如何於 CLP or CLLE 中使用 Subfile Message ?
File : QDDSSRC
Member: SUBFLEMSGD
Type : DSPF
Usage : CRTDSPF SUBFLEMSGD
A DSPSIZ(24 80 *DS3)
A R FORMAT01
A CA03(03)
A OVERLAY
A 1 31'Generate Some Report'
A 1 72DATE
A EDTCDE(Y)
A 2 72TIME
A 5 8'Enter range of dates in MMDDYY for-
A mat. You may leave ending date'
A 6 8'blank if the report is to be run f-
A or only one day.'
A 8 8'Beginning date ...................-
A ...........:'
A SBGNDATE 6Y 0B 8 55EDTCDE(4)
A 9 8'Ending date ......................-
A ...........:'
A SENDDATE 6Y 0B 9 55EDTCDE(4)
A 22 6'F3=Cancel request'
A 22 27'Enter=Generate report'
A
A R MSGSFL SFL
A SFLMSGRCD(24)
A MSGKEY SFLMSGKEY
A PGMNAM SFLPGMQ
A
A R MSGCTL SFLCTL(MSGSFL)
A SFLSIZ(0010)
A SFLPAG(0001)
A OVERLAY
A SFLDSP
A SFLDSPCTL
A SFLINZ
A N87 SFLEND
A PGMNAM SFLPGMQ(10)
File : QCLSRC
Member: SUBFLEMSGC
Type : CLP
Usage : CRTCLPGM SUBFLEMSGC
PGM
DCLF FILE(SUBFLEMSGD)
DCL VAR(&NBGNDATE) TYPE(*CHAR) LEN(6)
DCL VAR(&NENDDATE) TYPE(*CHAR) LEN(6)
DCL VAR(&WBGNDATE) TYPE(*CHAR) LEN(8)
DCL VAR(&WENDDATE) TYPE(*CHAR) LEN(8)
DCL VAR(&DATEWDW8) TYPE(*CHAR) LEN(8)
DCL VAR(&DATEWDW6) TYPE(*CHAR) LEN(8)
DCL VAR(&MSGTXT) TYPE(*CHAR) LEN(78)
DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)
/* Variables needed to determine program name */
DCL VAR(&MSGKEY) TYPE(*CHAR) LEN(4)
DCL VAR(&SENDER) TYPE(*CHAR) LEN(80)
MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR))
Prelims:
/* Determine the name of the program */
SNDPGMMSG MSG('Dummy message') TOPGMQ(*SAME) +
MSGTYPE(*INFO) KEYVAR(&MSGKEY)
RCVMSG PGMQ(*SAME) MSGTYPE(*INFO) MSGKEY(&MSGKEY) +
RMV(*YES) SENDER(&SENDER)
CHGVAR VAR(&PGMNAM) VALUE(%SST(&SENDER 27 10))
/* Get earliest acceptable date */
CHGVAR VAR(&DATEWDW8) VALUE('20020101') /* yymd */
CVTDAT DATE(&DATEWDW8) TOVAR(&DATEWDW6) +
FROMFMT(*YYMD) TOFMT(*JOB) TOSEP(*JOB) /* +
job date format */
/* Create the msgf for demo purposes. Normally this msgf */
/* would already exist in a production library */
CRTMSGF MSGF(QTEMP/SUBFLEMSGF)
MONMSG MSGID(CPF2112) EXEC(GOTO BEGIN)
ADDMSGD MSGID(MSG1001) MSGF(QTEMP/SUBFLEMSGF) +
MSG('Ending date must not be before +
beginning date')
ADDMSGD MSGID(MSG1002) MSGF(QTEMP/SUBFLEMSGF) MSG('Dates +
must not be before &1.') FMT((*CHAR 8))
Begin:
RMVMSG CLEAR(*ALL)
/* loop until F3 pressed or data is valid */
GetInput:
SNDF RCDFMT(MSGCTL)
SNDRCVF RCDFMT(FORMAT01)
IF COND(&IN03) THEN(GOTO EndPgm)
RMVMSG CLEAR(*ALL)
CHGVAR &NBGNDATE &SBGNDATE
CVTDAT DATE(&NBGNDATE) TOVAR(&WBGNDATE) +
FROMFMT(*JOB) TOFMT(*YYMD) TOSEP(*NONE)
IF (&SENDDATE *NE 0) DO
CHGVAR &NENDDATE &SENDDATE
ENDDO
ELSE DO
CHGVAR &NENDDATE &SBGNDATE
ENDDO
CVTDAT DATE(&NENDDATE) TOVAR(&WENDDATE) +
FROMFMT(*JOB) TOFMT(*YYMD) TOSEP(*NONE)
IF COND(&WENDDATE *LT &WBGNDATE) THEN(DO)
SNDPGMMSG MSGID(MSG1001) MSGF(QTEMP/SUBFLEMSGF) TOPGMQ(*SAME)
GOTO CMDLBL(GETINPUT)
ENDDO
IF COND((&WBGNDATE *LT &DATEWDW8) *OR +
(&WENDDATE *LT &DATEWDW8)) THEN(DO)
SNDPGMMSG MSGID(MSG1002) MSGF(QTEMP/SUBFLEMSGF) +
MSGDTA(&DATEWDW6) TOPGMQ(*SAME)
GOTO CMDLBL(GETINPUT)
ENDDO
EndInput:
/* Insert commands to process input here */
RETURN
Error:
RCVMSG MSGQ(*PGMQ) MSGTYPE(*EXCP) MSG(&MSGTXT) +
MSGID(&MSGID)
MONMSG MSGID(CPF0000)
CHGVAR &MSGTXT (&MSGID *BCAT &MSGTXT)
SNDPGMMSG MSG(&MSGTXT) TOPGMQ(*SAME)
MONMSG MSGID(CPF0000)
GOTO CMDLBL(GETINPUT)
EndPgm:
ENDPGM
A blog about IBM i (AS/400), MQ and other things developers or Admins need to know.
星期三, 11月 01, 2023
2002-04-04 如何於 CLP or CLLE 中使用 Subfile Message ?
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言