Focal Point
[SOLVED] MAINTAIN - TYPE ON DDNAME

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

September 21, 2009, 05:22 PM
Dr. Nick
[SOLVED] MAINTAIN - TYPE ON DDNAME
Hi,
Using a Maintain, I'm trying to save selective data from many records to a flat file to be exported to another application. Using a TYPE ON ddname requires a filedef. So I placed the filedef in a fex and "EXEC thefex" from Maintain.

Maintain gives error FOC03799 open for file: ddname : failed.

Another technique would be to collect data in another FOCUS DB, Table and save to flat file. This is the "fall back".

Any ideas?

Thank you,
Nick

This message has been edited. Last edited by: Dr. Nick,


WebFOCUS 7.7.03 & 8.0.7
Windows
HTML, Excel, PDF, etc.
Also, using Maintain, etc.
September 21, 2009, 05:41 PM
Waz
Does thefex run if you run it standalone ?

What is the format of the FILEDEF ?


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

September 21, 2009, 09:01 PM
Dr. Nick
Hi Waz,
Tested the following:
FILEDEF EMAILOP DISK \\xxxxx\cccc\hh\EMAILOP.TXT
and
APP FI EMAILOP DISK \\xxxxx\cccc\hh\EMAILOP.TXT

same results.
Nick


WebFOCUS 7.7.03 & 8.0.7
Windows
HTML, Excel, PDF, etc.
Also, using Maintain, etc.
September 21, 2009, 09:08 PM
Waz
Have you run the FEX without Maintain in the picure ?

This could also be a permissions issue, if its a network share.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

September 22, 2009, 03:56 AM
Alan B
Nick

Running an EXEC will not affect anything in the maintain session you are running; the focexec runs on a different agent and has no knowledge of the calling maintain and cannot affect it.

You should have the filedef in EDASPROF.


Alan.
WF 7.705/8.007
September 22, 2009, 05:55 AM
GamP
Alan is right. The filedef must be done before the maintain starts, otherwise you will not be able to use it. Only on mainframe it is possible to dynamically allocate a resource from within the maintain procedure. On all other platforms you have to do it outside of and before starting the maintain.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
September 22, 2009, 06:50 AM
Alan B
Of course you might get away with something like:
MAINTAIN FILE CAR

DECLARE FIRST_REC/A1;
DECLARE THIS_RECORD/A80;
DECLARE STACK_ROW/I4;
CASE TOP
FOR ALL NEXT COUNTRY CAR INTO CARSTACK;
FIRST_REC= 'Y';
WINFORM SHOW FORM1 
ENDCASE

CASE WRITE_RECORD
THIS_RECORD = CARSTACK(STACK_ROW).COUNTRY | ',' | CARSTACK(STACK_ROW).CAR | ',$' ;  
EXEC WRITE_FEX KEEP FROM FIRST_REC THIS_RECORD;
FIRST_REC= 'N';
ENDCASE
END
with
-* File WRITE_FEX.fex
-SET &APP = IF &1 EQ 'N' THEN '(APPEND' ELSE ' ';
APP FI WFILE CLEAR
APP FI WFILE DISK BASEAPP/WFILE.TXT &APP.EVAL
-RUN
-WRITE WFILE &2

depending on what you are trying to achieve.


Alan.
WF 7.705/8.007
September 22, 2009, 10:04 AM
Maintain Wizard
Nick
As the gentlemen point out, you really have to do the FILEDEF in the EDASPROF. However, if you need to write out a flat file and use it in the same session as the Maintain procedure, use the TEMPPATH command.

Here, case SENDDATA performs a Maintain called WRITER that writes the selected values out to a flatfile called SEL. I have already FILEDEF'D SEL in my EDASPROF. It passes back the TEMPPATH in the variable PTH. I can then perform TABLE1 and pass the path back so I can find the SEL file to use as criteria.

Mark


CASE SENDDATA
COMPUTE PTH/A256;
COMPUTE I/I3=1;
REPEAT OUTSTK.FOCCOUNT
Compute OUTSTK(I).CAT = "'" || OUTSTK(I).CAT ||"'";
Compute I=I+1;
ENDREPEAT
STACK CLEAR HTMLSTK
CALL WRITER FROM OUTSTK INTO PTH
EXEC TABLE1 FROM PTH INTO HTMLSTK
ENDCASE

Note, I added a PTH or Path variable. Now, the child Maintain writes the file, but also knows the path that it wrote to and passes it back.

MAINTAIN FROM OUTSTK INTO PTH
COMPUTE HTMLSTK.HTML/A2000;
COMPUTE outstk.cat/a15;
COMPUTE I/I3=1;
REPEAT outstk.FOCCOUNT
TYPE ON SEL "< COMPUTE I=I+1;
ENDREPEAT
COMPUTE PTH/A256 = TEMPPATH(256,PTH);
END


-SET &Q = &1 || SEL.DAT
FILEDEF SEL DISK &Q
? FILEDEF
-RUN
TABLE FILE MOVIES
PRINT TITLE BY CATEGORY
WHERE CATEGORY IN FILE SEL
ON TABLE PCHOLD FORMAT HTML
END
-RUN