Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED]-IF statement not working correctly
Go
New
Search
Notify
Tools
Reply
  
[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: 111 | Registered: May 28, 2015Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Would it make a difference if you say THEN GOTO PSYCEND; ?


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


WF8
Windows
 
Posts: 111 | Registered: May 28, 2015Reply With QuoteReport 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: 1659 | Location: New York City | Registered: December 30, 2015Reply With QuoteReport 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,


Senior Business Intelligence Analyst (BIA) @ Enclara Pharmacia
Production: WF 8.09, App Studio, BIP, RC, MSSQL / Test: WF 8204, App Studio, BIP, Reportcaster, Resource Manager, MSSQL
 
Posts: 290 | Location: Greater Cincinnati  | Registered: May 11, 2005Reply With QuoteReport 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: 1566 | Location: Customer Support | Registered: April 12, 2005Reply With QuoteReport 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: 390 | Location: Europe | Registered: February 05, 2007Reply With QuoteReport 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.06 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5601 | Location: United Kingdom | Registered: April 08, 2004Reply With QuoteReport 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: 1643 | Location: Enschede, Netherlands | Registered: August 12, 2010Reply With QuoteReport 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 7 - IE11.
in Focus since 1988
 
Posts: 1960 | Location: Netherlands | Registered: September 25, 2007Reply With QuoteReport 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: 111 | Registered: May 28, 2015Reply With QuoteReport This Post
  Powered by Social Strata  
 

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

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.