How to Code Selective prompting in CL and common mistake to avoid |
How to code Selective prompting in CL program
To enable selective prompting in CL on any command just prefix the command with question mark sign (?). After selective prompting the command displays the list of parameters associated with the command when running in CL program and we input values to CL command parameters
For Example, here we are enabling selective prompting on SNDMSG command in CL program.
?SNDMSG
CL program to Code Selective prompting
PGM ?SNDMSG MONMSG MSGID(CPF6801) CMPDTA('F3') EXEC(RETURN) MONMSG MSGID(CPF6801) EXEC(SNDPGMMSG MSG('F12 + PRESSED')) SNDPGMMSG MSG(EXECUTED) ENDPGM
Explanation and output of the above program
?SNDMSGOutput:
Send Message (SNDMSG) Type choices, press Enter. Message text . . . . . . . . . . MSG To user profile . . . . . . . . TOUSR
Then you can type msg and Tousr values as below. Then you can press F10 tp see additional parameters and Input there values.
Send Message (SNDMSG) Type choices, press Enter. Message text . . . . . . . . . . MSG TEST To user profile . . . . . . . . TOUSR EASYCLASS
Display Messages System: Queue . . . . . : EASYCLASS Program . . . . : Library . . . : QUSRSYS Library . . . : Severity . . . : 00 Delivery . . . : Type reply (if required), press Enter. From . . . : EASYCLASS 06/09/22 20:09:10 TEST
MONMSG MSGID(CPF6801) CMPDTA('F3') EXEC(RETURN)
MONMSG MSGID(CPF6801) EXEC(SNDPGMMSG MSG('F12 + PRESSED'))
SNDPGMMSG MSG(EXECUTED)
Common mistake to avoid
When using selective prompting in your CL procedures, you must remember that the CL procedure stops and the command prompter appears. All function keys supported by the command prompter are active, including F3 (Exit) and F12 (Cancel). When the user presses F3 or F12, the command prompter issues an *ESCAPE message (CPF6801) to your CL procedure that must be handled in your CL program as described in above CL code.