Focal Point
[SOLVED] Error with IF Then Else

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

September 09, 2009, 02:23 PM
OnQuest
[SOLVED] Error with IF Then Else
Here is my code that gives me the EXPRESSION IS INCOMPLETE BECAUSE AN OPERATION IS MISSING error. I've tried changing the || to a single | concatenation operator, but still the error persists.
DEFINE FILE HOLDFILE1

DISPLAY_NM2/A500 = 	IF CAR_NM IS NOT MISSING 
					THEN ' ['  || CAR_NM || ' - ' || ( IF SQNC_NB IS NOT MISSING THEN  BR_NB ELSE RGN_CD ) || '] ' ;

END  

Any ideas on what is missing?
Thank you!

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


WebFOCUS 767, Windows XP
Excel, HTML, PDF
September 09, 2009, 03:11 PM
Francis Mariani
You cannot embed a second IF statement within the first one.

Try something like this instead:

DEFINE FILE HOLDFILE1
DISPLAY_NMXX/A50 = IF SQNC_NB IS NOT MISSING THEN BR_NB ELSE RGN_CD;
DISPLAY_NM2/A500 = IF CAR_NM IS NOT MISSING THEN ' [' || CAR_NM || ' - ' || DISPLAY_NMXX || '] ' ELSE '';
END



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
September 09, 2009, 05:48 PM
Tom Flynn
Here is a format with a nested IF currently in production:

  
February/P12.3CB = IF '&MO2' GE '02' THEN 
                  (IF Month EQ '02' AND VERSIONS_KEY EQ 'ACT'    THEN Amount ELSE 0)
                 ELSE
                   IF Month EQ '02' AND VERSIONS_KEY EQ 'PLAN01' THEN Amount ELSE 0;


This "may" be the syntax you are looking for...

hth


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
September 10, 2009, 02:26 AM
GamP
And you're also missing the ELSE part.
The following DEFINE should syntactically correct (did not test it):
DEFINE FILE HOLDFILE1
DISPLAY_NM2/A500 = IF CAR_NM IS MISSING THEN '?' ELSE
                   IF SQNC_NB IS NOT MISSING THEN
                   ' ['  || CAR_NM || ' - ' || BR_NB || '] ' ELSE
                   ' ['  || CAR_NM || ' - ' || RGN_CD || '] ' ;
END



GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
September 16, 2009, 11:49 AM
OnQuest
Thanks Everyone.
I replaced the nested If with a define variable and also added the missing else ' ' at the end.
that worked for me.


WebFOCUS 767, Windows XP
Excel, HTML, PDF