Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Conditional HTML Form based on data from within a FEX

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Conditional HTML Form based on data from within a FEX
 Login/Join
 
Master
posted
I'm trying to build HTML from within a FEX, but I want some logical changes of style based on data response. I know this code doesn't work, unless you remove the whole IF statement, but hope it gives you an idea of what I'm trying to do.

TABLE FILE CAR
SUM CAR.BODY.DEALER_COST
	CAR.BODY.RETAIL_COST
BY CAR.ORIGIN.COUNTRY
BY CAR.COMP.CAR
-*ON TABLE PCHOLD FORMAT HTML
ON TABLE HOLD AS HOLDDIV FORMAT ALPHA
ON TABLE NOTOTAL
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET SQUEEZE ON
ON TABLE SET EMPTYREPORT ON
ON TABLE SET HTMLCSS ON
ON TABLE SET HTMLENCODE ON
ON TABLE SET CACHELINES 100
END

-RUN
-HTMLFORM BEGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"  "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<body>

-REPEAT HENDNUM FOR &MYDATA FROM 1 TO &LINES
-READFILE HOLDDIV

Country: !IBI.AMP.COUNTRY;<br/>
Car: !IBI.AMP.CAR;<br/>
DCost: !IBI.AMP.DEALER_COST;<br/>

-IF !IBI.AMP.DEALER_COST = 25000 THEN
-TYPE Note: Special!!
-END

RCost: !IBI.AMP.RETAIL_COST;<br/>

-HENDNUM
-ENDLOOP

</body>
</html>
-HTMLFORM END


Is something like this possible?

This message has been edited. Last edited by: <Kathryn Henning>,



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Master
posted Hide Post
I figured it out..


DEFINE FILE CAR
 SALE/A100=IF DEALER_COST EQ 25000 THEN '<font color=red>Note: Special!!!</font><br/>' ELSE '';
END

TABLE FILE CAR
SUM CAR.BODY.DEALER_COST
	CAR.BODY.RETAIL_COST
BY CAR.ORIGIN.COUNTRY
BY CAR.COMP.CAR
BY SALE
-*ON TABLE PCHOLD FORMAT HTML
ON TABLE HOLD AS HOLDDIV FORMAT ALPHA
ON TABLE NOTOTAL
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET SQUEEZE ON
ON TABLE SET EMPTYREPORT ON
ON TABLE SET HTMLCSS ON
ON TABLE SET HTMLENCODE ON
ON TABLE SET CACHELINES 100
END

-RUN
-HTMLFORM BEGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"  "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<body>

-REPEAT HENDNUM FOR &MYDATA FROM 1 TO &LINES
-READFILE HOLDDIV

Country: !IBI.AMP.COUNTRY;<br/>
Car: !IBI.AMP.CAR;<br/>
DCost: !IBI.AMP.DEALER_COST;<br/>!IBI.AMP.SALE;
RCost: !IBI.AMP.RETAIL_COST;<br/>

-HENDNUM
-ENDLOOP

</body>
</html>
-HTMLFORM END



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Master
posted Hide Post
Gavin,

What you are asking is possible. I would do it differently though. I would do something like this:

TABLE FILE CAR
SUM MAX.COUNTRY AS 'Country:' OVER
	MAX.CAR AS 'Car:' OVER
	DEALER_COST AS 'DCost:' OVER
	COMPUTE NOTE/A20V= IF DEALER_COST EQ 25000 THEN 'Special' ELSE ''; AS 'Note:' OVER
	RETAIL_COST AS 'RCost'
BY COUNTRY NOPRINT
BY CAR NOPRINT
ON CAR SUBFOOT
""
ON TABLE NOTOTAL
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET SQUEEZE ON
ON TABLE SET EMPTYREPORT ON
ON TABLE SET HTMLCSS ON
ON TABLE SET HTMLENCODE ON
ON TABLE SET CACHELINES 100
END  


if you absolutely feel the need to use the HTMLFORM begin and loop method, then you need to fix your -READ command. This is what the documentation says about -READ

quote:
Syntax: How to Retrieve a Variable Value From an External File
-READ filename[,] [NOCLOSE] &name[.format.][,][&name][.format.]
where:

filename[,]
Is the name of the external file, which must be defined to the operating system. A space after filename denotes a fixed-format file, while a comma denotes a free-format file.

On UNIX and Windows platforms, a FILEDEF for the external file is required.
On z/OS, the external file must be allocated in the JCL or dynamically allocated by WebFOCUS with the ALLOCATE command.
NOCLOSE
Keeps the external file open until the -READ operation is complete. Files kept open with NOCLOSE can be closed using the command -CLOSE filename or a subsequent -WRITE command.

