Focal Point
[CLOSED] Problem with USE command when using in repeat loops

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

March 19, 2014, 12:45 PM
koti
[CLOSED] Problem with USE command when using in repeat loops
Hi,

I have procedure with 10 systems and 3 regions, each system creates one hold file. These 10 hold files are combined by using USE command. Now repeating the same procedure by passing region value to separate the report region wise. First hold file creating correctly and when creating for region2 hold file it is appending the region1 records also. When I pass region3 the file comes with all three regions data.
I used USE CLEAR * but not clearing. I want clear for each loop and it should be like first time run

Example:

-SET &ECHO = 'ALL';
-SET &RGN = 'A1';
-SET &FINLFILE = 'FILEA';
-GOTO STRTPRG;
-B1
-SET &RGN = 'B1';
-SET &FINLFILE = 'FILEB';
-GOTO STRTPRG;
-C1
-SET &RGN = 'C1';
-SET &FINLFILE = 'FILEC';
-STRTPRG
-IF &RGN NE 'A1' THEN GOTO SKIPA1;
TABLE FILE CAR
PRINT CAR COUNTRY RETAIL_COST
WHERE COUNTRY EQ 'ENGLAND';
ON TABLE HOLD AS HOLD1 FORMAT FOCUS
END
-RUN
-*-*
-SKIPA1
-IF &RGN NE 'B1' THEN GOTO SKIPB1;
TABLE FILE CAR
PRINT CAR COUNTRY RETAIL_COST
WHERE COUNTRY EQ 'JAPAN';
ON TABLE HOLD AS HOLD2 FORMAT FOCUS
END
-RUN
-SKIPB1
-*
-IF &RGN NE 'C1' THEN GOTO SKIPC1;
TABLE FILE CAR
PRINT CAR COUNTRY RETAIL_COST
WHERE COUNTRY EQ 'ITALY';
ON TABLE HOLD AS HOLD3 FORMAT FOCUS
END
-RUN
TABLE FILE CAR
PRINT CAR COUNTRY RETAIL_COST
WHERE COUNTRY EQ 'FRANCE';
ON TABLE HOLD AS HOLD4 FORMAT FOCUS
END
-RUN
-SKIPC1
USE CLEAR *
USE
HOLD1 AS HOLD1
HOLD2 AS HOLD1
HOLD3 AS HOLD1
HOLD4 AS HOLD1
END
-RUN
APP HOLD acctpay
-RUN
TABLE FILE HOLD1
PRINT *
ON TABLE HOLD AS &FINLFILE FORMAT FOCUS
END
-RUN
-IF &FINLFILE EQ 'FILEA' THEN GOTO B1 ELSE IF &FINLFILE EQ 'FILEB' THEN GOTO C1 ELSE GOTO EXTPRG;
-EXTPRG
-EXIT

Thanks,Koti
WF7703, Windows 7

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


WebFOCUS 8104/7703/769/764, Windows 7, Oracle 11g, DB2, QAD
March 19, 2014, 12:52 PM
Francis Mariani
This sample fex does not run all the way through - I get an error because HOLD2-HOLD4 do not exist.


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
March 19, 2014, 12:57 PM
Francis Mariani
The problem might be in the APP HOLD command. The FOCUS databases are physically created in app folder acctpay, so they will be there if you loop through the fex several times. Though it might also be possible that they'll repeatedly be read even if they're not in the app folder. Perhaps you need to append the region to the database name when creating/reading the databases.


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
March 19, 2014, 01:22 PM
Tony A
To use your code as a base, you just need a little judicial use of Dialog Manager magic -

-SET &ECHO = 'ALL';
-DEFAULTH &Hold1 = '', &Hold2 = '', &Hold3 = '', &Hold4 = ''
-SET &RGN = 'A1';
-SET &FINLFILE = 'FILEA';
-GOTO STRTPRG;
-B1
-SET &RGN = 'B1';
-SET &FINLFILE = 'FILEB';
-GOTO STRTPRG;
-C1
-SET &RGN = 'C1';
-SET &FINLFILE = 'FILEC';
-STRTPRG
-IF &RGN NE 'A1' THEN GOTO SKIPA1;
TABLE FILE CAR
PRINT CAR COUNTRY RETAIL_COST
WHERE COUNTRY EQ 'ENGLAND';
ON TABLE HOLD AS HOLD1 FORMAT FOCUS
END
-RUN
-SET &Hold1 = IF &LINES EQ 0 THEN '' ELSE 'HOLD1 AS HOLD1';
-*
-SKIPA1
-*
-IF &RGN NE 'B1' THEN GOTO SKIPB1;
TABLE FILE CAR
PRINT CAR COUNTRY RETAIL_COST
WHERE COUNTRY EQ 'JAPAN';
ON TABLE HOLD AS HOLD2 FORMAT FOCUS
END
-RUN
-SET &Hold2 = IF &LINES EQ 0 THEN '' ELSE 'HOLD2 AS HOLD1';
-*
-SKIPB1
-*
-IF &RGN NE 'C1' THEN GOTO SKIPC1;
TABLE FILE CAR
PRINT CAR COUNTRY RETAIL_COST
WHERE COUNTRY EQ 'ITALY';
ON TABLE HOLD AS HOLD3 FORMAT FOCUS
END
-RUN
-SET &Hold3 = IF &LINES EQ 0 THEN '' ELSE 'HOLD3 AS HOLD1';
-*
TABLE FILE CAR
PRINT CAR COUNTRY RETAIL_COST
WHERE COUNTRY EQ 'FRANCE';
ON TABLE HOLD AS HOLD4 FORMAT FOCUS
END
-RUN
-SET &Hold4 = IF &LINES EQ 0 THEN '' ELSE 'HOLD4 AS HOLD1';
-*
-SKIPC1
USE CLEAR *
USE
&Hold1.EVAL
&Hold2.EVAL
&Hold3.EVAL
&Hold4.EVAL
END
-RUN
-*APP HOLD acctpay
-RUN
TABLE FILE HOLD1
PRINT *
ON TABLE HOLD AS &FINLFILE FORMAT FOCUS
END
-RUN
-IF &FINLFILE EQ 'FILEA' THEN GOTO B1 ELSE IF &FINLFILE EQ 'FILEB' THEN GOTO C1 ELSE GOTO EXTPRG;
-EXTPRG
-EXIT

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 
March 20, 2014, 11:28 AM
koti
Hi Tony,

Thanks for the information. I have implemented logic by using Dialog manager commands.

Thanks,
Koti


WebFOCUS 8104/7703/769/764, Windows 7, Oracle 11g, DB2, QAD
March 20, 2014, 12:45 PM
Tony A
Koti,

You're welcome.

Incidentally, I would be inclined to use the following syntax at the end of your sample code as it would ensure that the only items written to your target application folder are the .MAS and .FOC files that you want.
-*APP HOLD acctpay
-RUN
TABLE FILE HOLD1
PRINT *
ON TABLE HOLD AS acctpay/&FINLFILE FORMAT FOCUS
END
-RUN
-IF &FINLFILE EQ 'FILEA' THEN GOTO B1 ELSE IF &FINLFILE EQ 'FILEB' THEN GOTO C1 ELSE GOTO EXTPRG;
-EXTPRG
-EXIT

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