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. Moving forward, myibi is our community platform to learn, share, and collaborate. We have the same Focal Point forum categories in myibi, so you can continue to have all new conversations there. If you need access to myibi, contact us at myibi@ibi.com and provide your corporate email address, company, and name.


Connect to myibi
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED]-IF statement not working correctly

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED]-IF statement not working correctly
 Login/Join
 
Platinum Member
posted
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
 
Posts: 117 | Registered: May 28, 2015Report This Post
Virtuoso
posted Hide Post
Would it make a difference if you say THEN GOTO PSYCEND; ?


WebFOCUS 8206, Unix, Windows
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Platinum Member
posted Hide Post
I tried that and it didn't work, got the same results.


WF8
Windows
 
Posts: 117 | Registered: May 28, 2015Report This Post
Virtuoso
posted Hide Post
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
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Guru
posted Hide Post
-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
 
Posts: 291 | Location: Greater Cincinnati  | Registered: May 11, 2005Report This Post
Virtuoso
posted Hide Post
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
 
Posts: 2128 | Location: Customer Support | Registered: April 12, 2005Report This Post
Guru
posted Hide Post
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.
 
Posts: 454 | Location: Europe | Registered: February 05, 2007Report This Post
Expert
posted Hide Post
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 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Virtuoso
posted Hide Post
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 :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Virtuoso
posted Hide Post
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
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Platinum Member
posted Hide Post
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
 
Posts: 117 | Registered: May 28, 2015Report 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]-IF statement not working correctly

Copyright © 1996-2020 Information Builders