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.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] IF and GOTO problem

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] IF and GOTO problem
 Login/Join
 
Member
posted
Hi all,
for &VARIABLE12 even if the value is other than 'A' on &OP_DSP its always giving 'AUSTRALIA QLY'.not going to other GOTO, why? can any one help me out.

here in my code:
-IF &VARIABLE12 EQ 'A' THEN GOTO DSP_A;
-IF &VARIABLE12 EQ 'B' THEN GOTO DSP_B;
-IF &VARIABLE12 EQ 'C' THEN GOTO DSP_C;
-IF &VARIABLE12 EQ 'D' THEN GOTO DSP_D;
-TYPE VARIABLE12 &VARIABLE12

-DSP_A
-SET &OP_DSP = 'AUSTRALIA QLY';
-GOTO LBL_END;

-DSP_B
-SET &OP_DSP = 'BRITAIN';
-GOTO LBL_END;

-DSP_C
-SET &OP_DSP = 'WXY';
-GOTO LBL_END;

-DSP_D
-SET &OP_DSP = 'DENMARK';
-GOTO LBL_END;

-LBL_END

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


webfocus 7.6.9 windows XP Excel
 
Posts: 22 | Registered: July 22, 2009Report This Post
Gold member
posted Hide Post
I think you might need to add an ELSE for the values other than A,B,C,D.
What's happening here is that if the values are not A,B,C or D; the code lets you to the next statement where value "AUSTRALIA QLY' is set.

After all the IFs, try this:
-IF &VARIABLE12 EQ 'D' THEN GOTO DSP_D
ELSE
GOTO LBL_END

or you can put any other logic(setting any default value) in the ELSE, as per your requirements.


webFOCUS 7.6.x,
z/OS(Mainframes),
Excel and HTML
 
Posts: 51 | Registered: August 31, 2009Report This Post
Platinum Member
posted Hide Post
I notice that you have a -TYPE &VARIABLE12, is there any variables other than 'A' getting displayed when you run the report?


Prod: WebFocus 7.7.3 Win 2003
Dev: WebFocus 7.7.3 Win 2003
 
Posts: 116 | Registered: April 23, 2007Report This Post
Platinum Member
posted Hide Post
Use DECODE function;

-SET &OP_DSP=DECODE &VARIABLE12('A' 'AUSTRALIA QLY' 'B' 'BRITAIN' 'c' 'WXY' ELSE 'DENMARK');


Regards,
Cyril Joy.

WF Production 8008 on Linux.
 
Posts: 143 | Location: Rochester,NY. | Registered: August 20, 2004Report This Post
Platinum Member
posted Hide Post
Also you try adding '&VARIABLE12' within quotes in the IF condition.


Regards,
Cyril Joy.

WF Production 8008 on Linux.
 
Posts: 143 | Location: Rochester,NY. | Registered: August 20, 2004Report This Post
Virtuoso
posted Hide Post
Could there be leading or trailing blanks in the variable's content?
I suggest a decode, rather than a plateful of GOTOs and labels:
-TYPE * &|VARIABLE12 / &VARIABLE12.LENGTH = '&VARIABLE12'
-SET &OP_DSP = DECODE &VARIABLE12 (
-    A  'AUSTRALIA QLY'
-    B  'BRITAIN'
-    C  'WXY'
-    D  'DENMARK'
-  ELSE '?');


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Member
posted Hide Post
Hi

yes for -TYPE &VARIABLE12, i am getting whatever value i am passing A,B,C OR D...


webfocus 7.6.9 windows XP Excel
 
Posts: 22 | Registered: July 22, 2009Report This Post
Virtuoso
posted Hide Post
But is its .LENGTH =1?
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
1) Jack's suggestion makes a lot of sense.
2) If you have leading blanks in the variable value, you will get the behaviour as you described.

Jack's code prints the length of the variable, to ensure you're passing a one-character value.

-DEFAULT &VARIABLE12 = ' B';

-IF &VARIABLE12 EQ 'A' THEN GOTO DSP_A;
-IF &VARIABLE12 EQ 'B' THEN GOTO DSP_B;
-IF &VARIABLE12 EQ 'C' THEN GOTO DSP_C;
-IF &VARIABLE12 EQ 'D' THEN GOTO DSP_D;
-TYPE VARIABLE12 &VARIABLE12

