/*REXX*/
/*TRACE*/
SIGNAL ON ERROR
/*--- IDBOFF ------------------------------- 1993 - MARK MCDONALD ----*/
/*   THIS EXEC IS USED TO VARY IDMS DB AREAS OFF-LINE AND CONTINUE TO */
/*   CHECK THE IDMS DB AREAS UNTIL THEY ARE TRUELY-OFF-LINE.          */
/*   EXAMPLE CALLING JCL AT THE END OF THIS EXEC.                     */
/*--------------------------------------------------------------------*/
/*--- INIT VARIABLES ---*/
      QFLAG = 1   /* 1 = DB STILL NOT OFF-LINE  2 = OFF LINE */
      CNT = 0
      MAX_CNT = 0
      CNTR = 0
/*--- COLLECT START TIME DATE ---*/
      START_TIME = TIME()
      START_DATE = DATE()
/*--- CREATE STACK - SEPARATE FROM TSO STACK ---*/
      'NEWSTACK'
/*--- SPECIFY FILEOUT FOR DCMT DISPLAYS ---*/
      FILEOUT = "'DFM.VMAFROFF.OUT8'"
/*--- SPECIFY DATA SET/MEMBER NAMES ---*/
      LOADLIB = 'XDB.IDMSN.LOADLIB'
      SYSCTL = 'XDB.IDMSN.SYSCTL'
      DICTNARY = 'XDB.IDMSN.DICTNARY'
      VOFF_CMD = 'DFP.CNTLLIB(DCMTLST)'
      PROGRAM = "'XDB.IDMSN.LOADLIB(UCFBTCH)'"
      DCMT_DISP = 'DFP.CNTLLIB(DCMTDSP)'
/*--- TAKE AREAS OFF LINE ---*/
      CALL VARYOFF
/*--- CALL EXAMINE RESULT ROUTINE ---*/
      DO UNTIL QFLAG = 0
         CNT = CNT + 1
         SAY "COUNTER = "CNT"   QFLAG ="QFLAG
         CALL DISPLAY
      END
/*--- CAPTURE END TIME/DATE ---*/
      END_TIME = TIME()
      END_DATE = DATE()
/*--- STATISTICS BOX ---*/
      SAY "+------------------------------------------------+"
      SAY "| START TIME/DATE = "START_TIME START_DATE
      SAY "| NUMBER OF LOOPS = "CNT
      SAY "|   END TIME/DATE = "END_TIME END_DATE
      SAY "+------------------------------------------------+"
/*--- DISPLAY RESULT OF LAST LOOP ---*/
      DO CNTR = 1 TO MAX_CNT
         IF WORDS(HOLD.CNTR) > 0 THEN
            SAY LEFT(HOLD.CNTR,78)
      END
/*--- EXIT EXEC ---*/
      EEXIT:
/*      --- DELETE STACK ---*/
        'DELSTACK'
         "FA"
         IF QFLAG = 0 THEN
           EXIT
         ELSE
           EXIT 10
   EXIT
/*------------------------------------------------------------------*/
/*                          SUBROUTINES                             */
/*------------------------------------------------------------------*/
     VARYOFF:
/*     --- ALLOCATE DD CARDS FOR BATCH PROGRAM ---*/
       "FA"
       "ALLOC SYSOUT(T) DDN(SYSOUT) DDN(SYSPCH) DDN(SYSUDUMP) DDN(SYSDUMP)"
       "ALLOC SYSOUT(T) DDN(SYSLST)"
       "ALLOC DDNAME(TEMP1) DSN('"LOADLIB"') SHR"
       "ALLOC DDNAME(SYSCTL) DSN('"SYSCTL"') SHR"
       "ALLOC DDNAME(SYSDDL) DSN('"DICTNARY"') SHR"
       "ALLOC DDNAME(SYSIPT) DSN('"VOFF_CMD"') SHR"
/*     --- EXECUTE DCMT VARY OFF ---*/
       "CALL "PROGRAM
        "FA"
     RETURN
/*------------------------------------------------------------------*/
     DISPLAY:
