简体   繁体   中英

How to call a *CMD programm using free RPG prototype

Does anyone know how to call a *CMD program in free RPG using a prototype? In my case the command has 10 parameters and I want to call it with just 4.

Calling it with 10/10 parameter works. But how do I do it with fewer parameters?

Commands (*CMD) are executed by the command language processor, not called.

Assuming a user written command, thus you have the source for the program envoked by the command...I'd recommend creating a prototype and calling the program that processes the command directly...

DSPCMD will tell you what that program is...

If an IBM or third party command, you'll need to call the command language processor and pass it the command you want to execute.

IBM provides a few APIs for the command language processor..
Execute Command (QCMDEXC)
Process Commands (QCAPCMD)

Also, you can use the C-runtime API
system() — Execute a Command

Here's a nice article about using the most powerful (and complex) option, QCAPCMD...with links to articles about QCMDEXC and system().
QCAPCMD another alternative to QCMDEXC

Declare this in your D Specific:

DCL-PR GoCmd INT(10) EXTPROC('system'); 
    CmdString POINTER VALUE OPTIONS(*STRING); 
END-PR;

then you can call AS400 command... example:

CmdString = 'CLRPFM FILE(WORKFILE)' ;
ReturnCode = Gocmd(CmdString) ;      

If you can use sqlrpgle then its very easy, you can do as if you are on command line, just use the params which you need only:

exec sql call qsys2.qcmdexc('DSPJOBLOG OUTPUT(*PRINT)');

see also here - obviosly this works for a long time: http://www.midrangenews.com/view?id=2395

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM