I came to know that QCMDEXC
api is an IBM-supplied program for the IBM i system that can be either called from RPG or CL and other programs to call any other program that does not return any value. What should be the way or syntax to call the qcmdexc
API in RPG-free format?
QCMDEXC
API is an IBM-supplied program that can run a single command. This API can be called from an HLL program like an RPG or CL program. It calls another program or command that needs to be passed in the first parameter of theqcmdexc
API. Here, we show how we codeqcmdexc
in rpgle-free format. First, you must declare the procedure prototype ofqcmdexc
API in your program to use this API.Declaring qcmdexc prototype in rpgle free format
qcmdexc
API takes 2 input parameters first is the program call parameter of varying characters and the second is the length of the first parameter in packed decimal. Therefore, you must declare two variables in your program to hold the command and its length to be passed to theqcmdexc
api. Declaring a standalone variable in rpgle free format.Here, we declare a standalone variable varchar command and packed decimal length. Later in the program, we can evaluate some commands and calculate their length to be passed to
qcmdexc
api. Eval in rpgle free format.Here, we first evaluate the
addlible
command in the command variable and then pass the length of the command parameter by trimming the right side data and passing the actual length of the command to be executed. Now, we callqcmdexc
api in rpgle free format.