Execute Command from an RPG program

IBM i Commands are normally run from a command line or from a CL program, but it is very simple to run the also from an RPG program.

The IBM i API program QCMDEXC is used for this. The API takes a string containing the command and the length of the command.

To simplify this in an RPG application a procedure can be made as a general utility where the call to the API is made. 

Example of a procedure executing a supplied command