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     Repeat FOR loop does not increment

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Repeat FOR loop does not increment
 Login/Join
 
<awilson>
posted
I have the following code aN IBI consultant left me with to cycle through the different databases we have, however it doesn't work - if we set the FOR loop from 1 to 7, it repeats the first item, DJ5, 7 times. Any ideas?

-REPEAT END_PAYROLL FOR &N FROM 1 TO 7;
-SET &DATASRC = IF &N EQ 1 THEN 'DJ5'
-ELSE IF &N EQ 2 THEN 'AFM5'
-ELSE IF &N EQ 3 THEN 'PRC5'
-ELSE IF &N EQ 4 THEN 'RI5'
-ELSE IF &N EQ 5 THEN 'WF5'
-ELSE IF &N EQ 6 THEN 'DJI5'
-ELSE IF &N EQ 7 THEN 'TW5';
-SET &ENVRNMNT = 'PROD';
-INCLUDE siteprof
-RUN
 
Report This Post
Master
posted Hide Post
TRY THIS

-REPEAT END_PAYROLL FOR &N FROM 1 TO 7;
-SET &DATASRC = IF &N EQ 1 THEN 'DJ5'
-ELSE IF &N EQ 2 THEN 'AFM5'
-ELSE IF &N EQ 3 THEN 'PRC5'
-ELSE IF &N EQ 4 THEN 'RI5'
-ELSE IF &N EQ 5 THEN 'WF5'
-ELSE IF &N EQ 6 THEN 'DJI5'
-ELSE IF &N EQ 7 THEN 'TW5';
-SET &ENVRNMNT = 'PROD';
-TYPE &N &DATASRC
-END_PAYROLL
-RUN
 
Posts: 865 | Registered: May 24, 2004Report This Post
Virtuoso
posted Hide Post
Is &N manipulated in the -INCLUDE file?

What else appears between the pasted code and the closing label of the loop (-END_PAYROLL)?

Does the loop work properly if you change &N to some other variable name?
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
as Tex points out, you don't have any ENDPAYROLL statment label. Look carefully at his code, he puts one in.
and you need to initialize &N.
so at the top of your fex,
-SET &N = 0 ;

i didn't know we could use FOR syntax in loops. how delightfully Fortran. ..so thanx for the post.
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
<awilson>
posted
&N is not manipulated in the -INCLUDE file.

The loop does not work properly if I change &N to a different variable name.

I tried Tex's code and it displays:
1 DJ5
2 AFM5
3 PRC5
4 RI5
5 WF5
6 DJI5
7 TW5