&name[,]
Is the variable name. For free-format files, you may separate the variable names with commas. If the list of variables is longer than one line, end the first line with a comma and begin the next line with a dash followed by a blank. For fixed-format files, including comma-delimited files, begin the next line with a dash, a blank, and a comma.

Free-format

-READ EXTFILE, &CITY, &CODE1,- &CODE2
Fixed-format

-READ EXTFILE &CITY.A8. &CODE1.A3.,- ,&CODE2.A3.
.format.
Is the format of the variable. For a free-format file, specifying this value is optional. For a fixed-format file, format is the length or the type and the length. The type is either A (alphanumeric), which is the default, or I (numeric). The format value must be delimited by periods. The format is ignored for comma-delimited files.

Note: Instead of using .format., you can specify the length of a variable using -SET and enclosing the corresponding number of blanks in single quotes. For example:

-SET &CITY=' ';
-SET &CODE1=' ';
-SET &CODE2=' ';


It would look like this

 TABLE FILE CAR
SUM CAR.BODY.DEALER_COST
	CAR.BODY.RETAIL_COST
BY CAR.ORIGIN.COUNTRY
BY CAR.COMP.CAR
-*ON TABLE PCHOLD FORMAT HTML
ON TABLE HOLD AS HOLDDIV FORMAT ALPHA
ON TABLE NOTOTAL
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET SQUEEZE ON
ON TABLE SET EMPTYREPORT ON
ON TABLE SET HTMLCSS ON
ON TABLE SET HTMLENCODE ON
ON TABLE SET CACHELINES 100
END

-RUN
-HTMLFORM BEGIN
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"  "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<body>

-REPEAT HENDNUM FOR &MYDATA FROM 1 TO &LINES 

-READ HOLDDIV NOCLOSE &COUNTRY.A10 &CAR.A16 &DEALER_COST.A7 &RETAIL_COST.A7

Country: !IBI.AMP.COUNTRY;<br/>
Car: !IBI.AMP.CAR;<br/>
DCost: !IBI.AMP.DEALER_COST;<br/>

-SET &NOTE = IF &DEALER_COST EQ 25000 THEN 'Note: Special!!! <BR>' ELSE '';
&NOTE.EVAL

RCost: !IBI.AMP.RETAIL_COST;<br/>

-HENDNUM
-ENDLOOP
</body>
</html>
-HTMLFORM END
 


Personally I prefer using OVER. I can do it all within FOCUS code which means I can put into PDF, Excel, whatever. And it will be better to maintain in FOCUS as opposed to having to read the HTML code also.


Eric Woerle
8.1.05M Gen 913- Reporting Server Unix
8.1.05 Client Unix
Oracle 11.2.0.2
 
Posts: 750 | Location: Warrenville, IL | Registered: January 08, 2013Report This Post
Master
posted Hide Post
I had tried using the READ first and spent a few hours not getting the results to return in a format I could use. I was getting data size appended to the front, and it seem to be skipping some fields, but if I changed my variable to 200, I could then see it. I got frustrated and went back to READFILE. I'm looking at yours and I don't know what I was doing different as I overwrote it with my solution. arg..

Is there a reason, to use READ over READFILE? I like the ability to not have to provide out all the variables and their sizes, when READFILE, knows that already.



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Master
posted Hide Post
I'm reopening this, because I need to understand why I can't get it to work outside of your example. This is my code:

ENGINE INT CACHE SET ON

DEFINE FILE TBLRATELOCKVOLUME ADD
	RATETYPE/A150 = TBLRATELOCKVOLUME.TBLRATELOCKVOLUME.RATELOCKTYPE;
END

TABLE FILE TBLRATELOCKVOLUME
	SUM CNT.TBLRATELOCKVOLUME.TBLRATELOCKVOLUME.RATELOCKTYPE
	BY RATETYPE
-*ON TABLE PCHOLD FORMAT HTML
ON TABLE HOLD AS HOLDDIV FORMAT ALPHA
ON TABLE NOTOTAL
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET SQUEEZE ON
ON TABLE SET EMPTYREPORT ON
ON TABLE SET HTMLCSS ON
ON TABLE SET HTMLENCODE ON
ON TABLE SET CACHELINES 100
END

-RUN
-HTMLFORM BEGIN

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"  "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<body>

-REPEAT HENDNUM FOR &MYDATA FROM 1 TO &LINES 

-READ HOLDDIV NOCLOSE &RATETYPE.A50 &RATELOCKTYPE.I11

Type: !IBI.AMP.RATETYPE; - Rate: !IBI.AMP.RATELOCKTYPE;
-*-SET &NOTE = IF &RATETYPE EQ 'Current' THEN '<img src="/images/uptodate.jpg"><br/>' ELSE '<br/>';
-*&NOTE.EVAL

<br/>

-HENDNUM
-ENDLOOP

</body>
</html>
-HTMLFORM END


The results:
Type: Current - Rate: 
Type: Expired - Rate: 


