Parameter Passing: RPGLE to CMD to RPGLE

690 pts.
Tags:
AS/400
CMD
RPG
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

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    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
    125,585 pointsBadges:
    report
  • TomLiotta
    If you want the value in RPGLE, just call the CPP directly. Skip the command. -- Tom
    125,585 pointsBadges:
    report
  • Eric Witham
    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.
    690 pointsBadges:
    report
  • TomLiotta
    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
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following