230 pts.
 How can I copy a daily generated spool file into an IFS folder adding members for each daily copy using CPYTOIMPF
How can I copy a daily generated spool file into an IFS folder adding members for each daily copy. I try to use CPYTOIMPF but 1). It does not resolve the &file1 variable put on TOSTMF 2. It does not seems to be adding members. Thanks for your response

Software/Hardware used:
ASKED: August 17, 2010  2:23 PM
UPDATED: August 18, 2010  11:55 AM

Answer Wiki:
Hi The following example program may solve: The following program will create a file with the name format "YYYYMMDD_ExReport.CSV" in the folder "home/Ex_Reports/&userprf/" PGM DCL VAR(&USERPRF) TYPE(*CHAR) LEN(10) DCL VAR(&FILENAME) TYPE(*CHAR) LEN(75) DCL VAR(&DATE1) TYPE(*CHAR) LEN(6) DCL VAR(&DATE2) TYPE(*CHAR) LEN(10) DCL VAR(&CURDATE) TYPE(*CHAR) LEN(10) DCL VAR(&DIR1) TYPE(*CHAR) LEN(100) DCL VAR(&DD) TYPE(*CHAR) LEN(2) DCL VAR(&MM) TYPE(*CHAR) LEN(2) DCL VAR(&YYYY) TYPE(*CHAR) LEN(4) DCL VAR(&RPTDAT) TYPE(*CHAR) LEN(10) RTVUSRPRF RTNUSRPRF(&USERPRF) RTVSYSVAL SYSVAL(QDATE) RTNVAR(&DATE1) CVTDAT DATE(&DATE1) TOVAR(&CURDATE) + FROMFMT(*SYSVAL) TOFMT(*ISO) TOSEP(*NONE) CHGVAR VAR(&DATE2) VALUE(&CURDATE) CHGVAR VAR(&DD) VALUE(%SST(&DATE2 9 2)) CHGVAR VAR(&MM) VALUE(%SST(&DATE2 6 2)) CHGVAR VAR(&YYYY) VALUE(%SST(&DATE2 1 4)) CHGVAR VAR(&RPTDAT) VALUE(&YYYY *TCAT &MM *TCAT &DD) CHGVAR VAR(&DIR1) VALUE('/home/Ex_Reports/') CRTDIR DIR(&DIR1) MONMSG MSGID(CPFA0A0) CHGVAR VAR(&DIR1) VALUE(&DIR1 *TCAT '/' *TCAT + &USERPRF) CRTDIR DIR(&DIR1) MONMSG MSGID(CPFA0A0) CHGVAR VAR(&FILENAME) VALUE(&DIR1 *TCAT '/' *TCAT + &RPTDAT *TCAT '_' *TCAT 'ExReport' *TCAT + '.CSV') MONMSG MSGID(CPF2817) CPYTOIMPF FROMFILE(SOURCEFILE) TOSTMF(&FILENAME) + MBROPT(*REPLACE) STMFCODPAG(*PCASCII) + RCDDLM(*CRLF) DTAFMT(*DLM) STRDLM(*NONE) + FLDDLM(',') MONMSG MSGID(CPF2817) CHGAUT OBJ(&FILENAME) USER(&USERPRF) DTAAUT(*RWX) + OBJAUT(*ALL) CHGAUT OBJ(&FILENAME) USER(*PUBLIC) + DTAAUT(*EXCLUDE) OBJAUT(*NONE) ENDPGM The above program will also provide the necessary authority to the created user.
Last Wiki Answer Submitted:  August 18, 2010  11:55 am  by  sudheer794   315 pts.
All Answer Wiki Contributors:  sudheer794   315 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

How can I copy a daily generated spool file into an IFS folder adding members for each daily copy.

IFS directories don’t have members unless you are working in the /QSYS.LIB file system. But if you are copying into /QSYS.LIB, you shouldn’t be using CPYTOIMPF.

Further, you probably shouldn’t be using CPYTOIMPF to copy spooled file data. You use CPYTOIMPF or CPYFRMIMPF when you are doing database exports or imports. If you are just copying spooled file data, use the CPYTOSTMF command.

It does not resolve the &file1 variable put on TOSTMF

Why not? That is, what value did you put into &file1? What does your statement look like? What does the definition of &file1 look like? How did you put the value into &file1?

It does not seems to be adding members.

CPYTOIMPF doesn’t add members unless you are creating database members; but that wouldn’t make any sense. Usually, you would create streamfiles rather than add members.

Tom

 110,115 pts.