command execution

Application development
thanks a lot!! for the help... but meanwhile i have got another my project- i have to use COMPILE commands such as CRTPF, CRTCLPPGM, CRTRPGPGM and so a program and this has to be transparent to the user. in CL these programs cannot be used... how can i do this? plz help me out!

Answer Wiki

Thanks. We'll let you know when a new response is added.


I’m a little confused – there’s nothing stopping you from using compilation commands, e.g. CRTPF, CRTCLPGM, etc, or indeed any command from within a CL program. Actually, that’s not entirely true, there are some commands that aren’t allowed to be used from within programs, but the compilation commands aren’t any of them.

In your CL program just code the command with the appropriate parameters, For example:


or whatever.

In RPG you can run commands by using either the QCMDEXC or QCAPCMD system API’s. The QCMDEXC is easier to code, but doesn’t return any completion status to the program whereas the QCAPCMD does.

To use the QCAPCMD you need to include the following in your RPG program:

* Common API Error Structure


D ApiError DS
D ApiBytes 10I 0 Inz(%Size(ApiError))
D ApiBytesOut 10I 0
D ApiErrID 7A
D ApiReserved 1A
D ApiErInDta 256A


* Process Command API

D QcaPCmd Pr ExtPgm(‘QCAPCMD’)
D aCmd 32767a Const Options(*VarSize)
D aCmdLen 10i 0 Const
D aCtlBlk 32767a Const Options(*VarSize)
D aCtlBlkLen 10i 0 Const
D aCtlBlkFmt 8a Const
D aRtnCmd 32767a Options(*VarSize)
D aRtnCmdAvl 10i 0 Const
D aRtnCmdLen 10i 0
D aApiError Like(ApiError)

D CPOP0100 Ds
D capPrcType 10i 0 Inz(0)
D capDBCS 1a Inz(‘0’)
D capPrompt 1a Inz(‘0’)
D capSyntax 1a Inz(‘0′)
D capMsgKey 4a
D capReserved 9a Inz(*Allx’00’)

D CmdFailed c Const(‘3’)
D CmdSuccessful c Const(‘4’)

D iCmd 32767a Options(*VarSize)
D wCmd s 32767a
D wCmdLen s 10i 0

And then to call it use something like:

C CallP(e) QcaPCmd(iCmd :
C %Len(%Trim(iCmd)) :
C CPOP0100 :
C %Len(CPOP0100) :
C ‘CPOP0100’ :
C wCmd :
C 32767 :
C wCmdLen :
C ApiError)

Hope it helps.


Discuss This Question: 3  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.
  • TomLiotta
    The question definitely doesn't make sense. All of the commands you listed are perfectly acceptable in compiled CL programs. The commands themselves may be compiled as part of the CL programs with parameters supplied in CL variables or command strings can be created and passed to the QCAPCMD API (or QCMDEXC). Please describe the actual problems you're seeing. It might even be useful to describe why you would ever want "users" to have access to those commands. Tom
    125,585 pointsBadges:
  • Splat
    These commands may not 'work' in CL because your end users don't have the necessary authority (which they probably shouldn't have).
    12,915 pointsBadges:
  • TomLiotta
    These commands may not ‘work’ in CL because your end users don’t have the necessary authority... Although true, that would mean they won't work in RPG, REXX or other program languages. If they are working in RPG, even unsatisfactorily, it's possibly because the RPG is adopting authority that hasn't been supplied to a CL program. Adopted authority may be blocked by setting USEADPAUT(*NO), but it can be generated by compiling as USRPRF(*OWNER) even if blocked from above. Tom
    125,585 pointsBadges:

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.

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


Share this item with your network: