使用 QSPRILSP API 取得 current job 的最後一份報表的 ID 資訊(Command RTVLSTSPLI)
從 V5R2 後系統提供新 API QSPRILSP 來取得 current job 的最後一份報表的 ID 資訊。
File : QCLSRC
Member: RTVLSTSPLI
Type : CLP
Usage : CRTCLPGM yourlib/RTVLSTSPLI
OS : V5R2
/*-------------------------------------------------------------------*/
/* Program . . : RTVLSTSPLI */
/* Description : Retrieve Last Spooled Id under current job */
/* Author . . : Vengoal Chang */
/* Published . : AS400ePaper */
/* Date . . . : January 4, 2012 */
/* */
/* Program function: Retrieve Last Spooled Id under current job */
/* */
/* */
/* Compile options: */
/* CrtClPgm Pgm( RTVLSTSPLI ) */
/* SrcFile( QCLSRC ) */
/* SrcMbr( *PGM ) */
/* */
/*-------------------------------------------------------------------*/
/* In V5R2 new API */
/* RETRIEVE IDENTITY OF LAST SPOOLED FILE CREATED (QSPRILSP) API */
/*-------------------------------------------------------------------*/
Pgm ( &Splf +
&Job +
&User +
&Nbr +
&SplfNbrC +
)
Dcl &RcvVar *Char 70
Dcl &RcvVarLen *Char 4
Dcl &ApiErrCode *Char 8
/* FIELDS FROM FORMAT SPRL0100 */
Dcl &BytesRtn *Dec (10 0)
Dcl &BytesAvl *Dec (10 0)
Dcl &Splf *Char 10
Dcl &Job *Char 10
Dcl &User *Char 10
Dcl &Nbr *Char 6
Dcl &SplfNbr *Dec (6 0)
Dcl &SplfNbrC *Char 6
Dcl &SystemName *Char 8
Dcl &CreateDate *Char 7
Dcl &CreateTime *Char 6
/*-- Global error monitoring: --------------------------------------*/
MonMsg CPF0000 *N GoTo Error
ChgVar (%bin(&ApiErrCode 1 4)) 0
ChgVar (%bin(&RcvVarLen 1 4)) 70
Call QSPRILSP ( &RcvVar +
&RcvVarLen +
'SPRL0100' +
&ApiErrCode )
ChgVar &BytesRtn %bin(&RcvVar 1 4)
ChgVar &BytesAvl %bin(&RcvVar 5 4)
ChgVar &Splf %sst(&RcvVar 9 10)
ChgVar &Job %sst(&RcvVar 19 10)
MonMsg Mch3601
ChgVar &User %sst(&RcvVar 29 10)
MonMsg Mch3601
ChgVar &Nbr %sst(&RcvVar 39 6)
MonMsg Mch3601
ChgVar &SplfNbr %bin(&RcvVar 45 4)
ChgVar &SplfNbrC &SplfNbr
ChgVar &SystemName %sst(&RcvVar 49 8)
ChgVar &CreateDate %sst(&RcvVar 57 7)
ChgVar &CreateTime %sst(&RcvVar 65 6)
Return:
Return
/*-- Error handling: -----------------------------------------------*/
Error:
Call QMHMOVPM ( ' ' +
'*DIAG' +
x'00000001' +
'*PGMBDY' +
x'00000001' +
x'0000000800000000' +
)
Call QMHRSNEM ( ' ' +
x'0000000800000000' +
)
EndPgm:
EndPgm
File : QCMDSRC
Member: RTVLSTSPLI
Type : CMD
Usage : CRTCMD Cmd(yourlib/RTVLSTSPLI) Pgm(RTVLSTSPLI) Allow( *Ipgm *Bpgm )
OS : V5R2
/* =============================================================== */
/* = Command....... RtvLstSplI = */
/* = CPP........... RtvLstSplI = */
/* = Description... Retrieve Last Spooled Id under current job = */
/* = = */
/* = = */
/* = CrtCmd Cmd( RtvLstSplI ) = */
/* = Pgm( RtvLstSplI ) = */
/* = SrcFile( YourSourceFile ) = */
/* = Allow( *Ipgm *Bpgm ) = */
/* =============================================================== */
/* = Date : 2012/01/04 = */
/* = Author: Vengoal Chang = */
/* =============================================================== */
CMD PROMPT('Retrieve Last Spooled File Id')
PARM KWD(SPLF ) TYPE(*CHAR) LEN(10) +
RTNVAL(*YES) MIN(1) +
PROMPT('CL var for SPLF (10)')
PARM KWD(JOB ) TYPE(*CHAR) LEN(10) +
RTNVAL(*YES) +
PROMPT('CL var for JOB (10)')
PARM KWD(USER ) TYPE(*CHAR) LEN(10) +
RTNVAL(*YES) +
PROMPT('CL var for USER (10)')
PARM KWD(NBR ) TYPE(*CHAR) LEN( 6) +
RTNVAL(*YES) +
PROMPT('CL var for NBR (6)')
PARM KWD(SPLNBR ) TYPE(*CHAR) LEN( 6) +
RTNVAL(*YES) MIN(1) +
PROMPT('CL var for SPLNBR (6)')
File : QCLSRC
Member: RTVLSTSPLT
Type : CMD
Usage : CRTCLPGM pgm(yourlib/RTVLSTSPLT)
CALL RTVLSTSPLT
PGM
Dcl &Splf *Char 10
Dcl &Job *Char 10
Dcl &User *Char 10
Dcl &Nbr *Char 6
Dcl &SplNbrC *Char 6
RTVLSTSPLI SPLF(&SPLF) JOB(&JOB) USER(&USER) NBR(&NBR) +
SPLNBR(&SPLNBRC)
MONMSG CPF333A /* No spooled file created under the current job */
DMPCLPGM
DSPSPLF FILE(QPPGMDMP) SPLNBR(*LAST)
ENDPGM
詳細資訊參照:Retrieve Identity of Last Spooled File Created (QSPRILSP) API
A blog about IBM i (AS/400), MQ and other things developers or Admins need to know.
星期三, 11月 08, 2023
2012-01-04 使用 QSPRILSP API 取得 current job 的最後一份報表的 ID 資訊(Command RTVLSTSPLI)
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言