The RateLockType.I11 isn't returning anything back to me. If I change that to A105, I get a value, but it defeats the purpose of what it's doing and I'm not 100% sure, it will always be A105.

This is pulling from SQL and the format of the column is an Int. I looked and WF has it as an I11. I went and looked at the car file and it was a D11, yet your example used A11. I tried using A11 and got nothing until I moved it to A255 and saw the value 105 bytes into the string. I'm totally confused.

Any help?



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Virtuoso
posted Hide Post
quote:
-READ HOLDDIV NOCLOSE &RATETYPE.A50 &RATELOCKTYPE.I11


".I11"? You're reading a character-string value (from an ALPHA hold file), and storing it as a character string (in an amper var). So the format should be A11.

But life would be simpler if you took advantage of -READFILE, and let it handle the details.


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Master
posted Hide Post
RATELOCKTYPE is an Int, that is being SUM'd.. I tried A11 and get nothing back. A105 returns it, but that makes no sense to me.



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Virtuoso
posted Hide Post
Look at your code:

DEFINE FILE TBLRATELOCKVOLUME ADD
RATETYPE/ A150 = TBLRATELOCKVOLUME.TBLRATELOCKVOLUME.RATELOCKTYPE;
END

TABLE FILE TBLRATELOCKVOLUME
SUM CNT.TBLRATELOCKVOLUME.TBLRATELOCKVOLUME.RATELOCKTYPE
BY RATETYPE
ON TABLE HOLD AS HOLDDIV FORMAT ALPHA
ON TABLE NOTOTAL
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET SQUEEZE ON
ON TABLE SET EMPTYREPORT ON
ON TABLE SET HTMLCSS ON
ON TABLE SET HTMLENCODE ON
ON TABLE SET CACHELINES 100
END
-RUN

. . .

-READ HOLDDIV NOCLOSE &RATETYPE. A50 &RATELOCKTYPE.I11[/quote]

. . .


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Master
posted Hide Post
Gavin,

If -READFILE works better for you, by all means use that. I just learned using -READ. Its what I'm used to, so its what I use.

As for why declaring your field as an 'A11' vs an 'A105' I would suggest doing "ON TABLE SAVE AS HHOLDDIV" and exiting after words. This will provide your hold structure for you. You can then see the format of each field and know exactly what size your amper varialbes need to be.

At the end of the day, I would still use the OVER syntax or some other form of TABLE FILE Manipulation. I don't know what your end game is, but I personally would prefer being able to easily put the report into PDF or Excel if I needed to. Again, just my 2 cents, but I think you're adding unneeded complexity by directly writing the HTML...


Eric Woerle
8.1.05M Gen 913- Reporting Server Unix
8.1.05 Client Unix
Oracle 11.2.0.2
 
Posts: 750 | Location: Warrenville, IL | Registered: January 08, 2013Report This Post
Master
posted Hide Post
Well, mixed up my message, but that would be for RATETYPE, which is the ASCII value, but RATELOCKTY is the COUNT, which is what I'm trying to retrieve. When I looked in WebFOCUS, I looked at the wrong column, which is an INT.. I still have the same issue..

A11 isn't working as its the count I'm trying to retrieve and get nothing back.



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Virtuoso
posted Hide Post
Regardless, you're holding the count as a character string, so you read it in as a character string.

But you've defined the first column of the hold file, RATETYPE, as A150, so you need to -READ accordingly:
-READ HOLDDIV NOCLOSE &RATETYPE.A150 &RATELOCKTYPE.A11
                                 ***
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Master
posted Hide Post
By changing from:
-READ HOLDDIV NOCLOSE &RATETYPE.A50 &RATELOCKTYPE.A11

To

-READ HOLDDIV NOCLOSE &RATETYPE.A150 &RATELOCKTYPE.A11


My results went from:
Type: Current - Rate: 
Type: Expired - Rate: 


To
Type: Current - Rate: 50Expire 
Type: Current - Rate: 50Expire 


I changed nothing else.



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Master
posted Hide Post
I changed it to:
-READ HOLDDIV NOCLOSE &RATETYPE.A150 &RATELOCKTYPE.A5

and I get the correct results.. I think the 150 was a most definite issue, but if I don't know what size SUM is going to return, because I can see it being larger than 5 bytes at times. If I put A6, I get the next records first character, from what data I have.



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Virtuoso
posted Hide Post
The width of the count column will be either 5 or 9 depending on SET COUNTWIDTH.

So that's one more run-time factor that could eventually trip the fex up in production; and -READFILE would finesse it.

-READFILE HOLDDIV

It's that simple. It will populate &vars with the same name as the respective HOLD columns, based on content of the Hold synonym. And no need for NOCLOSE.
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Conditional HTML Form based on data from within a FEX

Copyright © 1996-2020 Information Builders