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     Branching based on query results

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Branching based on query results
 Login/Join
 
<Tom Pettit>
posted
For some reason I am stuck on this issue, but I am betting there is a simple solution.

I wilk skip the details and focus on the problem area. Basically I need to lookup a value in a database - the result of the query will be a single integer value. Let's just say it will be either 1 or 0.

Then based on what that value is, I need to branch and run a different fex. So lets say if the value is 0 I would run myfex0.fex and if it is 1 then I would run meyfex1.fex.

I know how to use DM to branch and run the different reports if I get the parameter value from my HTML page, but the user does not know this value, so how do I look up the value in a table and then pass it to DM?
 
Report This Post
Virtuoso
posted Hide Post
I take it from your comment on the user doesn't know the value, that you have more than two simple ones. The dialog manager gurus on this forum might need a bit more detail on how you plan to launch the application. You can use dialog manager to read values from a file. Does the application have other selection criteria as well?


Leah
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Expert
posted Hide Post
I would do something like this:
TABLE FILE LOOKUP
PRINT CODE_VALUE
WHERE TESTFLD EQ '&WHATEVER'
ON TABLE SAVE
END
-RUN
-IF &LINES EQ 0 GOTO NODATE;
-READ SAVE &CODE_VALUE.I1.
-SET &FEXNAME=DECODE &CODE_VALUE(0 'myfex0' 1 'myfex1');
EX &FEXNAME  


This is just a skeleton but hopefully it will help you out.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
 
Posts: 2723 | Location: Ann Arbor, MI | Registered: April 05, 2006Report This Post
Expert
posted Hide Post
-SET &ECHO=ALL;

SET HOLDFORMAT=ALPHA   
SET HOLDLIST=PRINTONLY
-RUN

TABLE FILE CAR
PRINT
SEATS/I2L
WHERE RECORDLIMIT EQ 1
ON TABLE HOLD AS H001
END
-RUN

-READ H001 &SEATS.I2.


-TYPE &SEATS

-INCLUDE MYPROG&SEATS
 


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
<Tom Pettit>
posted
That is right, Leah: the user does not know the value (in fact, it is actually a web service call, but I did not want to overly complicate my question). I have actually had several scenarios where I needed something similar to this, but I have never gotten around to posting it here.

I COULD use dialog managers -READ to get it from a file, but I would need to refresh the file and I just thought there would be any easier way that I am missing.
 
Report This Post
<Tom Pettit>
posted
Thanks Francis and Ginny!

I think you both got what I was missing - correct me if i am wrong:

By putting the -RUN command in there, everything before that command will run, but the DM code AFTER that command won't run until after that first section of code runs?

That is what I didn't get, because I knew the DM code runs first.
 
Report This Post
Virtuoso
posted Hide Post
tom,

Your signature does not show what version of WebFOCUS you are using. There are old fashion ways to do this and then there is a DB_LOOKUP function avaialble in the 76x versions which may be useful. Check the Using Functions manual.


Thanks!

Mickey

FOCUS/WebFOCUS 1990 - 2011
 
Posts: 995 | Location: Gaithersburg, MD, USA | Registered: May 07, 2003Report This Post
Expert
posted Hide Post
Tom,

Yes, the -RUN command is very important if you have DM commands after the WF statements. I have a habit of putting a -RUN after every complete WF statement (after the END, after a JOIN, etc), whether or not there's DM...


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
<Tom Pettit>
posted
One last question: I assume from the solutions you all have proposed that you cannot pass the results of a query or procedure directly to a parameter or variable/array somehow - the only way you can use those results later is to save them in a file, correct?

That is not a problem, but it just seems like that would be easy to add to the language.
 
Report This Post
Expert
posted Hide Post
If you want that capability you can always request a New Feature Request (NFR) by opening a case.

And depending on the type of file, fixed/flat, you could -READ directly from that file into a variable.

And, lastly, could you please update your profile signature so that it includes your product suite, releases, and platform. That will allow us to better help you.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
 
Posts: 2723 | Location: Ann Arbor, MI | Registered: April 05, 2006Report This Post
Master
posted Hide Post
Tom,

