Focal Point
[SOLVED]-IF statement not working correctly

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

January 30, 2019, 03:25 PM
Trudy
[SOLVED]-IF statement not working correctly
Can anyone see what is wrong with this code, it should be going to the PSYCEND and I can't seem to get it to work.

-IF (&MAJCRI EQ Y) AND (&MAJOR EQ 'Psychology') GOTO PSYCEND;

-IF (&MAJCRI EQ Y) AND (&MAJOR EQ 'Sociology' OR 'Sociology/Appl Social Relation') GOTO SOCOEND;

WHERE ( J0.SHRTCKN.SHRTCKN_TERM_CODE LE '&TERM' ) AND ( J0.SHRTCKN.SHRTCKN_SUBJ_CODE EQ &SUBJ )  AND ( J0.SHRTCKN.SHRTCKN_CRSE_NUMB GE '&CRSE' )AND (( J0.SHRTCKN.SHRTCKN_REPEAT_COURSE_IND NE 'A' OR 'E' ) OR ( J0.SHRTCKN.SHRTCKN_REPEAT_COURSE_IND IS MISSING)) AND ( J2.SHRGRDE.SHRGRDE_LEVL_CODE EQ 'UG' ) AND ( J2.SHRGRDE.SHRGRDE_GPA_IND EQ 'Y' );
-GOTO ENDWHERE

-PSYCEND
WHERE AHCourse NE 'PSY100' OR 'PSY480' OR 'PSY491' OR 'PSY496' OR 'PSY497' OR 'PSY498';
-GOTO ENDWHERE

-SOCOEND
WHERE AHCourse EQ 'SOC100' OR 'SOC201' OR 'SOC300' OR 'SOC350' OR 'SOC351' OR 'SOC400';
-GOTO ENDWHERE

-ENDWHERE
  


I get the following when I run it and the &ECHO=ALL


 -IF (Y EQ Y) AND ('Psychology' EQ 'Psychology') GOTO PSYCEND;
 -IF (Y EQ Y) AND ('Psychology' EQ 'Sociology' OR 'Sociology/Appl Social Relation') GOTO SOCOEND;
 WHERE ( J0.SHRTCKN.SHRTCKN_TERM_CODE LE '201940' ) AND ( J0.SHRTCKN.SHRTCKN_SUBJ_CODE EQ 'PSY' )  AND ( J0.SHRTCKN.SHRTCKN_CRSE_NUMB GE '_FOC_NULL' )AND (( J0.SHRTCKN.SHRTCKN_REPEAT_COURSE_IND NE 'A' OR 'E' ) OR ( J0.SHRTCKN.SHRTCKN_REPEAT_COURSE_IND IS MISSING)) AND ( J2.SHRGRDE.SHRGRDE_LEVL_CODE EQ 'UG' ) AND ( J2.SHRGRDE.SHRGRDE_GPA_IND EQ 'Y' );
 -GOTO ENDWHERE
 -ENDWHERE
  

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


WF8
Windows
January 30, 2019, 03:30 PM
BabakNYC
Would it make a difference if you say THEN GOTO PSYCEND; ?


WebFOCUS 8206, Unix, Windows
January 30, 2019, 03:33 PM
Trudy
I tried that and it didn't work, got the same results.


WF8
Windows
January 30, 2019, 03:49 PM
BabakNYC
Can you test this and see if it works? Also what version of WebFOCUS are you running?
  
-SET &ECHO=ALL;
-DEFAULT &MAJCRI='Y'
-DEFAULT &MAJOR= 'Psychology'
-IF (&MAJCRI EQ Y) AND (&MAJOR EQ 'Psychology') GOTO PSYCEND;
-TYPE DIDN'T WORK
-GOTO ENDWHERE
-PSYCEND
-TYPE IT WORKED
-ENDWHERE



