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

240 pts.
Tags:
CPYTOIMPF
IFS file list
Spool files
TOSTMF
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    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
    125,585 pointsBadges:
    report
  • dinuas400
    using CPYTOSPLF give the value for TOSTMF field
    510 pointsBadges:
    report
  • TomLiotta

    using CPYTOSPLF give the value for TOSTMF field

    There is no such system command as "CPYTOSPLF". I assume you mean "CPYTOSTMF".

    However, CPYTOSTMF cannot copy spooled files. Perhaps the simplest method is to use the QShell catsplf utility.

    Tom

    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following