I'm not sure what you are wanting to accomplish. You can pass variables in the same way you would in a drill down.
EX CAR CAR_1=VOLVO CAR_2=JAGUAR


Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
 
Posts: 755 | Location: TX | Registered: September 25, 2007Report This Post
<Tom Pettit>
posted
quote:
Originally posted by PBrightwell:
You can pass variables in the same way you would in a drill down.
EX CAR CAR_1=VOLVO CAR_2=JAGUAR


Yes, Pat - I understand the passing of values to a procedure, but the values I want to pass in this case are initially in a table. So it appears the solution is get the values from the table, write them to a file and then READ them so that they can then be passed to the procedure.

I just wanted to verify that there is no way to skip the steps of writing to a file and then reading from that file. The solutions above work fine, but it just seemed that there should be a way to assign a value to some sort of global variable in memory rather than write it to a file, but it is not a big deal.

(hopefully my signature is working now - we will see after I post this.) Red Face
 
Report This Post
Platinum Member
posted Hide Post
Tom Pettit,

Think of DM as a text-based "script pre-processor".
It reads your *.fex file and sends it's output to a 'stack' of processed FOCUS source code.
As each line of input is read, it is parsed for &text and &&text strings which are replaced with the curent value of the indicated &variable. Only one pass is made, so you get one chance to substitute other characters for your &/&&strings. [That's why DM treats numeric values as characters; it's a character string pre-processor; everything is alpha strings.]
Then, it looks at the line's first character.
- If that's other than "-" the resulting modified input line is added to the stack.
- If that's a "-" it treats the modifed line as a command and does what the command says. Nothing goes into the stack.

The stack of processed text keeps growing until DM encounters a "-RUN". Then DM dispatches the stack's content to the FOCUS "ENGINE" for interepretation and execution.
Your *.fex procedure is thus executed in chunks divided by "-RUN"s.
"-EXIT" and "-QUIT" flush DM, the stack's current content, and (perhaps) the remainder of the *.fex.

I Hope this model helps you understand the sequence of how things run and why they appear in the log and "ECHO" output as they do.

You're right about the inability to pass stuff as parameters. The "TABLE FILE ... END" is a closed block for the "ENGINE" to chew on.
DM "-" lines inside it serve to alter the text of the FOCUS code that's stacked and executed.
DM "-" lines outside of it change the flow of logic and cause stacking of alternative texts.
Both contribute to the ability of procedures to dynamically modify themselves; run a different procedure at each 'run'.

The -WRITE/-READ process is the only way I know of to pass information from inside TABLE ... END to DM on the outside.

Unfortunately, DevStudio denies the ability to imbed DM inside the TABLE ... END block so half of it's power is scrificed by those who stick with point-n-click tools.

Chris

This message has been edited. Last edited by: cburtt,


WIN/2K running WF 7.6.4
Development via DevStudio 7.6.4, MRE, TextEditor.
Data is Oracle, MS-SQL.
 
Posts: 154 | Location: NY | Registered: October 27, 2005Report This Post
<Tom Pettit>
posted
Thanks for that excellent explanation, Chris!

This will help me a lot going forward. I understood the idea of DM as a 'pre-processor', and have been using that regularly, but totally missed the power of being able to plug in some -RUNs in order to sort of 'switch' between DM and FOCUS code.

Tom
 
Report This Post
Expert
posted Hide Post
Tom how about trying this.

TABLE FILE LOOKUP
PRINT COMPUTE
      EX_LINE/A50 = 'EX MYFEX' || CODE_VALUE ;
WHERE TESTFLD EQ '&WHATEVER'
ON TABLE SAVE AS GEN_FEX
END
-RUN
-IF &LINES EQ 0 GOTO NODATE;
-INCLUDE GEN_FEX 


The Hold or Save file can be included as a FOCEXEC.

Cut and Paste this and see.
TABLE FILE CAR
PRINT COMPUTE
      EX_CMD/A50 = 'EX MYFEX' || EDIT(SEATS) ;
WHERE RECORDLIMIT EQ 1
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SAVE AS GEN_FEX
END
-RUN
-INCLUDE GEN_FEX


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report 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     Branching based on query results

Copyright © 1996-2020 Information Builders