QCMDEXC:
CL (Control Language) has always been (and continue to be) the best choice for the programs which require more interaction with the Operating System.
However, We do see many cases where there is a need to run these commands from other HLL programs (like. RPGLE). And, it's not always best to write a CL Program to serve this purpose.
QCMDEXC (Execute Command) API becomes very useful in this case.
This API Requires two Input parameters.
- Command String - Character field with Variable length (maximum length of 32,702 characters).
- Length Of Command String - Decimal field with 15 digits (5 decimal places).
Here is a sample code with a simple 'DSPMSG' command.
**Free
Dcl-PR ExecuteCommand ExtPgm('QCMDEXC') ;
Command Char(128) ;
Length Packed(15 : 5) ;
End-PR;
Dcl-S Command Char(128) ; //Maximum length allowed is 32,702
Dcl-S Length Packed(15 : 5) ;
Command = 'DSPMSG' ;
Length = %Len(%Trim(Command)); // Length of the Command being executed
ExecuteCommand(Command : Length) ;
*InLr = *On ;
Comments
Post a Comment