Difference between revisions of "Execute System Command (QCMDEXC)"

From MidrangeWiki
Jump to: navigation, search
(Prototype for the QCMDEXC API)
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:API]]
 
[[Category:API]]
 
[[Category:RPG_Prototypes]]
 
[[Category:RPG_Prototypes]]
 +
== Summary ==
 +
 +
For more information on this API, visit [https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_72/apis/qcmdexc.htm Execute Command (QCMDEXC) API] (right-click to open link in a new tab).
 +
 +
== Prototype for the QCMDEXC API ==
 
<pre>
 
<pre>
 
DQCMDEXC          PR                  EXTPGM('QCMDEXC')             
 
DQCMDEXC          PR                  EXTPGM('QCMDEXC')             
Line 7: Line 12:
 
</pre>
 
</pre>
  
An RPG/LE free-form alternative:
+
An RPG/LE fully free-form alternative (by [[User:DaveLClarkI|Dave Clark]]):
 
<pre>
 
<pre>
      *========================================================================*
+
//=============================================================================
      * IBM API to Execute a System Command
+
// IBM API to Execute a System Command
      *
+
//
      * EXAMPLE:
+
// EXAMPLE:
      * Monitor;
+
// Monitor;
      *   VarStr = 'DLYJOB DLY(15)';
+
//   VarStr = 'DLYJOB DLY(15)';
      *   CallP IBMAPI_ExecSysCmd(VarStr: %len(VarStr));
+
//   CallP IBMAPI_ExecSysCmd(VarStr: %len(VarStr));
      * On-Error *All;
+
// On-Error *All;
      *   Reset ApiErrC;                // trap API errors
+
//   Reset ApiErrC;                // trap API errors
      *   CallP IBMAPI_SendPgmMsg( EXCP_MSGID: 'QCPFMSG  *LIBL'
+
//   CallP IBMAPI_SendPgmMsg( EXCP_MSGID: 'QCPFMSG  *LIBL'
      *                         : EXCP_DATA: %len(EXCP_DATA)
+
//                         : EXCP_DATA: %len(EXCP_DATA)
      *                         : '*ESCAPE': '*': 0: msgkey: ApiErrC );
+
//                         : '*ESCAPE': '*': 0: msgkey: ApiErrC );
      *   If (ApiErrC.BytAvail > *zero); // if an error occurred
+
//   If (ApiErrC.BytAvail > *zero); // if an error occurred
      *     Return *Off;                // indicate another error
+
//     Return *Off;                // indicate another error
      *   EndIf;
+
//   EndIf;
      * EndMon;
+
// EndMon;
      *
+
//
      * DOCUMENTATION:
+
// DOCUMENTATION:
      * http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/topic/apis/qcmdexc.htm
+
// https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_72/apis/qcmdexc.htm
      *========================================================================*
+
//=============================================================================
      dcl-pr IBMAPI_ExecSysCmd ExtPgm('QCMDEXC');
+
dcl-pr IBMAPI_ExecSysCmd extpgm('QCMDEXC');
        pCmdStr             Char(32702)  Const Options(*Varsize);
+
  pCmdStr               char(32702)  const  options(*varsize);
        pCmdLen             Packed(15:5) Const;
+
  pCmdLen               packed(15:5) const;
        pCmdIGC             Char(3)      Const Options(*Nopass);
+
  pCmdIGC               char(3)      const  options(*nopass);
      end-pr;
+
end-pr;
 
</pre>
 
</pre>
  
 
== References ==
 
== References ==
* [[QMHSNDPM — Send Program Message]], [[ApiErrC — API Error Code]]
+
* [[API Error Code Structure (ApiErrC)]]
 +
* [[Send Program Message (QMHSNDPM)|IBMAPI_SendPgmMsg]] API

Latest revision as of 16:50, 17 December 2018

Summary

For more information on this API, visit Execute Command (QCMDEXC) API (right-click to open link in a new tab).

Prototype for the QCMDEXC API

DQCMDEXC          PR                  EXTPGM('QCMDEXC')             
D prCmdStr                   32767A   CONST                         
D prCmdLen                      15P 5 CONST                         

An RPG/LE fully free-form alternative (by Dave Clark):

//=============================================================================
// 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:
// https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_72/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;

References