WebFOCUS 8206, Unix, Windows
January 30, 2019, 04:08 PM
Don Garland
-SET &MAJOR = IF &MAJOR CONTAINS 'Sociology/Appl Social Relation' THEN Sociology ELSE &MAJOR;

-IF &MAJCRI EQ Y GOTO &MAJOR;

WHERE ( J0.SHRTCKN.SHRTCKN_TERM_CODE LE '&TERM' ) AND ( J0.SHRTCKN.SHRTCKN_SUBJ_CODE EQ &SUBJ )  AND ( J0.SHRTCKN.SHRTCKN_CRSE_NUMB GE '&CRSE' )AND (( J0.SHRTCKN.SHRTCKN_REPEAT_COURSE_IND NE 'A' OR 'E' ) OR ( J0.SHRTCKN.SHRTCKN_REPEAT_COURSE_IND IS MISSING)) AND ( J2.SHRGRDE.SHRGRDE_LEVL_CODE EQ 'UG' ) AND ( J2.SHRGRDE.SHRGRDE_GPA_IND EQ 'Y' );
-GOTO ENDWHERE

-Psychology
WHERE AHCourse NE 'PSY100' OR 'PSY480' OR 'PSY491' OR 'PSY496' OR 'PSY497' OR 'PSY498';
-GOTO ENDWHERE

-Sociology
WHERE AHCourse EQ 'SOC100' OR 'SOC201' OR 'SOC300' OR 'SOC350' OR 'SOC351' OR 'SOC400';
-GOTO ENDWHERE

-ENDWHERE

This message has been edited. Last edited by: Don Garland,


WebFOCUS Administrator @ Worldpay FIS
PROD/DEV/TEST: 8204, SANDBOX: 8206 soon - BIP, Reportcaster, Resource Manager, EUM, HyperStage soon, DB: HIVE,Oracle,MSSQL
January 30, 2019, 09:27 PM
FP Mod Chuck
Trudy

Could it be as simple as putting tick marks around the 'Y'....


-IF (&MAJCRI EQ 'Y') AND (&MAJOR EQ 'Psychology') GOTO PSYCEND;



Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
January 31, 2019, 04:15 AM
Frans
Not sure where the parameters are set, but this could also help:

-IF (&MAJCRI.EVAL EQ Y) AND (&MAJOR.EVAL EQ 'Psychology') GOTO PSYCEND;


Test: WF 8.2
Prod: WF 8.2
DB: Progress, REST, IBM UniVerse/UniData, SQLServer, MySQL, PostgreSQL, Oracle, Greenplum, Athena.
January 31, 2019, 04:28 AM
Tony A
This seems to be an area that recurs in posts, so I thought that it would be useful to add a document link -
Navigating a procedure

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
January 31, 2019, 05:39 AM
Wep5622
Is that your entire code?

I suspect that you may have a dialog-manager statement before, that requires a terminating semi-colon and doesn't have one. Probably a -SET or a -DEFAULT.

If that is the case, the statement continues on into your -IF line and terminates at that semi-colon.

The next -IF line is evaluated properly, but of course the condition does not evaluate true.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
January 31, 2019, 07:40 AM
GamP
In this specific case the give-away is the quotes around the translation of the &MAJOR variable in the output of the echo.
Apparently the variable comes in to the procedure including the quotes. And then you compare it with a value without quotes, where, of course, it is decided that both are not equal.
So either remove the quotes from the variable before comparing, or compare to a value with the extra quotes added.
The latter:
-IF (&MAJCRI EQ Y) AND (&MAJOR EQ '''Psychology''') GOTO PSYCEND;


And, personally, I'd advise to keep the code as tidy as possible. In my fex this code would be:
-IF (&MAJCRI EQ 'Y') AND (&MAJOR EQ '''Psychology''') THEN GOTO PSYCEND;



GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
February 01, 2019, 01:40 PM
Trudy
GamP

Your solution was correct, thank you. I don't know how you figured it out from the echo though since both sides of the equal sign had quotes.


WF8
Windows