Figure 4 Command Exit Point Program Example

   ========================================================================

 /* Program Name: RSTOBJEXIT                                          */                                               

 /* Purpose: This is the exit program for the Command RSTOBJ.  	    */                                               

 /*          Exit Point IS QIBM_QCA_RTV_COMMAND                       */                                               

 /*          Parameter format is RTVC0100.                            */                                               

 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */                                               

 /* Copyright© 2007 Dan Riehl, All rights reserved                    */



PGM    PARM(&ExitInfo)                                                  

                                                                        

DCL  &Exitinfo    *Char 2000   /* RTVC0100 Interface Data */            

                                                                        

DCL  &User        *Char   10                                            

DCL  &JobName     *Char   10                                            

                                                                         

DCL  &OffsetDec   *Dec  (7 0)                                           

DCL  &CmdLenDec   *Dec  (7 0)                                           

                                                                        

/* Exit point interface RTVC0100 for QIBM_CA_RTV_COMMAND exit point */  

DCL  &ExitPoint   *CHAR   20   /* Exit Point name              */       

DCL  &ExitFormat  *CHAR    8   /* Exit Point Format            */       

DCL  &CmdName     *CHAR   10   /* Command name being executed  */       

DCL  &CmdLib      *CHAR   10   /* Command Library              */       

DCL  &OffsetO     *CHAR    4   /* Offset to command string     */



DCL  &CmdLengthO  *CHAR    4   /* Command string length        */       

DCL  &OffsetR     *CHAR    4   /* Offset to command string     */       

DCL  &CmdLengthR  *CHAR    4   /* Command string length        */       

                                                                        

DCL  &CmdString   *CHAR 2000   /* Command String               */       

                                                                        

/* Error handling variables                                    */       

DCL  &MsgID       *CHAR    7                                            

DCL  &MsgFile     *CHAR   10                                            

DCL  &MsgFLib     *CHAR   10                                            

DCL  &MsgData     *CHAR  512                                            

                                                                        

MONMSG   CPF0000    EXEC(GOTO ERROR)                                    

                                                                        

/* Parse out the exit info data                     */                  

     CHGVAR  &ExitPoint  %SST(&ExitInfo   1  20)                        

     CHGVAR  &ExitFormat %SST(&ExitInfo  21   8)

     CHGVAR  &CmdName    %SST(&ExitInfo  29  10)                        

     CHGVAR  &CmdLib     %SST(&ExitInfo  39  10)                        

     CHGVAR  &OffsetO    %SST(&ExitInfo  53   4)                        

     CHGVAR  &CmdLengthO %SST(&ExitInfo  57   4)                        

     CHGVAR  &OffsetR    %SST(&ExitInfo  61   4)                        

     CHGVAR  &CmdLengthR %SST(&ExitInfo  65   4)                        

                                                                        

/* Check to see if command was replaced by Change Command Exit */       

     IF   (%BIN(&OffsetR) = 0)  DO  /* Command not replaced */          

        CHGVAR  &CmdLenDec  %BIN(&CmdlengthO)                           

        CHGVAR  &OffsetDec  (%BIN(&OffsetO) + 1) /* Set offset */       

      ENDDO                                                             

     ELSE   DO                      /* Command was replaced  */         

        CHGVAR  &CmdLenDec  %BIN(&CmdlengthR)                           

        CHGVAR  &OffsetDec  (%BIN(&OffsetR) + 1) /* Set offset */

     ENDDO                                                             

                                                                         

     CHGVAR  &CmdString  %SST(&ExitInfo &OffsetDec &CmdLenDec)          

                                                                        

     RTVJOBA    JOB(&JobName) USER(&User)                               

                                                                        

     SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Restore +          

                      operation in progress from user' *BCAT +         

                      &User *BCAT 'from job' *BCAT &JobName +          

                      *TCAT '. The command executed is:' *BCAT +       

                      &CmdString) TOMSGQ(RESTORE QHST)                   

                                                                        

ENDIT: RETURN /* Normal end of Program */                               

                                                                        

/* Error handling */

ERROR: RCVMSG     MSGTYPE(*LAST) MSGDTA(&MsgData) +                     

                  MSGID(&MsgID) MSGF(&MsgFile)    +                     

                  SNDMSGFLIB(&MsgFLib)                                  

       MONMSG CPF0000 EXEC(RETURN)                                      

                                                                        

       SNDPGMMSG  MSGID(&MsgID) MSGF(&MSGFLIB/&MsgFile) +               

                  MSGDTA(&MsgData) MSGTYPE(*ESCAPE)                     

       MONMSG CPF0000 EXEC(RETURN)                                      

       ENDPGM