如何針移動整個 outq 的報表至另一個outq ?(Command PRCSLTSPLF)
工具: PRCSLTSPLF(Process selected spool files)
此工具整合 MOVSPLF, HLDSPLF, DLTSPLF, RLSSPLF
The Process Selected Spool Files Utility
下載 Source code
/*==================================================================*/
/* Process a group of spool files */
/*==================================================================*/
/* To compile: */
/* */
/* CRTCMD CMD(XXX/PRCSLTSPLF) PGM(XXX/SPL001CL) + */
/* SRCFILE(XXX/QCMDSRC) */
/* */
/*==================================================================*/
CMD PROMPT('Process selected spool files')
PARM KWD(FROMOUTQ) TYPE(Q1) PROMPT('From output +
queue')
Q1: QUAL TYPE(*NAME) LEN(10) MIN(1) EXPR(*YES)
QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) +
SPCVAL((*LIBL) (*CURLIB)) EXPR(*YES) +
PROMPT('Library')
PARM KWD(ACTION) TYPE(*CHAR) LEN(3) RSTD(*YES) +
DFT(MOV) VALUES(DLT HLD MOV RLS) +
EXPR(*YES) PROMPT('Action')
PARM KWD(FILE) TYPE(*NAME) LEN(10) DFT(*ALL) +
SPCVAL((*ALL)) EXPR(*YES) PROMPT('File name')
PARM KWD(FORMTYPE) TYPE(*NAME) LEN(10) DFT(*ALL) +
SPCVAL((*ALL) (*STD)) EXPR(*YES) +
PROMPT('Form type')
PARM KWD(USERDATA) TYPE(*NAME) LEN(10) DFT(*ALL) +
SPCVAL((*ALL)) EXPR(*YES) PROMPT('User data')
PARM KWD(USERID) TYPE(*NAME) LEN(10) DFT(*ALL) +
SPCVAL((*ALL)) EXPR(*YES) PROMPT('User +
profile')
PARM KWD(DATE) TYPE(*DATE) DFT(*ALL) SPCVAL((*ALL +
010140)) PROMPT('Creation date')
PARM KWD(TOOUTQ) TYPE(Q1) PMTCTL(OUTQ2) +
PROMPT('To output queue')
OUTQ2: PMTCTL CTL(ACTION) COND((*EQ MOV))
/*==================================================================*/
/* CPP for PRCSLTSPLF command */
/*==================================================================*/
/* To compile: */
/* */
/* CRTCLPGM PGM(XXX/SPL001CL) SRCFILE(XXX/QCLSRC) */
/* */
/*==================================================================*/
PGM PARM(&FROMOUTQ &ACTION &SELFILE &SELFORM +
&SELUSRDTA &SELUSER &SELDATE &TOOUTQ)
DCL &ACOUNT *CHAR 5
DCL &ACTION *CHAR 3
DCL &COUNT *DEC 5
DCL &DONE *CHAR 10
DCL &ERROR *LGL VALUE('0')
DCL &ERRBYTES *CHAR 4 VALUE(X'00000000')
DCL &ERRORDATA *CHAR 80
DCL &ERRORID *CHAR 7
DCL &FROMOUTQ *CHAR 20
DCL &FROMOUTQLI *CHAR 10
DCL &FROMOUTQNA *CHAR 10
DCL &MSGKEY *CHAR 4
DCL &MSGTYP *CHAR 10 VALUE('*DIAG')
DCL &MSGTYPCTR *CHAR 4 VALUE(X'00000001')
DCL &PGMMSGQ *CHAR 10 VALUE('*')
DCL &SELDATE *CHAR 7
DCL &SELFILE *CHAR 10
DCL &SELFORM *CHAR 10
DCL &SELUSER *CHAR 10
DCL &SELUSRDTA *CHAR 10
DCL &SPLFDATE *CHAR 7
DCL &SPLFFILE *CHAR 10
DCL &SPLFJOBNAM *CHAR 10
DCL &SPLFJOBNBR *CHAR 6
DCL &SPLFJOBUSR *CHAR 10
DCL &SPLFNBR *CHAR 6
DCL &STKCTR *CHAR 4 VALUE(X'00000001')
DCL &TOOUTQ *CHAR 20
DCL &TOOUTQLIB *CHAR 10
DCL &TOOUTQNAME *CHAR 10
MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERRPROC))
CHGVAR VAR(&FROMOUTQNA) VALUE(&FROMOUTQ)
CHGVAR VAR(&FROMOUTQLI) VALUE(%SST(&FROMOUTQ 11 10))
CHKOBJ OBJ(&FROMOUTQLI/&FROMOUTQNA) OBJTYPE(*OUTQ)
IF COND(&ACTION *EQ MOV) THEN(DO)
CHGVAR VAR(&TOOUTQNAME) VALUE(&TOOUTQ)
CHGVAR VAR(&TOOUTQLIB) VALUE(%SST(&TOOUTQ 11 10))
CHKOBJ OBJ(&TOOUTQLIB/&TOOUTQNAME) OBJTYPE(*OUTQ)
ENDDO
GETENTRY:
CALL PGM(SPL001RG) PARM(&FROMOUTQ &SELFORM +
&SELUSRDTA &SELUSER &SELDATE &SELFILE +
&SPLFFILE &SPLFJOBNBR &SPLFJOBUSR +
&SPLFJOBNAM &SPLFNBR &SPLFDATE &ERRORID &ERRORDATA)
IF COND(&ERRORID *NE ' ') THEN(DO)
SNDPGMMSG MSGID(&ERRORID) MSGF(QCPFMSG) +
MSGDTA(&ERRORDATA) MSGTYPE(*ESCAPE)
ENDDO
IF COND(&SPLFFILE *EQ '**********') THEN(GOTO +
CMDLBL(ENDENTRY))
IF COND(&ACTION *EQ MOV) THEN(DO)
CHGSPLFA FILE(&SPLFFILE) +
JOB(&SPLFJOBNBR/&SPLFJOBUSR/&SPLFJOBNAM) +
SPLNBR(&SPLFNBR) OUTQ(&TOOUTQLIB/&TOOUTQNAME)
CHGVAR VAR(&COUNT) VALUE(&COUNT + 1)
CHGVAR VAR(&DONE) VALUE('moved')
ENDDO
ELSE CMD(IF COND(&ACTION *EQ DLT) THEN(DO))
DLTSPLF FILE(&SPLFFILE) +
JOB(&SPLFJOBNBR/&SPLFJOBUSR/&SPLFJOBNAM) +
SPLNBR(&SPLFNBR)
CHGVAR VAR(&COUNT) VALUE(&COUNT + 1)
CHGVAR VAR(&DONE) VALUE('deleted')
ENDDO
ELSE CMD(IF COND(&ACTION *EQ HLD) THEN(DO))
HLDSPLF FILE(&SPLFFILE) +
JOB(&SPLFJOBNBR/&SPLFJOBUSR/&SPLFJOBNAM) +
SPLNBR(&SPLFNBR)
CHGVAR VAR(&COUNT) VALUE(&COUNT + 1)
CHGVAR VAR(&DONE) VALUE('held')
ENDDO
ELSE CMD(IF COND(&ACTION *EQ RLS) THEN(DO))
RLSSPLF FILE(&SPLFFILE) +
JOB(&SPLFJOBNBR/&SPLFJOBUSR/&SPLFJOBNAM) +
SPLNBR(&SPLFNBR)
CHGVAR VAR(&COUNT) VALUE(&COUNT + 1)
CHGVAR VAR(&DONE) VALUE('released')
ENDDO
GOTO CMDLBL(GETENTRY)
ENDENTRY:
IF COND(&COUNT *EQ 0) THEN(DO)
CHGVAR VAR(&ACOUNT) VALUE('0')
ENDDO
ELSE CMD(DO)
CHGVAR VAR(&ACOUNT) VALUE(&COUNT)
RADJ:
IF COND(%SST(&ACOUNT 1 1) *EQ '0') THEN(DO)
CHGVAR VAR(&ACOUNT) VALUE(%SST(&ACOUNT 2 4))
GOTO CMDLBL(RADJ)
ENDDO
ENDDO
SNDPGMMSG MSGID(CPF9897) MSGF(QCPFMSG) MSGDTA('Spool +
files' *BCAT &DONE *TCAT ':' *BCAT +
&ACOUNT) MSGTYPE(*COMP)
RETURN
/*==================================================================*/
/* Error processing routine */
/*==================================================================*/
ERRPROC:
IF COND(&ERROR) THEN(GOTO CMDLBL(ERRDONE))
ELSE CMD(CHGVAR VAR(&ERROR) VALUE('1'))
/* Move all *DIAG messages to previous program queue */
CALL PGM(QMHMOVPM) PARM(&MSGKEY &MSGTYP +
&MSGTYPCTR &PGMMSGQ &STKCTR &ERRBYTES)
/* Resend last *ESCAPE message */
ERRDONE:
CALL PGM(QMHRSNEM) PARM(&MSGKEY &ERRBYTES)
MONMSG MSGID(CPF0000) EXEC(DO)
SNDPGMMSG MSGID(CPF3CF2) MSGF(QCPFMSG) +
MSGDTA('QMHRSNEM') MSGTYPE(*ESCAPE)
MONMSG MSGID(CPF0000)
ENDDO
ENDPGM
*===============================================================
* Return information about a spool file. Used by PRCSLTSPLF.
*===============================================================
* To compile:
* CRTRPGPGM PGM(XXX/SPL001RG) SRCFILE(XXX/QRPGSRC)
*
*===============================================================
* API error data structure
IAPIERR DS
I B 1 40ERRPRV
I B 5 80ERRAVL
I 9 15 ERRID
I 17 96 ERRPDT
* API general header
IAPIHDR DS
I B 125 1280GUSOFF
I B 133 1360GUSNBE
I B 137 1400GUSLEN
* Spool file header data, SPLF0200 format
ISPLHDR DS
I 1 10 SPHUSR
I 11 20 SPHOTQ
I 21 30 SPHOQL
I 31 40 SPHFRM
I 41 50 SPHUDT
I B 83 860SPHNKY
I 87 102 SPHNU1
I 103 112 SPHNAM
* Spool file header data for fields
ISPLHD2 DS
I 21 30 SPANAM
I 49 58 SPAJOB
I 77 86 SPAUSR
I 105 110 SPAJBN
I B 129 1320SPANUM
I 149 155 SPDATE
* Data structure to define binary variables
I DS
I B 1 40SPLKEY
I B 5 80GUSSPO
I B 9 120GUSHLN
I B 13 160SPSIZE
I B 17 200SPALRV
* Binary DS for QUSLSPL list of keys
I DS
I 1 24 SPLK
I B 1 40SPLK1
I B 5 80SPLK2
I B 9 120SPLK3
I B 13 160SPLK4
I B 17 200SPLK5
I B 21 240SPLK6
*
I '#SPLFWORK#QTEMP 'C USRSPN
C *ENTRY PLIST
C PARM I#OUTQ 20 output queue
C PARM I#FORM 10 form
C PARM I#USRD 10 user data
C PARM I#USNM 10 user name
C PARM I#DATE 7 creation date
C PARM I#FILE 10 file name
C PARM O#FILE 10 file name
C PARM O#JBNR 6 job number
C PARM O#JBUS 10 user profile
C PARM O#JBNM 10 job name
C PARM O#SPNR 6 spool file nbr
C PARM O#SPDT 7 creation date
C PARM O#ERID 7 Error msg ID
C PARM O#ERDT 80 Error msg data
*
* Process next spool file entry
*
C SELECT DOUEQ'1'
C MOVE '1' SELECT 1
C ADD 1 ENTRCT 90
C ENTRCT IFLE GUSNBE
* Get the attributes of the spooled file
C CALL 'QUSRTVUS'
C PARM SPACNM
C PARM GUSSPO
C PARM GUSLEN
C PARM SPLHD2
C PARM APIERR
C EXSR CHKERR
C I#DATE IFNE '0400101'
C I#DATE ANDNESPDATE
C MOVE '0' SELECT
C ENDIF
C I#FILE IFNE '*ALL'
C I#FILE ANDNESPANAM
C MOVE '0' SELECT
C ENDIF
C SELECT IFEQ '1'
C MOVELSPANAM O#FILE file name
C MOVELSPAJOB O#JBNM job name
C MOVELSPAUSR O#JBUS user ID
C MOVE SPAJBN O#JBNR job number
C MOVE SPDATE O#SPDT creation date
C MOVE SPANUM O#SPNR file number
C ENDIF
C ADD GUSLEN GUSSPO goto next entry
C ELSE
C MOVE *ALL'*' O#FILE
C MOVE *ON *INLR
C ENDIF
C ENDDO
*
C RETRN
* =========================================================
C *INZSR BEGSR
*
C MOVE *BLANKS O#ERID
* Create the user space
C CALL 'QUSCRTUS'
C PARM USRSPN SPACNM 20
C PARM SPATTR 10
C PARM 8192 SPSIZE
C PARM X'00' SPIVAL 1
C PARM '*CHANGE' SPAUTH 10
C PARM SPTEXT 50
C PARM '*YES' SPREPL 10
C PARM APIERR
C EXSR CHKERR
*
* initialize user space list variables
C Z-ADD6 SPLKEY
C Z-ADD201 SPLK1 file name
C Z-ADD202 SPLK2 job name
C Z-ADD203 SPLK3 user name
C Z-ADD204 SPLK4 job number
C Z-ADD205 SPLK5 spool file nbr
C Z-ADD216 SPLK6 creation date
C CALL 'QUSLSPL'
C PARM SPACNM 20 usrspc name
C PARM 'SPLF0200'SPFMT 8 format
C PARM I#USNM SPUSNM 10 user name
C PARM I#OUTQ SPOUTQ 20 output queue
C PARM I#FORM SPFORM 10 formtype
C PARM I#USRD SPUSRD 10 user data
C PARM APIERR
C PARM *BLANKS SPLJBN 26 job name
C PARM SPLK
C PARM SPLKEY
C EXSR CHKERR
*
* Get User Space Detail Parameter list
C Z-ADD140 GUSHLN
C CLEARAPIHDR
* Get header data from user space
C Z-ADD1 GUSSPO
C CALL 'QUSRTVUS'
C PARM SPACNM
C PARM 1 GUSSPO
C PARM GUSHLN
C PARM APIHDR
C PARM APIERR
C EXSR CHKERR
*
C GUSOFF ADD 1 GUSSPO
C CALL 'QUSRTVUS'
C PARM SPACNM
C PARM GUSSPO
C PARM GUSHLN
C PARM SPLHDR
C PARM APIERR
C EXSR CHKERR
*
C ENDSR
* =========================================================
C CHKERR BEGSR
*
C ERRID IFNE *BLANKS
C MOVELERRID O#ERID
C MOVELERRPDT O#ERDT
C MOVE *ON *INLR
C RETRN
C ENDIF
*
C ENDSR
A blog about IBM i (AS/400), MQ and other things developers or Admins need to know.
星期二, 11月 07, 2023
2006-02-22 如何針移動整個 outq 的報表至另一個outq ?(Command PRCSLTSPLF)
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言