Focal Point
[SOLVED] Loop

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

September 29, 2010, 02:06 PM
texgator
[SOLVED] Loop
My Sales files end with the YYYYMM suffix pertaining to the month the sales are for. I need to combine files for all months starting from Jan of last year to the current month. I am trying to do it using the folloiwng loop but I get an error ' A VALUE IS MISSING FOR: &CT2'. Tried providing default value for &CT2 but can't get it to move past the -SET &CT2 line. Any suggestions on fixing this? Thanks.



-SET &ECHO=ALL;

-SET &YEARMONTH=EDIT(&YYMD,'999999');
-SET &WHICHYEAR=EDIT(&YYMD,'9999');
-SET &WHICHLASTYEAR=&WHICHYEAR - 1;
-SET &WHICHLASTYEAR01 = &WHICHLASTYEAR || '01';
-SET &MN=AYM(&WHICHLASTYEAR01, +0,I6YYM);
-SET &CT=0;


TABLE FILE SALES&WHICHLASTYEAR01
PRINT *
ON TABLE HOLD AS HOLDMASTER


-REPEAT ENDLOOP WHILE &MN GT &YEARMONTH
-SET &CT2=&CT + 1;
-SET &MN=AYM(&WHICHLASTYEAR01, +&CT2,I6YYM);

MORE
FILE SALES&MN

-ENDLOOP
END
-EXIT

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


WebFOCUS 7.6.10
Windows
all output (Excel, HTML, PDF)
September 29, 2010, 02:51 PM
GinnyJakes
A couple of things. First off, you never increment &CT1. Do that right before the -ENDLOOP line.

Second, I think your WHILE statement is backwards. &MN is less than &YEARMONTH and the WHILE condition as is will jump to -ENDLOOP because the condition is false to start with. Make the condition LT or LE and I think it will work better.

Lastly, for some odd reason, I had to put a semicolon at the end of the -REPEAT line. Otherwise I get a syntax error. Might be my release (7.6.10) because the doc doesn't show a semi nor do I remember ever having to use one before.

Good luck.


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
September 29, 2010, 03:39 PM
texgator
The main obstable was not using a semicolon at the end of the REPEAT statement. It works now with the semicolon there. Thanks for your help.


WebFOCUS 7.6.10
Windows
all output (Excel, HTML, PDF)
September 30, 2010, 11:36 AM
GinnyJakes
Just for grins, I checked the doc. The doc is wrong in the appslang manual all the way back to 7.6.0. It is fixed in the 7.6.11 version of the manual. The semicolon is only required for the WHILE option of -REPEAT.


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