Focal Point
[SOLVED] Help with filedef append

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

July 16, 2009, 03:57 PM
jjoyce
[SOLVED] Help with filedef append
I have an include file someone else wrote that I'm trying to modify so that I can call it multiple times from within the same program. Its using a filedef append and my problem is that the second pass seems to sum the numbers with the first pass. So in otherwords, I set &BDGT_HOLD = TABLE1, include the file, and my budget on TABLE1 is 150. Then I set &BDGT_HOLD = TABLE2, include the file and my budget on TABLE2 should be 100, but instead I get 250.

I assume the second pass is appended to the first pass in BDGT_HLDX.FTM, and I would think I need to close or destroy the original file in some way, but I don't know how.

The include file looks something like this (I ommitted a few things):
FILEDEF BDGT_HLDX DISK BDGT_HLDX.FTM (APPEND
-SET &LOOP_CNT=0;
-REPEAT MONBDGT 12 TIMES;
-SET &LOOP_CNT = &LOOP_CNT + 1;
-SET &SAVEHOLD = IF &LOOP_CNT LE 11 THEN 'SAVE' ELSE 'HOLD';
DEFINE FILE BDGT_HOLDX
  .... END
TABLE FILE BDGT_HOLDX
SUM
    BUDGET
BY FMN
ON TABLE &SAVEHOLD AS BDGT_HLDX FORMAT ALPHA
END
-RUN
-*...put budget numbers into an XFOCUS file...
TABLE FILE BDGT_HLDX
SUM
    BUDGET
BY FMN
ON TABLE HOLD AS &BDGT_HOLD FORMAT XFOCUS INDEX FMN  

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


WebFOCUS 7.7.2
Win2003
Excel, HTML, PDF
July 16, 2009, 04:32 PM
GinnyJakes
The easy answer is to take the (APPEND off of the filedef. What happens if you do that?


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
July 16, 2009, 04:43 PM
jjoyce
Its appending to the file each time it loops. If I remove the append, then I only have 1 line in the file when I should have 12. So essentially I want it to loop 12 times, append a line each time. Clear the File. Loop 12 more and append 12 new lines.


WebFOCUS 7.7.2
Win2003
Excel, HTML, PDF
July 16, 2009, 05:20 PM
Mighty Max
Sounds like you have two loops but I only see one.
Anyways you can use DOS commands in Webfocus.
So you can do a DOS delete when you need to clear the file.

DOS DEL \\WF_SERVER\IBI\APPS\APP_FOLDER\BDGT_HLDX.FTM


WebFOCUS 8.1.05M Unix Self-Service/MRE/Report Caster - Outputs Excel, PDF, HTML, Flat Files
July 16, 2009, 06:01 PM
susannah
-*SET &ECHO = ALL ;
FILEDEF MYFILE DISK MYFILE.TXT(   LRECL 5

-RUN
 
-SET &KOUNTER = 0 ;
-REPEAT BOTTOMLOOP 2 TIMES
-SET &KOUNTER = &KOUNTER + 1;
-SET &NAME = DECODE &KOUNTER( 1 'FRED' 2 'ETHEL' 3 'LUCY' 4 'RICKY');
FILEDEF MYFILE CLEAR
FILEDEF MYFILE DISK MYFILE.TXT(  APPEND   LRECL 5
-RUN
-WRITE MYFILE &NAME  
 
-BOTTOMLOOP
-CLOSE MYFILE
-TYPE READING FIRST FILE
-READ MYFILE NOCLOSE &NAME.A5
-IF &IORETURN NE 0 GOTO eoj ;
-TYPE &NAME &IORETURN

-READ MYFILE NOCLOSE &NAME.A5
-IF &IORETURN NE 0 GOTO eoj ;
-TYPE &NAME &IORETURN
-READ MYFILE NOCLOSE &NAME.A5
-IF &IORETURN NE 0 GOTO eoj ;
-TYPE &NAME &IORETURN
-READ MYFILE NOCLOSE &NAME.A5
-IF &IORETURN NE 0 GOTO eoj ;
-TYPE &NAME &IORETURN
-eoj
-RUN
-TYPE READING 2ND ONE 
-*CLOSE MYFILE
-*FILEDEF MYFILE CLEAR
FILEDEF MYFILE DISK MYFILE.TXT( LRECL 5
 
-RUN
-SET &KOUNTER = 2 ;
-REPEAT BOTTOMLOOP2 2 TIMES
-SET &KOUNTER = &KOUNTER + 1;
-SET &NAME = DECODE &KOUNTER( 1 'FRED' 2 'ETHEL' 3 'LUCY' 4 'RICKY');
-WRITE MYFILE &NAME  
FILEDEF MYFILE DISK MYFILE.TXT(  APPEND LRECL 5
-RUN
-BOTTOMLOOP2
 
-CLOSE MYFILE
-RUN





In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
July 16, 2009, 06:05 PM
susannah
there appears to me to have been some code tightening...
As Ginny says, You may be able to get away with removing the APPEND altogether.
but if you're re-executing the fex within the same fex/agent, this will work
FILEDEF thing DISK thing
FILEDEF thing DISK thing(APPEND
seems to clear the existing filedef, and start over.
FILEDEF thing CLEAR didn't seem to do anything.
-CLOSE thing didn't seem to do anything either.
hmm.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
July 16, 2009, 09:43 PM
j.gross
Issue the filedef within the LOOP, just before the TABLE request -- omitting "(APPEND" in iteration 1, including it in 2 through 12.


- Jack Gross
WF through 8.1.05
July 17, 2009, 08:34 AM
jjoyce
Thanks Jack! that worked perfectly!


WebFOCUS 7.7.2
Win2003
Excel, HTML, PDF