Example: Creating a program temporary fix exit program

This example exit program, written in CL, covers these possible changes in the logical state of a program temporary fix (PTF): loaded to temporarily applied and temporarily applied to temporarily removed. The example program shows where you can add your code. You can write a PTF exit program in any programming language.

Note: This example does not show the apply-temporary to apply-permanent or the not-applied to remove-permanent cases. It is assumed that all action was taken on the moves from loaded to apply-temporary and from apply-temporary to not-applied. If additional actions are necessary, code could be added to handle those transitions as well.

Do not assume the default values for parameters on CL commands or for library lists. Users can change these values. Library lists can vary from one system to another.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

 /****  START OF SPECIFICATIONS  *************************************/
 /*                                                                  */
 /* LANGUAGE:  CL                                                    */
 /*                                                                  */
 /* APIs USED: None                                                  */
 /*                                                                  */
 /* FUNCTION:                                                        */
 /*            THIS EXIT PROGRAM IS CALLED DURING ANY                */
 /*            OF THE FOLLOWING CASES.                               */
 /*                                                                  */
 /*            APPLY TEMPORARILY -  (user defined)                   */
 /*                                                                  */
 /*            APPLY PERMANENTLY -  (user defined)                   */
 /*                                                                  */
 /*            REMOVE TEMPORARILY - (user defined)                   */
 /*                                                                  */
 /*            REMOVE PERMANENTLY - (user defined)                   */
 /*                                                                  */
 /* Input:     PARM1 - CHAR(7)  - Product ID                         */
 /*            PARM2   CHAR(7)  - PTF ID                             */
 /*            PARM3 - CHAR(6)  - Product release                    */
 /*            PARM4   CHAR(4)  - Product option ID                  */
 /*            PARM5   CHAR(4)  - Product load ID                    */
 /*            PARM6   CHAR(10) - PTF library                        */
 /*            PARM7   CHAR(50) - User data                          */
 /*            PARM8 - CHAR(1)  - Current PTF Status                 */
 /*                               0 - LOADED BUT NOT APPLIED         */
 /*                               1 - APPLIED TEMPORARILY            */
 /*            PARM9   CHAR(1)  - PTF Operation                      */
 /*                               0 - REMOVE TEMPORARILY             */
 /*                               1 - APPLY TEMPORARILY              */
 /*                               2 - APPLY PERMANENTLY              */
 /*                               3 - REMOVE PERMANENTLY             */
 /*                               4 - PRE-REMOVE TEMPORARILY         */
 /*                               5 - PRE-APPLY TEMPORARILY          */
 /*                               6 - PRE-APPLY PERMANENTLY          */
 /*                               7 - PRE-REMOVE PERMANENTLY         */
 /*                                                                  */
 /*                                                                  */
 /*******  END OF SPECIFICATIONS  ************************************/
 PGM PARM(&PARM1 &PARM2 &PARM3 &PARM4 &PARM5 &PARM6 &PARM7 &PARM8 &PARM9)
 /*------------------------------------------------------------------*/
 /*                                                                  */
 /* DECLARE INPUT PARAMETERS                                         */
 /*                                                                  */
 /*------------------------------------------------------------------*/

 DCL  &PARM1   TYPE(*CHAR) LEN(7)   /* Product ID                    */
 DCL  &PARM2   TYPE(*CHAR) LEN(7)   /* PTF ID                        */
 DCL  &PARM3   TYPE(*CHAR) LEN(6)   /* Product release               */
 DCL  &PARM4   TYPE(*CHAR) LEN(4)   /* Product option ID             */
 DCL  &PARM5   TYPE(*CHAR) LEN(4)   /* Product load ID               */
 DCL  &PARM6   TYPE(*CHAR) LEN(10)  /* PTF library                   */
 DCL  &PARM7   TYPE(*CHAR) LEN(50)  /* User data                     */
 DCL  &PARM8   TYPE(*CHAR) LEN(1)   /* Current PTF status            */
 DCL  &PARM9   TYPE(*CHAR) LEN(1)   /* PTF operation                 */
 /*------------------------------------------------------------------*/

 /*------------------------------------------------------------------*/
 /*                                                                  */
 /* DECLARE VARIABLES                                                */
 /*                                                                  */
 /*------------------------------------------------------------------*/
 DCL &ACTION   TYPE(*CHAR) LEN(1)   /* PTF action to occur           */
 DCL &STATUS   TYPE(*CHAR) LEN(1)   /* PTF current status            */
                                    /* Handle exceptions             */
 MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(HDLERR))


   CHGVAR VAR(&ACTION) VALUE(&PARM9) /* Gets action being performed  */
   CHGVAR VAR(&STATUS) VALUE(&PARM8) /* Gets current PTF status      */

   /*----------------------------------------------------------------*/
   /*     THE CURRENT STATUS OF THE PTF IS "LOADED (NOT APPLIED)"    */
   /*----------------------------------------------------------------*/
   IF (&STATUS = '0') THEN(DO)   /* If PTF is loaded but not applied */
     IF (&ACTION = '1') THEN(DO) /* If action is temporarily         */
                                 /* applied then                     */
         /*?---- TEMP APPLY -  ADD YOUR STATEMENTS HERE -----        */
     ENDDO
     IF (&ACTION = '5') THEN(DO)    /* If action will be temporarily */
                                    /* apply then                    */
         /*?---- PRE-TEMP APPLY -  ADD YOUR STATEMENTS HERE -----    */
     ENDDO
   ENDDO                            /* End of loading the PTF        */

   /*----------------------------------------------------------------*/
   /*     THE CURRENT STATUS OF THE PTF IS "APPLIED TEMPORARILY"     */
   /*----------------------------------------------------------------*/
   IF (&STATUS = '1') THEN(DO)      /* If PTF is temporarily         */
                                    /* applied then                  */
     IF (&ACTION = '0') THEN(DO)    /* If action is temporarily      */
                                    /* removed then                  */
         /*?---- TEMPORARILY REMOVE - ADD YOUR STATEMENTS HERE ---   */
     ENDDO
     IF (&ACTION = '4') THEN(DO)    /* If action will be temporarily */
                                    /*  remove then                  */
         /*?---- PRE-TEMP REMOVE - ADD YOUR STATEMENTS HERE -----    */
     ENDDO
   ENDDO                            /* End of remove the PTF         */
    /*---------------------------------------------------------------*/
    /*     PTF HAS BEEN SUCCESSFULLY PROCESSED                       */
    /*---------------------------------------------------------------*/
       QSYS/SNDPGMMSG  MSGID(CPC1214) MSGF(*LIBL/QCPFMSG) +
                       MSGDTA(*NONE) TOPGMQ(*PRV (* *NONE +
                       *NONE)) TOMSGQ(*TOPGMQ) MSGTYPE(*COMP)
   RETURN
   /*----------------------------------------------------------------*/
   /*     HANDLE ALL ERROR CONDITIONS                                */
   /*----------------------------------------------------------------*/
  HDLERR:
      /* Try to back out any changes already made */
      /* If nothing to back out or back-out operation was successful */
      QSYS/SNDPGMMSG  MSGID(CPF3638) MSGF(*LIBL/QCPFMSG) +
                      MSGDTA(*NONE) TOPGMQ(*PRV (* *NONE +
                      *NONE)) TOMSGQ(*TOPGMQ) MSGTYPE(*ESCAPE)
      /* Else the permanent changes not backed out    */
      QSYS/SNDPGMMSG  MSGID(CPF3639) MSGF(*LIBL/QCPFMSG) +
                      MSGDTA(*NONE) TOPGMQ(*PRV (* *NONE +
                      *NONE)) TOMSGQ(*TOPGMQ) MSGTYPE(*ESCAPE)

ENDPGM                              /* Return to external caller     */