-DSP_A
-SET &OP_DSP = 'AUSTRALIA QLY';
-GOTO LBL_END;

-DSP_B
-SET &OP_DSP = 'BRITAIN';
-GOTO LBL_END;

-DSP_C
-SET &OP_DSP = 'WXY';
-GOTO LBL_END;

-DSP_D
-SET &OP_DSP = 'DENMARK';
-GOTO LBL_END;

-LBL_END
-TYPE &VARIABLE12 - &VARIABLE12.LENGTH - &OP_DSP 


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
To give another example apart from Jack's and Francis's excellent idea/example:

  
-SET &ECHO=ALL;
-DEFAULT &VARIABLE12 = '       C';
-SET &X_VAR12 = LJUST(&VARIABLE12.LENGTH, &VARIABLE12, 'A&VARIABLE12.LENGTH');
-SET &Y_VAR12 = EDIT(&X_VAR12,'9');
-IF &Y_VAR12 EQ 'A' THEN GOTO DSP_A;
-IF &Y_VAR12 EQ 'B' THEN GOTO DSP_B;
-IF &Y_VAR12 EQ 'C' THEN GOTO DSP_C;
-IF &Y_VAR12 EQ 'D' THEN GOTO DSP_D;

-DSP_A
-TYPE VARIABLE12 = &Y_VAR12
-SET &OP_DSP = 'AUSTRALIA QLY';
-GOTO LBL_END;

-DSP_B
-TYPE VARIABLE12 = &Y_VAR12
-SET &OP_DSP = 'BRITAIN';
-GOTO LBL_END;

-DSP_C
-SET &OP_DSP = 'WXY';
-GOTO LBL_END;

-DSP_D
-SET &OP_DSP = 'DENMARK';
-GOTO LBL_END;

-LBL_END
-TYPE OP_DSP = &OP_DSP 


Output:

  
-DEFAULT &VARIABLE12 = '       C';
 -SET &X_VAR12 = LJUST(08,        C, 'A08');
 -SET &Y_VAR12 = EDIT(C       ,'9');
 -IF C EQ 'A' THEN GOTO DSP_A;
 -IF C EQ 'B' THEN GOTO DSP_B;
 -IF C EQ 'C' THEN GOTO DSP_C;
 -DSP_C
 -SET &OP_DSP = 'WXY';
 -GOTO LBL_END;
 -LBL_END
 -TYPE OP_DSP = WXY
 OP_DSP = WXY


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Virtuoso
posted Hide Post
I NEVER use a -IF that does not have some sort of ELSE. That assures that EVERY possible value is accounted for and handled in some way.

To accomplish your -SETs, Jack's got the best way using a DECODE. To accomplish you branching for some other purpose, try:

-IF &VARIABLE12 EQ 'A' THEN GOTO DSP_A ELSE
- IF &VARIABLE12 EQ 'B' THEN GOTO DSP_B ELSE
- IF &VARIABLE12 EQ 'C' THEN GOTO DSP_C ELSE
- IF &VARIABLE12 EQ 'D' THEN GOTO DSP_D ELSE
- GOTO LBL_END;


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Platinum Member
posted Hide Post
Hi all,
I think you should not write
-GOTO LBL_END;
but
-GOTO LBL_END
No ';' in a -GOTO Statement
But, as so many, since -IF statement requires a ';', you come to think that -GOTO is on the same logic
That's why Old Focusians always let a space before ';'
-GOTO LBL_END ; is not the best way to write, but it works.
It doesn't search for a Label -LBL_END; but for the Proper Label -LBL_END

