Focal Point
How to Use where condition in a IF Statement ?

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4191078992

September 19, 2008, 11:36 AM
Rekha
How to Use where condition in a IF Statement ?
Hi All,

I am new to this WebFocus, I dont know how to use either one WHERE condition from the IF statement.
Let me expalin below:
I am creating the report , which will drill down to 2 child reports. the lower level child will contain the detailed information.So when i drill down from 1st child to 2nd i am having fields with passing paramaters.In the 1st child report there are fields like F1,F2,F3,F4 etc..
If i click on the one of the rows in the report, it will pass the info to 2nd child report, while passing values, some of the fields like F3, or F4 will contain the NULL values, so that the 2nd child will not be executed, to do so i need to write a IF statement like
IF F3 EQ null then
(where condition like,, F1= '&F1' and F2='&F2' and F3=Null)
ELSE
(where condition like,, F1= '&F1' and F2='&F2' and F3='&F3')
END IF

But i dont know the Syntax. Please any one help me on this problem ?


WebFocus 7.6.4
windows XP
MS SQL 2000/2005
September 19, 2008, 12:00 PM
GinnyJakes
Rekha,

First of all, please update your profile signature with your products, releases, and platforms so that we can better help you.

Second, please look up the syntax for IF and WHERE in the "Creating Reports with the WebFOCUS Language" manual which can be found by clicking on the documentation link in the upper righthand corner of this page.

Third, IF statements cannot be compound in the body of the report; they can only be compound on the righthand side of an equal sign in a define or compute. So I would suggest that you use WHERE to construct your screening conditions.

You might also want to search this forum and the documentation for FOC_NONE as this might help you with your problem.


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
September 19, 2008, 04:23 PM
j.gross
The received parameters are "dialog manager" variables (&F1 etc.). Dialog manager is a scripting language, with decision logic. It has ancient roots, and is GOTO- rather then block-oriented.

You can use D.M. to test the parameters and branch to appropriate reporting code:

-IF (&F3 EQ '') THEN GOTO CASE2
-ELSE
-IF (&F2 EQ '') THEN GOTO CASE3;

-CASE1
. . . appropriate code for case 1
-GOTO DONE
-CASE2
. . .
-GOTO DONE
-CASE3
. . .
-DONE

You get the idea?


- Jack Gross
WF through 8.1.05
September 19, 2008, 04:53 PM
EWoerle
actually you don't need to use the goto's. you could do it much simpler in DM this way

-SET &WHEREF1 = IF &F3 EQ '' THEN 'WHERE ....'
- ELSE IF F2 EQ '' THEN 'WHERE ....'
- ELSE ''

ETC.

then where you would normally put the where statement, call the variable
&WHEREF1.EVAL
  

When the FEX executes it will replace the amper statement with the appropriate where statement


Eric Woerle
WF 7.6.7 Reportting Server
ETL 7.6.10
Dev Studio 7.6.7
September 20, 2008, 01:52 AM
FrankDutch
Hi Rekha

Lots of suggestion for this obvious simple question.
I can add some more ways to handle this and confuse you more and more.
What is DM?
What does Ginny mean by "body of the report"

What you really need to do is go to your manager and ask (maybe force) him to send you to one ore more basic trainings.

It will help you a lot and your questions and our helpful hints will be much more valuable.

Have a nice weekend...




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

September 20, 2008, 03:16 PM
Doug
Frank, Yes. The Forum should be for more advanced topics, right? But, then again, new users will get a good basis / familiarity with the Forum and, thus, be beneficial to all in the long run, right?

I like your thinking Eric,
I would have only added two things. 1: the closing semi-colon and a '-* No Op notation' in the ELSE so that it would show up during a -SET &ECHO = ALL ;

-Doug




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
September 22, 2008, 03:31 AM
GamP
Rekha,

The first child needs parameters to do its thing. These parameters come from the parent procedure. Should not the second child also need the first child's parameters?
If yes, then just propagate them to the second child. You can do this by adding them to the parameter list of the drilldown command:
focexec=child2(f1=&f1.quotedstring f2=&f2.quotedstring f3=field3 ...etc)
The parameter list can be a mix of &values and report fields....


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
September 24, 2008, 10:09 PM
Brian Suter
I would like to re-enforce doing this code with sets. First of all, using -SET is very compatable with the report painter because the prefix execution before the painter opens has no ambiguity.
Secondly there is the magic of FOC_NONE ... it allows lines to be thrown away at execution time. I regularly use a parm style that allows a user to say ALL which means I do not want a WHERE.
-DEFAULT PROD = ALL
..
-SET &WHPROD = IF &PROD EQ 'ALL' THEN 'FOC_NONE' ELSE &PROD ;
...
TABLE FILE ...
WHERE PRODUCT EQ '&WHPROD';
...
TYPE=DATA,COLUMN=..
FOCEXEC=child_fex(P1=N1 PROD=&PROD.QUOTEDSTRING ...)

This allows the system to throw away the WHERE statement, but pass PROD='ALL' in the drilldown. And this style works fine with devstudio report painter.


Brian Suter
VP WebFOCUS Product Development