The entire fex file is below showing what else appears between the pasted code and the closing label of the loop:
UNIX rm /home/reportcaster/jamis-dji-ap-total-export-vendor-master-1.txt
-RUN
FILEDEF jamis-dji-ap-total-export-vendor-master-1 DISK /home/reportcaster/jamis-dji-ap-total-export-vendor-master-1.txt (APPEND
-RUN
-REPEAT END_PAYROLL FOR &N FROM 1 TO 7;
-SET &DATASRC = IF &N EQ 1 THEN 'DJ5'
-ELSE IF &N EQ 2 THEN 'AFM5'
-ELSE IF &N EQ 3 THEN 'PRC5'
-ELSE IF &N EQ 4 THEN 'RI5'
-ELSE IF &N EQ 5 THEN 'WF5'
-ELSE IF &N EQ 6 THEN 'DJI5'
-ELSE IF &N EQ 7 THEN 'TW5';
-SET &ENVRNMNT = 'PROD';
-INCLUDE siteprof
-RUN
-*
TABLE FILE AP_VEND
PRINT
COMPUTE D_VEND_NNO/A37 = VEND_NO|'|'|VEND_NAME; AS ''
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SAVE AS jamis-dji-ap-total-export-vendor-master-1 FORMAT ALPHA
END
-RUN
-END_PAYROLL

I also commented out the INCLUDE siteprof and ran the fex and intialized N at the beginning of the fex and it's still cycling through DJ5 seven times.

The output is below - each data source should have a different number of records but it's listing the same number seven times so I know it's not actually going through each data source:
ALPHANUMERIC RECORD NAMED JAMIS-DJ
0 FIELDNAME ALIAS FORMAT LENGTH
D_EMP A57 57
TOTAL 116
1
0 NUMBER OF RECORDS IN TABLE= 6936 LINES= 6936
0
ALPHANUMERIC RECORD NAMED JAMIS-DJ
0 FIELDNAME ALIAS FORMAT LENGTH
D_EMP A57 57
TOTAL 116
1
0 NUMBER OF RECORDS IN TABLE= 6936 LINES= 6936
0
ALPHANUMERIC RECORD NAMED JAMIS-DJ
0 FIELDNAME ALIAS FORMAT LENGTH
D_EMP A57 57
TOTAL 116
1
0 NUMBER OF RECORDS IN TABLE= 6936 LINES= 6936
0
ALPHANUMERIC RECORD NAMED JAMIS-DJ
0 FIELDNAME ALIAS FORMAT LENGTH
D_EMP A57 57
TOTAL 116
1
0 NUMBER OF RECORDS IN TABLE= 6936 LINES= 6936
0
ALPHANUMERIC RECORD NAMED JAMIS-DJ
0 FIELDNAME ALIAS FORMAT LENGTH
D_EMP A57 57
TOTAL 116
1
0 NUMBER OF RECORDS IN TABLE= 6936 LINES= 6936
0
ALPHANUMERIC RECORD NAMED JAMIS-DJ
0 FIELDNAME ALIAS FORMAT LENGTH
D_EMP A57 57
TOTAL 116
1
0 NUMBER OF RECORDS IN TABLE= 6936 LINES= 6936
0
ALPHANUMERIC RECORD NAMED JAMIS-DJ
0 FIELDNAME ALIAS FORMAT LENGTH
D_EMP A57 57
TOTAL 116
1
0 NUMBER OF RECORDS IN TABLE= 6936 LINES= 6936
0
 
Report This Post
Virtuoso
posted Hide Post
[revised]

Apparently sitepref.fex is responsible for pointing AP_VEND to an appropriate datastore corresponding to &DATASRC. That's where I'd look next: Is "&DATASRC" the way it's spelled in siteprof, and is siteprof trouncing it.

Try this:

-SET &ECHO=ON;
UNIX rm /home/reportcaster/jamis-dji-ap-total-export-vendor-master-1.txt
-RUN
FILEDEF jamis-dji-ap-total-export-vendor-master-1 DISK /home/reportcaster/jamis-dji-ap-total-export-vendor-master-1.txt (APPEND
-RUN
-REPEAT END_PAYROLL FOR &N FROM 1 TO 7;
-SET &DATASRC = IF &N EQ 1 THEN 'DJ5'
-ELSE IF &N EQ 2 THEN 'AFM5'
-ELSE IF &N EQ 3 THEN 'PRC5'
-ELSE IF &N EQ 4 THEN 'RI5'
-ELSE IF &N EQ 5 THEN 'WF5'
-ELSE IF &N EQ 6 THEN 'DJI5'
-ELSE IF &N EQ 7 THEN 'TW5';
-SET &ENVRNMNT = 'PROD';
-TYPE @ BEFORE siteprof: n=&N, datasrc=&DATASRC
-INCLUDE siteprof
-RUN
-TYPE @ AFTER siteprof: n=&N, datasrc=&DATASRC
TABLE FILE AP_VEND
PRINT
COMPUTE D_VEND_NNO/A37 = VEND_NO|'|'|VEND_NAME; AS ''
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SAVE AS jamis-dji-ap-total-export-vendor-master-1 FORMAT ALPHA
END
-RUN
-TYPE @ AFTER report: n=&N, datasrc=&DATASRC
-END_PAYROLL
and post the messages.

This message has been edited. Last edited by: <Mabel>,
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
<awilson>
posted
Looking at SITEPROF, it was doing an APP APPENDPATH but needed to do an APP PATH first which wasn't listed. Thanks for pointing me in the right direction.
 
Report 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     Repeat FOR loop does not increment

Copyright © 1996-2020 Information Builders