Using QCMDEXC API in CL program |
QCMDEXC
The Execute Command (QCMDEXC) API is an IBM-supplied program that executes/activates another single command. The QCMDEXC program can be called from the CL program or procedure.
Syntax of QCMDEXC in CL program
The command which has to run is passed as a parameter to the QCMDEXC API. Once that another command is executed the control returns to the CL program from the QCMDEXC program. Moreover, the values cannot be returned from the command fired through QCMDEXC. Therefore, RTV* commands cannot be fired through the QCMDEXC program.
CALL PGM(QCMDEXC) PARM(CommandString LengthOfCommandString)
Example: Using QCMDEXC in the CL program
PGM PARM(&CMD &CMDLEN) DCL &CMD *CHAR(256) DCL &LENGTH *DEC LEN(15 5) CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN) ENDPGM
Here, in the above program, two input params are passed during CALL to this CL program or procedure that are command string in &CMD variable and Command string length in &CMDLEN variable. Both the variables are declared. The length must be a packed decimal of length (15, 5) decimal positions. After that, we call the program QCMDEXC by passing parameters &CMD and &CMDLEN using CALL command and finally END of program.
You can prefix the CL command with a question mark (?) to request prompting or use selective prompting when you call the QCMDEXC program in an Interactive job.