Same Remark with -SET : ';' compulsory
and -DEFAULT(s): No ';' but ',' allows different variables to be Defaulted on a single line
Cordially and Focusely
PS : This Rule is so old, that, perhaps, it's not longer true. NotWithstanding, untill I die, I'll never write -GOTO WAY_OUT;
( As I'll never begin a Focus Statement in Position 1, which I let to the '-' of DM => So I see, at first sight if I'm playing with Focus or with DM... Which is rather important to know. And which DS hides ... But, Do I like DS ? Anyway DS doesn't care much about my loving or not ...)


Focus Mainframe 7.6.11
Dev Studio 7.6.11 and !!!
PC Focus, Focus for OS/2, FFW Six, MSO
 
Posts: 134 | Registered: November 06, 2007Report This Post
Master
posted Hide Post
If you are displaying the value in your -TYPE statement then you haven't matched any of the conditions or your GOTO would have bypassed it. Have you followed j.gross's advice and checked the length? Also it is case sensitive, is your value 'A' or 'a'?


Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
 
Posts: 755 | Location: TX | Registered: September 25, 2007Report This Post
Expert
posted Hide Post
Baillecl,

Keep on writing. I enjoy your posts though I don't always understand them.

At any rate, your GOTO comments are correct. However, in Darin's example his -GOTO is part of the ELSE in an IF statement and as such should be followed by the semicolon.


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
 
Posts: 2723 | Location: Ann Arbor, MI | Registered: April 05, 2006Report This Post
Platinum Member
posted Hide Post
Misunderstood, once more ... Should I love that ? I was not refering to Darin's example, but to the first message by rp.
That's typical of my (too often) being misunderstood. I should have specified that.
But an old Fool / Focusian (*) like me just cannot not know, inside his guts, the difference between -IF and -GOTO syntax
Anyway, thanks for the kindness of the message
Cordially and Focusely
(*) As you prefer. Not mutually exclusive.


Focus Mainframe 7.6.11
Dev Studio 7.6.11 and !!!
PC Focus, Focus for OS/2, FFW Six, MSO
 
Posts: 134 | Registered: November 06, 2007Report This Post
Guru
posted Hide Post
 
-IF 'MAP' EQ 'MAP' THEN GOTO MAP
 - ELSE IF 'MAP' EQ 'DETAIL' THEN GOTO DETAIL
 - ELSE GOTO PERIOD;
 0 ERROR AT OR NEAR LINE     76  IN PROCEDURE ADHOCRQ FOCEXEC *
 (FOC305) SPECIFIED LABEL NOT FOUND: PERIOD
 


I thought this might be spelling error, so I tried the GUI DM to pick up the label; it might be the semi-colon played the trick on me, tried switch the conditions around and still didn't work.

I tried the simple goto and it recognize the label and gave me the report I wanted. So it got to be something wrong with my if-else structure. Please help.

-GOTO PERIOD  <== this one works

-IF '&LEVEL' EQ 'MAP' THEN GOTO MAP
- ELSE IF '&LEVEL' EQ 'DETAIL' THEN GOTO DETAIL
- ELSE GOTO PERIOD; <== this one doesn't work

-IF '&FDIV' NE 'ALL' THEN GOTO PERIOD <== this one doesn't work
- ELSE GOTO &LEVEL; 
  



Thanks,

Hua


Developer Studio 7.6.11
AS400 - V5R4
HTML,PDF,XLS
 
Posts: 305 | Location: Winnipeg,MB | Registered: May 12, 2008Report This Post
Expert
posted Hide Post
Hua, take the quotes off the amper variable. This works:
-IF &LEVEL EQ 'MAP' THEN GOTO MAP
- ELSE IF &LEVEL EQ 'DETAIL' THEN GOTO DETAIL
- ELSE GOTO PERIOD;
-MAP
-TYPE IN MAP
-EXIT
-DETAIL
-TYPE IN DETAIL
-EXIT
-PERIOD
-TYPE IN PERIOD
-EXIT


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
 
Posts: 2723 | Location: Ann Arbor, MI | Registered: April 05, 2006Report This Post
Guru
posted Hide Post
OK, sorry to bother everyone.
The -EXIT tag is missing from -PERIOD block.

-MAP
...
-EXIT
-DETAIL
...
-EXIT
-PERIOD
-EXIT (when I add this line in, everything is OK)

Hua


Developer Studio 7.6.11
AS400 - V5R4
HTML,PDF,XLS
 
Posts: 305 | Location: Winnipeg,MB | Registered: May 12, 2008Report This Post
Guru
posted Hide Post
Thanks Ginny. Appreciated for your quick response.


Developer Studio 7.6.11
AS400 - V5R4
HTML,PDF,XLS
 
Posts: 305 | Location: Winnipeg,MB | Registered: May 12, 2008Report 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     [CLOSED] IF and GOTO problem

Copyright © 1996-2020 Information Builders