midrange.com code scratchpad
Name:
CHKINZTAP
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
09/19/2011 01:11:31 pm
IP:
Logged
Description:
Make sure a tape is loaded into the drive and then initialize it.
Code:
  1. /* Group Dekko Services, LLC                                        */
  2. /* ALL RIGHTS RESERVED.                                             */
  3. /*                                                                  */
  4. /* This program will use CHKTAP to verify that the tape is loaded   */
  5. /* then it will use the volume id retrieved from the CHKTAP and     */
  6. /* use that on the INZTAP.                                          */
  7. /*                                                                  */
  8. /* Modification log:                                                */
  9. /* 01/03/03 by R.Berendt, CDP   GDS,LLC                             */
  10. /*          Created                                                 */
  11. /* 01/17/03 by R.Berendt, CDP   GDS,LLC                             */
  12. /*          Changed INZTAP to CHECK(*YES)                           */
  13. /* 04/28/03 by R.Berendt, CDP   GDS,LLC                             */
  14. /*          Vary off/on tape drive in case backup immediately prior */
  15. /*          left drive in a failed state.                           */
  16. /* 04/29/03 by R.Berendt, CDP   GDS,LLC                             */
  17. /*          Changed INZTAP to CHECK(*NO) due to concerns regarding  */
  18. /*          holidays, and inordinate amount of time for INZTAP.     */
  19. /* 02/01/07 by R.Berendt, CDP   GDS,LLC                             */
  20. /*          Change to default density of *DEVTYPE to *CTGTYPE       */
  21. /*                                                                  */
  22. PGM (                                                                +
  23.       &TAPEDRIVE       /* Tape drive to process                   */ +
  24.       &STATUSCODE      /* Status code:                            */ +
  25.                        /*   0 = Success                           */ +
  26.                        /*  50 = Vary off failed                   */ +
  27.                        /*  51 = Vary on failed                    */ +
  28.                        /*  52 = Invalid device status             */ +
  29.                        /* 100 = Generic CHKTAP failed             */ +
  30.                        /* 200 = Generic INZTAP failed             */ +
  31.     )
  32.  
  33.     DCL  &MSG         *CHAR 132  /* First level message text         */
  34.     DCL  &MSGDTA      *CHAR 132  /* Message data                     */
  35.     DCL  &MSGID       *CHAR   7  /* Message id                       */
  36.     DCL  &STATUSCODE  *DEC    5  /* Status code:                     */ +
  37.                                  /*   0 = Success                    */ +
  38.                                  /*  50 = Vary off failed            */ +
  39.                                  /*  51 = Vary on failed             */ +
  40.                                  /*  52 = Invalid device status      */ +
  41.                                  /* 100 = Generic CHKTAP failed      */ +
  42.                                  /* 200 = Generic INZTAP failed      */
  43.     DCL  &TAPEDRIVE   *CHAR  10  /* Tape drive to process            */
  44.     DCL  &VOLID       *CHAR  14  /* Volume id of the tape            */
  45.  
  46. CHGVAR     VAR(&VOLID) VALUE(*BLANKS)
  47. CHGVAR     VAR(&STATUSCODE) VALUE(0)
  48.  
  49.  
  50.     /*                                                                         +
  51.      | Check tape drive status                                                 +
  52.     */
  53.  
  54. CALL PGM(CHKTAPSTS) PARM(&TAPEDRIVE &STATUSCODE)
  55.  
  56.  
  57. If (&StatusCode = 0) Do
  58.   /* Valid device status */
  59.  
  60.   /*                                                                         +
  61.    | CHKTAP to retrieve the volume id, then use that to INZTAP.              +
  62.   */
  63.   SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) +
  64.              MSGDTA('Checking tape volume') +
  65.              TOPGMQ(*EXT) MSGTYPE(*STATUS)
  66.   CHKTAP     DEV(&TAPEDRIVE) ENDOPT(*REWIND)
  67.   MONMSG     MSGID(CPF0000)
  68.   RCVMSG     MSGQ(*PGMQ) MSG(&MSG) MSGDTA(&MSGDTA) MSGID(&MSGID) +
  69.              MSGTYPE(*LAST)
  70.   IF         COND(&MSGID = 'CPC6778') THEN(DO) /* Volume &2 found +
  71.              on device &1.  CHKTAP worked. */
  72.     CHGVAR     VAR(&VOLID) VALUE(%SST(&MSGDTA 11 6))
  73.     SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) +
  74.                MSGDTA('Initializing tape volume') +
  75.                TOPGMQ(*EXT) MSGTYPE(*STATUS)
  76.     INZTAP     DEV(&TAPEDRIVE) NEWVOL(&VOLID) +
  77.                NEWOWNID(DEKKO) CHECK(*NO) DENSITY(*CTGTYPE)
  78.     MONMSG     MSGID(CPF0000) EXEC(DO) /* INZTAP failed */
  79.       CHGVAR     VAR(&STATUSCODE) VALUE(200)
  80.     ENDDO      /* INZTAP failed */
  81.   ENDDO      /* CHKTAP worked */
  82.   ELSE       CMD(DO) /* CHKTAP failed */
  83.     CHGVAR     VAR(&STATUSCODE) VALUE(100)
  84.   ENDDO      /* CHKTAP failed */
  85. ENDDO   /* Tape drive was either varied on, or abled to be varied off/on */
  86.  
  87. END:
  88.  
  89.              ENDPGM 
© 2004-2019 by midrange.com generated in 0.008s valid xhtml & css