

Execute a CL program

I am attempting to execute a CL program on system b from a CL program that resides on system a. The CL on system b has parameters that are variables. The procedure will work with SBMRMTCMD, but when I attempt to execute it with AREXEC or RUNRMTCMD, the error message that I receive states that variables are invalid. If I substitute a literal for the variable, there is not a problem. Do the later two commands actually not accept variables? I found this hard to believe and am hoping that it is user error. Any help would be greatly appreciated.

When passing parameters, what is actually passed is a pointer to the passed parameters. There are a few ways around this. One is to create a CL in QTEMP, which hard-codes the parameters, compiles and calls it. Another is to send a message to the remote user to be retrieved by the called CL. Another (my preference) is to pass the data via a remote data queue. The called program checks the "Hard coded" variables passed. If they are set to a specific value, it reads the data queue (or retrieves the message) and parses the parameters into the variables it had expected the caller to pass.

Calling program:
OrdNo = 00012345
CustNo = 000456789
PartNo = "A123456ADFDSFSD "
QtyShip = 0012345.8955
Concat into "00012345000456789A123456ADFDSFSD 0012345.8955"
Send to data queue defined as remote data queue.
Call Program C on remote system, which calls program B passing hard coded value for OrdNo of -1 and all other variables as zeros or blanks.
Called program:
Check to see if OrdNo is -1
If no
Process normally
If Yes
Read data queue and parse values into passed variables
Process normally.


The Best Web Links: tips, tutorials and more.


Dig Deeper on RPG iSeries programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.