How to make prompt selective in CL |
Making the prompt selective in CL
Selective prompting for CL commands is especially helpful when you are using some of the longer commands and do not want to be prompted for certain parameters. You can use selective prompting to:
Here, In this article you can have an basic idea of how to code selective prompting in CL program. In this article, you will learn how to prompt for specific parameters of the CL command using selective prompting. We will use the SNDMSG comamnd as an example to make the prompt selective.
How to make prompt selective in CL program
PGM ?SNDMSG ??MSG() MONMSG MSGID(CPF6801) CMPDTA('F3') EXEC(RETURN) MONMSG MSGID(CPF6801) EXEC(SNDPGMMSG MSG('F12 + PRESSED')) SNDPGMMSG MSG(EXECUTED1) ?SNDMSG ??MSG('TEST MESSAGE') MONMSG MSGID(CPF6801) CMPDTA('F3') EXEC(RETURN) MONMSG MSGID(CPF6801) EXEC(SNDPGMMSG MSG('F12 + PRESSED')) SNDPGMMSG MSG(EXECUTED2) ?SNDMSG ?*TOMSGQ() MONMSG MSGID(CPF6801) CMPDTA('F3') EXEC(RETURN) MONMSG MSGID(CPF6801) EXEC(SNDPGMMSG MSG('F12 + PRESSED')) SNDPGMMSG MSG(EXECUTED3) ?SNDMSG ?*TOMSGQ(QSYSOPR) MONMSG MSGID(CPF6801) CMPDTA('F3') EXEC(RETURN) MONMSG MSGID(CPF6801) EXEC(SNDPGMMSG MSG('F12 + PRESSED')) SNDPGMMSG MSG(EXECUTED4) ?SNDMSG ?-MSGTYPE() MONMSG MSGID(CPF6801) CMPDTA('F3') EXEC(RETURN) MONMSG MSGID(CPF6801) EXEC(SNDPGMMSG MSG('F12 + PRESSED')) SNDPGMMSG MSG(EXECUTED5) ? SNDMSG ?-MSGTYPE(*INQ) MONMSG MSGID(CPF6801) CMPDTA('F3') EXEC(RETURN) MONMSG MSGID(CPF6801) EXEC(SNDPGMMSG MSG('F12 + PRESSED')) SNDPGMMSG MSG(EXECUTED6) ENDPGM
Explanation
We do monitor message CPF6801 handling with selective prompting just because at any time user can press F3 or F12 to exit from the selective prompting.In case user do not press F3 or F12 then SNDMSG command got execure and we send a message to the program message queue using SNDPGMMSG command.
?SNDMSG ??MSG() MONMSG MSGID(CPF6801) CMPDTA('F3') EXEC(RETURN) MONMSG MSGID(CPF6801) EXEC(SNDPGMMSG MSG('F12 + PRESSED')) SNDPGMMSG MSG(EXECUTED1)Output:
Below MSG param is input capable and must be entered. If we do not enter any value to the MSG parameter of the SNDMSG command then we get error message i.e. "parameter MSG required".
?SNDMSG ??MSG('TEST MESSAGE') MONMSG MSGID(CPF6801) CMPDTA('F3') EXEC(RETURN) MONMSG MSGID(CPF6801) EXEC(SNDPGMMSG MSG('F12 + PRESSED')) SNDPGMMSG MSG(EXECUTED2)Output:
Here, MSG() parameter is input capable and having default value "TEST MESSAGE" and can be changed during selective prompting of command SNDMSG.
?SNDMSG ?*TOMSGQ() MONMSG MSGID(CPF6801) CMPDTA('F3') EXEC(RETURN) MONMSG MSGID(CPF6801) EXEC(SNDPGMMSG MSG('F12 + PRESSED')) SNDPGMMSG MSG(EXECUTED3)Output:
Here, TOMSGQ() parameter is output capable and having default value blank and cannot be changed during selective prompting of command SNDMSG.
?SNDMSG ?*TOMSGQ(QSYSOPR) MONMSG MSGID(CPF6801) CMPDTA('F3') EXEC(RETURN) MONMSG MSGID(CPF6801) EXEC(SNDPGMMSG MSG('F12 + PRESSED')) SNDPGMMSG MSG(EXECUTED4)Output:
Here, TOMSGQ() parameter is output capable and having default value "QSYSOPR" and cannot be changed during selective prompting of command SNDMSG.
?SNDMSG ?-MSGTYPE() MONMSG MSGID(CPF6801) CMPDTA('F3') EXEC(RETURN) MONMSG MSGID(CPF6801) EXEC(SNDPGMMSG MSG('F12 + PRESSED')) SNDPGMMSG MSG(EXECUTED5)Output:
Here, MSGTYPE() parameter is hidden during selective prompting of command SNDMSG. Its default value is blank.
? SNDMSG ?-MSGTYPE(*INQ) MONMSG MSGID(CPF6801) CMPDTA('F3') EXEC(RETURN) MONMSG MSGID(CPF6801) EXEC(SNDPGMMSG MSG('F12 + PRESSED')) SNDPGMMSG MSG(EXECUTED6)Output:
Here, MSGTYPE() parameter is hidden during selective prompting of command SNDMSG. Its default value is "*INQ".
But, when you press SHIFT + F2, you will see the hidden parameter and its provided value for selective prompting.