/*     --- ALLOCATE DD CARDS FOR BATCH PROGRAM ---*/
       "FA"
       "ALLOC SYSOUT(T) DDN(SYSOUT) DDN(SYSPCH) DDN(SYSUDUMP) DDN(SYSDUMP)"
       "ALLOC DDNAME(TEMP1) DSN('"LOADLIB"') SHR"
       "ALLOC DDNAME(SYSCTL) DSN('"SYSCTL"') SHR"
       "ALLOC DDNAME(SYSDDL) DSN('"DICTNARY"') SHR"
       "ALLOC DDNAME(SYSIPT) DSN('"DCMT_DISP"') SHR"
/*     --- ALLOCATE DATA SET FOR SYSLST---*/
       IF SYSDSN("'DFM.VMAFROFF.OUT8'") = "OK" THEN
         "ALLOC DDNAME(SYSLST) DSN("FILEOUT") SHR"
       ELSE DO
         "ALLOC DSN("FILEOUT") DDNAME(SYSLST) SPACE(1 2) CYLINDERS",
         "LRECL(80) BLOCK(6160) RECFM(F,B) DSORG(PS) NEW",
         "UNIT(PRDDA)"
         END
/*     --- EXECUTE DCMT DISPLAY ---*/
       "CALL "PROGRAM
        "FA"
/*     --- CALL ROUTINE TO EXAMINE RESULT OF DISPLAY ---*/
          CALL EXAMINE
     RETURN
/*------------------------------------------------------------------*/
     EXAMINE:
/*     --- READ ENTIRE INPUT FILE INTO STACK ---*/
        "ALLOC DDNAME(INFILE) DSN("FILEOUT") SHR"
       "EXECIO * DISKR INFILE (FINIS"
/*     --- DETERMINE # OF LINES IN STACK ---*/
       TOTAL = QUEUED()
       MAX_CNT = TOTAL
/*     --- INITIALIZE FLAG ---*/
       QFLAG = 0
       READ_CNT = 0
/*     --- READ LINES FROM STACK ---*/
       DO TOTAL
         IF QUEUED() > 0 THEN
           DO
             PARSE PULL VAR
             READ_CNT = READ_CNT + 1
/*           --- DISPLAY DCMT RESULT FOR DEBUGGING ---*/
             HOLD.READ_CNT = VAR
/*           --- CHECK FOR -AREA IN LINE ---*/
             F = INDEX(VAR,"-AREA",1)
             IF F > 0 THEN
               DO
/*               --- GET AREA MODE (2ND WORD) ---*/
                 FMODE = WORD(VAR,2)
/*               --- SET FLAG IF STILL IN UPDATE MODE (UPD) ---*/
                 IF FMODE = 'UPD' THEN
                   QFLAG = 1
               END
           END
       END
     RETURN
/*------------------------------------------------------------------*/
     ERROR:
       SAY "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*"
       SAY "| AN ERROR HAS OCCURED."
       SAY "| SOURCE STATEMENT = "SOURCELINE(SIGL)
       SAY "| ERROR CODE       = "RC
       SAY "| ERROR TEXT IS    = "ERRORTEXT(RC)
       SAY "| START TIME/DATE  = "START_TIME START_DATE
       SAY "| NUMBER OF LOOPS  = "CNT
       SAY "|   END TIME/DATE  = "END_TIME END_DATE
       SAY "|           QFLAG  = "QFLAG
       SAY "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*"
       EXIT 10
     RETURN
/*====================================================================*/
/*THIS IS THE SAMPLE MVS JCL TO RUN THIS REXX PROGRAM

/USERJOB  JOB (31,H054,47,ASC),'USERID@SOME',
/         MSGCLASS=T,NOTIFY=ACYAL00,MSGLEVEL=(0,0),PRTY=13
/*MAIN    CLASS=TSO,SYSTEM=SY1
/*---------------------------------------------------------------------
/* JOB VARIES DATA BASE AREAS OFF LINE FOR LOCAL MODE PROCRESSING
/* THIS JOB REQUIRES THAT THE MEMBER TO BE EXECUTED BE IN THE
/* SYSPROC DSN.
/*---------------------------------------------------------------------
/V8OFF    EXEC PGM=IKJEFT01,DYNAMNBR=30
/SYSTSPRT DD SYSOUT=*,OUTLIM=16000000
/SYSTSIN  DD DSN=DFP.CNTLLIB(V8DBNM),DISP=SHR
/SYSEXEC  DD DSN=DFP.REXX.EXEC,DISP=SHR
/SYSPROC  DD DSN=DFP.REXX.EXEC,DISP=SHR
/

*/
^Z