Use the i5/OS™ prompter within a CL procedure or program

You can request prompting within the interactive processing of a CL procedure or program.

For example, the following procedure can be compiled and run:

PGM
.
.
.
?DSPLIB
.
.
.
ENDPGM

In this case, the prompt for the Display Library (DSPLIB) command appears on the display during processing of the program. Processing of the Display Library (DSPLIB) command waits until you have entered values for required parameters and pressed the Enter key.

Any values specified in the source procedure cannot be changed directly by the operator (or user). For example:

PGM
.
.
.
?SNDMSG TOMSGQ(WS01 WS02)
.
.
.
ENDPGM

When the procedure is called and the prompt for the Send Message (SNDMSG) command appears, the operator (or user) can enter values on the MSG, MSGTYPE, and RPYMSGQ parameters, but cannot alter the values on the TOMSGQ parameter. For example, the operator (or user) cannot add WS03 or delete WS02. The following restrictions apply to the use of the prompter within a CL procedure at run time:

When you enter a prompting request (?) on a command in a CL source file member, you may receive a diagnostic message on the command and still have a successful compilation. In this case, you must examine the messages carefully to see that the errors can be corrected by values entered through the prompt display when the procedure or program runs.

You can prompt for all commands you are authorized to in any mode while in an interactive environment except for the previously listed commands, which cannot be prompted for during processing of a CL procedure or program. This allows you to prompt for any command while at a workstation and reduces the need to refer to the manuals that describe the various commands and their parameters.

If you press F3 or F12 to cancel the prompted command while running that command, an escape message (CPF6801) is sent to the CL procedure or program. You can monitor for this message using the Monitor Message (MONMSG) command in the CL procedure or program.

When you prompt for a command, your procedure or program does not receive the command string you entered. To achieve this, prompt using QCMDCHK, then run the command using QCMDEXC. You can also use QCAPCMD to prompt and run the command.

Related tasks
Use QCMDEXC with prompting in CL procedures and programs
Related information
CL command finder