AS/400 Code Samples - AS/400 - CPYSPLSTMF - Copy Spool File to a Stream File (IFS) Author: George Pearson Company: Green Springs Software, Inc. www.green-springs.com Purpose: Utility to copy any iSeries spool file to a text file on the IFS Components: CPYSPLSTMF Command CPYSPLSTMF CLP Parameters: SPLFNAME Spool File Name JOBAMM The 3 component iSeries Job Name and Number SPLFNBR Spool File Number: 0001-9999, *Last, *Only REPORT Name you want to call the PC Text File. This will be suffixed by ".txt". You can use long Windows file names. STMF The IFS File Path you want the report placed STMFOPT *ADD, *REPLACE or *NONE. To add to, or replace any existing file by this name. Written: 2003 //*ã************************************************************************/ /* */ /* ¹ Green Springs Software, Inc. Ashland, OR */ /* */ /*ã*************************************************************************/ /* */ /*¹ Command - CPYSPLSTMF */ /*¹ CPP - CPYSPLSTMF */ /*¹ Description - Copy an iSeries Spool File to an IFS Folder. */ /*¹ Creation - 02/27/2003 */ /*¹ Programmer - George Pearson */ /*¹ */ /*¹ Comments - Copies an ISeries Spool file into an IFS Folder. */ /*¹ Executes CP Program CPYSPLSTMF. */ /*¹ */ /*¹ NOTES - No Error checking here. If the IFS folder or spool */ /*¹ file do not exist, this program will choke. */ /*¹ */ /*¹ PARMS - SPLFNAME - Spool File Name. Required and must exist */ /*¹ - JOBALL - Qualified Job Name, or "*" for current Job */ /*¹ - SPLFNBR - Spool File Number (0001-9999; *LAST, *ONLY) */ /*¹ - REPORT - Supply a name that you want the report file */ /*¹ to be known as on the IFS Folder. Use up to */ /*¹ 50 characters including spaces, but DON'T */ /*¹ use a "/" (as in AS/400). It doesn't like. */ /*¹ */ /*¹ - STMF - The IFS File Path you want the report placed.*/ /*¹ - STMFOPT - *ADD, *REPLACE or *NONE. See Helptext for */ /*¹ IBM's Command CPYTOSTMF for explanation. */ /*ã*************************************************************************/ /*¹ --Date-- Who Scan For --------- C O M M E N T S ----------------------*/ /*¹ 2/27/03 G Pearson New Command */ /*¹ */ /*¹------------------------------------------------------------------------*/ /* */ CMD PROMPT('Copy Spool File to IFS Folder') PARM KWD(SPLFNAME) TYPE(*NAME) LEN(10) + PROMPT('Spool File Name') MIN(1) PARM KWD(JOB) TYPE(QUAL1) SNGVAL(*) DFT(*) + PROMPT('Job name') PARM KWD(SPLNBR) TYPE(*CHAR) LEN(6) DFT(*LAST) + RANGE(0001 9999) SPCVAL(*ONLY *LAST) + PROMPT('Spool file number') PARM KWD(REPORT) TYPE(*CHAR) LEN(50) DFT('iSeries + Report') PROMPT('Report Name') PARM KWD(STMF) TYPE(*CHAR) LEN(50) + DFT('s2kjdeconv/Conversion Reports/') + PROMPT('Stream File Location') PARM KWD(STMFOPT) TYPE(*CHAR) LEN(08) RSTD(*YES) + DFT(*REPLACE) VALUES(*REPLACE *ADD *NONE) + PROMPT('Stream File Option') QUAL1: QUAL TYPE(*NAME) LEN(10) MIN(1) EXPR(*YES) QUAL TYPE(*NAME) LEN(10) MIN(0) EXPR(*YES) + PROMPT('User name') QUAL TYPE(*CHAR) LEN(6) MIN(0) FULL(*YES) + RANGE(000000 999999) + PROMPT('Job number') /*ã***** End Of Command CPYSPLSTMF ******************************************/ /*ã*************************************************************************/ /* */ /* ¹ Green Springs Software, Inc. Ashland, OR */ /* */ /*ã*************************************************************************/ /* */ /* PROGRAM ID - CPYSPLSTMF */ /* DISPLAY FILE NAME - *None */ /* CREATED BY - George Pearson, Green Springs Software, Inc. */ /* DATE CREATED - 2/27/03 */ /* */ /* PURPOSE - Copies an iSeries Spool File into an IFS Folder. */ /* Executed by command CPYSPLSTMF. */ /* */ /* NOTES - No Error checking here. If the file, folder or spool */ /* file does not exist, this program will choke. */ /* */ /* PARMS - SPLFNAME - Spool File Name. Required, and must exist */ /* - JOBALL - Qualified Job Name, or "*" for current Job */ /* - SPLFNBR - Spool File Number (0001-9999; *LAST, *ONLY) */ /* - REPORT - Supply a name that you want the report file */ /* to be known as on the IFS Folder. Use up to */ /* 50 characters including spaces, but DON'T */ /* use a "/" (as in AS/400). It doesn't like. */ /* - STMF - The IFS File Path you want the report placed */ /* - STMFOPT - *ADD, *REPLACE or *NONE. See Helptext for */ /* IBM's Command CPYTOSTMF for explanation. */ /* */ /* (c) MMIII Green Springs Software Inc. */ /* PO Box 3336, Ashland, OR 97520 */ /* (541) 488-2560 www.green-springs.com */ /* */ /*ã*************************************************************************/ /*¹ --Date-- Who Scan For --------- C O M M E N T S ----------------------*/ /*¹ */ /*¹------------------------------------------------------------------------*/ /*¹ 2/27/03 G Pearson New CL Program */ /*¹ 3/28/03 G Pearson Added Change Authority to allows others to */ /* replace the file on the IFS */ /*ã*************************************************************************/ PGM PARM(&SPLFNAME &JOBALL &SPLFNBR &REPORT + &STMF &STMFOPT) DCL &CVTDTA *Char Len(05) Value(*None) DCL &ENDLINFMT *Char Len(50) Value(*CRLF) DCL &FROMMBR *Char Len(50) DCL &JOB *Char Len(10) DCL &JOBALL *Char Len(26) DCL &JOBNBR *Char Len(06) DCL &REPORT *Char Len(50) DCL &SPLFNAME *Char Len(10) DCL &SPLFNBR *Char Len(06) DCL &STMF *Char Len(50) DCL &STMFOPT *Char Len(08) DCL &TOSTMF *Char Len(70) DCL &USER *Char Len(10) /* éExtract the Job Elements */ /* ¹------------------------ */ CHGVAR VAR(&JOB) VALUE(%SST(&JOBALL 1 10)) CHGVAR VAR(&USER) VALUE(%SST(&JOBALL 11 10)) CHGVAR VAR(&JOBNBR) VALUE(%SST(&JOBALL 21 6)) /* éCreate a Temp File to Copy Spool File Into */ /* ¹------------------------------------------- */ DLTF FILE(QTEMP/SPOOLTEMP) MONMSG MSGID(CPF0000) CRTPF FILE(QTEMP/SPOOLTEMP) RCDLEN(250) + SIZE(1000000 32000 100) /* éCopy the report into the Temp File */ /* ¹---------------------------------- */ CPYSPLF FILE(&SPLFNAME) TOFILE(QTEMP/SPOOLTEMP) + SPLNBR(&SPLFNBR) /* éBuild the Output File Name */ /* ¹-------------------------- */ CHGVAR VAR(&TOSTMF) VALUE(&STMF *TCAT &REPORT *TCAT + '.txt') /********* CHGVAR VAR(&TOSTMF) VALUE('s2kjdeconv/Conversion + Reports/' *CAT &REPORT *TCAT '.txt') ***/ /* éClear the Output file */ /* ¹--------------------- */ CHGVAR VAR(&FROMMBR) + VALUE('/qsys.lib/qtemp.lib/spooltemp.file/s+ pooltemp.mbr') CPYTOSTMF FROMMBR(&FROMMBR) TOSTMF(&TOSTMF) + STMFOPT(&STMFOPT) CVTDTA(&CVTDTA) + ENDLINFMT(&ENDLINFMT) /* éNow lets make sure that others can replace this, if needed. */ /* ¹----------------------------------------------------------- */ CHGAUT OBJ(&TOSTMF) USER(*PUBLIC) DTAAUT(*RWX) + OBJAUT(*ALL) ENDPGM: ENDPGM /*ã***** End Of CL Program CPYSPLSTMF ******************************************/