685 pts.
 Parameter Passing: RPGLE to CMD to RPGLE
Hello, I have an RPGLE program that I am using to call a command with 1 parameter. The parameter is a container number, 11 positions alphanumeric. I want to be able to run my RPGLE program, execute the command via QCMDEXC and receive/process that parameter within the same RPGLE. Is this possible? How can I do this? Here's the CMD source: PARM KWD(CONTAINER) TYPE(*CHAR) LEN(11) MIN(1) + MAX(1) PROMPT('CONTAINER NUMBER') For my learning and testing purposes, this is my RPGLE source: d cmdContainer# s 9a inz('?CNTNRSTS') d getContainer# pr extpgm('QCMDEXC') d cmdString 32702a const OPTIONS(*VARSIZE) d cmdLength 15p 5 const d dbcsFlag 3a const OPTIONS(*NOPASS) /FREE getContainer#(cmdContainer#:%len(cmdContainer#)); *inlr = *on; /END-FREE

Software/Hardware used:
V7R1
ASKED: February 19, 2013  2:51 PM
UPDATED: February 19, 2013  2:59 PM
  Help
 Approved Answer - Chosen by Eric Witham (Question Asker)

You can execute a command easily enough by passing the command string to the QCMDEXC API. But there is no memory connection that allows a parameter value to be returned. No variables can be passed. The variable values themselves must be inserted into the command string. If a command must be executed, and a parameter value must be returned, and the CPP can't simply be CALLed, then a simple CL procedure can be compiled around the command and made a part of the RPG program as an additional module. The CL procedure can pass the parameter value back and forth to RPG. -- Tom

ANSWERED:  Feb 27, 2013  2:50 PM (GMT)  by Eric Witham

 
Other Answers:
Last Wiki Answer Submitted:  February 19, 2013  2:59 pm  by  Michael Tidmarsh   11,380 pts.
Latest Answer Wiki Contributors:  Michael Tidmarsh   11,380 pts.
To see other answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

It doesn’t make a lot of sense. If you are expecting a value to be returned from a command, the command parameter needs to be defined with RTNVAL(*YES). And when RTNVAL(*YES) is specified, the command can’t have *BATCH, *INTERACT or *EXEC specified for the CRTCMD ALLOW() parameter. A parameter can return a value when it is compiled in a program, but not when it’s executed as a stand-alone command. Make the command part of a compiled CL module. — Tom

 107,735 pts.

 

If you want the value in RPGLE, just call the CPP directly. Skip the command. — Tom

 107,735 pts.

 

I was just trying to execute a small command within an RPGLE when it starts up and bypass the use of any CL or DSPF.

 685 pts.