A CL command is a statement that requests that the system perform a function.
Each command on the system has a Command Definition Object (*CMD) and a Command Processing Program (CPP).
The CPP is the program called when the command is entered.
You can define a command by entering command definition statements into a source file and running a Create Command (CRTCMD) command using the source file as input.
The command Definition statements of each command contains one or more command statements
LIBNAME/QCMDSRC CRTCMD用来create the command definition object
创建自定义CMD的步骤如下:
step 1. you need a Command Processing Pgm (CPP), optional Validity Checker Pgm (VCP), Prompt Override Pgm (POP).
step 2. enter Command Definition Statemensts in a source member of LIBNAME/QCMDSRC.
step 3. use CRTCMD command to create a Command Definition Object, *CMD
将*CMD及其CPP放在同一lib, 并将该lib添加到当前libl, 然后直接在command line输入 *CMD object的名字即可'召唤'该命令.
C2215611/QCMDSRC.HI
FMT ** ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6
*************** Beginning of data **************************
0001.00 CMD PROMPT('HI Command for CL07')
****************** End of data *****************************
C2215611/QCLSRC.CL07
FMT ** ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6
*************** Beginning of data ***************************
0001.00 PGM
0002.00 DCL VAR(&STR) TYPE(*CHAR) LEN(20)
0003.00 DCL VAR(&USER) TYPE(*CHAR) LEN(10)
0004.00
0005.00 RTVJOBA CURUSER(&USER)
0006.00 CHGVAR VAR(&STR) VALUE('HELLO ' *CAT &USER)
0007.00 SNDPGMMSG MSG(&STR) MSGTYPE(*COMP)
0008.00
0009.00 RETURN
0010.00 ENDPGM
****************** End of data ******************************
CRTCMD CMD(C2215611/HI) PGM(CL07) SRCMBR(HI)
该命令将*CMD object同*PGM CPP关联起来, 从而使得输入自定义命令名可调用相应的相应程序.
阅读(2347) | 评论(0) | 转发(0) |