CL Command Executive Program
CL subprogram to execute commands.
Simplify Command Execution with CL
CLP can function to execute commands when called with parameters. Instead of coding the QCMDEXEC as a procedure in RPG, a subprogram call to a CLP can be a simple alternative.
/*********************************************************************/ /* */ /* Control language program description. */ /* */ /* Program Id........... MIS421CL - Command Execution Program */ /* Programmer........... Steven Croy */ /* */ /* Date coded........... xx/xx/xxxx */ /* Function............. This program functions as a command */ /* processor for HLL programs. It accepts */ /* and incoming data stream and executes */ /* the command. */ /* */ /* Compiler options..... *OWNER */ /* */ /* Parameters required.. &CMD - Command to execute (256) */ /* &MSGLEN- Message length (15,5) */ /* &MSGFLG- Message Flag (1) */ /* */ /*********************************************************************/ /*************************** MODIFICATIONS **************************/ /* */ /* Modification No. - */ /* Reference No. - */ /* Programmer - */ /* Date modified - */ /* Nature of change - */ /* */ /*********************************************************************/ PGM PARM( + &CMD + &MSGLEN + &MSGFLG + ) /*------------------------------------------------------------------------*/ /* Declaritives */ /*------------------------------------------------------------------------*/ DCL &CMD *CHAR 256 /* Command to be executed */ DCL &MSG2 *CHAR 132 /* Intermediate level message */ DCL &MSG *CHAR 132 /* Return message variable */ DCL &MSGFLG *CHAR 1 /* Receive message flag */ DCL &MSGLEN *DEC (15 5) /* Message length */ /*------------------------------------------------------------------------*/ /* Execute the command */ /*------------------------------------------------------------------------*/ EXECUTE: CALL PGM(*LIBL/QCMDEXC) PARM(&CMD &MSGLEN) MONMSG MSGID(CPF0000) /*------------------------------------------------------------------------*/ /* Process any/all messages that may have been issued */ /*------------------------------------------------------------------------*/ NEXT_MSG: RCVMSG RMV(*NO) MSG(&MSG2) IF COND(&MSG2 *NE ' ') THEN(DO) CHGVAR VAR(&MSG) VALUE(&MSG2) GOTO CMDLBL(NEXT_MSG) ENDDO /*------------------------------------------------------------------------*/ /* Return error message to requester */ /*------------------------------------------------------------------------*/ IF COND(&MSG *NE ' ') THEN(DO) CHGVAR VAR(&MSGFLG) VALUE('1') CHGVAR VAR(&CMD) VALUE(&MSG) ENDDO RETURN ENDPGM