Difference between revisions of "Execute System Command (QCMDEXC)"
From MidrangeWiki
DaveLClarkI (talk | contribs) |
DaveLClarkI (talk | contribs) |
||
Line 12: | Line 12: | ||
* | * | ||
* EXAMPLE: | * EXAMPLE: | ||
− | * VarStr = 'DLYJOB DLY(15)'; | + | * Monitor; |
− | * | + | * VarStr = 'DLYJOB DLY(15)'; |
+ | * CallP IBMAPI_ExecSysCmd(VarStr: %len(VarStr)); | ||
+ | * On-Error *All; | ||
+ | * Reset ApiErrC; // trap API errors | ||
+ | * CallP IBMAPI_SendPgmMsg( EXCP_MSGID: 'QCPFMSG *LIBL' | ||
+ | * : EXCP_DATA: %len(EXCP_DATA) | ||
+ | * : '*ESCAPE': '*': 0: msgkey: ApiErrC ); | ||
+ | * If (ApiErrC.BytAvail > *zero); // if an error occurred | ||
+ | * Return *Off; // indicate another error | ||
+ | * EndIf; | ||
+ | * EndMon; | ||
* | * | ||
* DOCUMENTATION: | * DOCUMENTATION: | ||
Line 24: | Line 34: | ||
end-pr; | end-pr; | ||
</pre> | </pre> | ||
+ | |||
+ | == References == | ||
+ | * [[QMHSNDPM — Send Program Message]], [[ApiErrC — API Error Code]] |
Revision as of 20:32, 29 March 2016
DQCMDEXC PR EXTPGM('QCMDEXC') D prCmdStr 32767A CONST D prCmdLen 15P 5 CONST
An RPG/LE free-form alternative:
*========================================================================* * IBM API to Execute a System Command * * EXAMPLE: * Monitor; * VarStr = 'DLYJOB DLY(15)'; * CallP IBMAPI_ExecSysCmd(VarStr: %len(VarStr)); * On-Error *All; * Reset ApiErrC; // trap API errors * CallP IBMAPI_SendPgmMsg( EXCP_MSGID: 'QCPFMSG *LIBL' * : EXCP_DATA: %len(EXCP_DATA) * : '*ESCAPE': '*': 0: msgkey: ApiErrC ); * If (ApiErrC.BytAvail > *zero); // if an error occurred * Return *Off; // indicate another error * EndIf; * EndMon; * * DOCUMENTATION: * http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/topic/apis/qcmdexc.htm *========================================================================* dcl-pr IBMAPI_ExecSysCmd ExtPgm('QCMDEXC'); pCmdStr Char(32702) Const Options(*Varsize); pCmdLen Packed(15:5) Const; pCmdIGC Char(3) Const Options(*Nopass); end-pr;