Search

Thursday, February 14, 2013

Submit JCL through REXX

The following REXX tool explains how JCL can be submitted through REXX.

Step 1: To get inputs from the user


/*REXX*/
/* TRACE I */
USERID = SYSVAR('SYSUID')
 "EXEC 'SYS2.CMDPROC(CLRSCRN)' CLIST"
ARG  ID FILEDT SQLINR
SAY  ID
SAY  FILEDT
SAY  SQLINR
IF ID = ' ' THEN
    DO
      SAY 'ENTER ID REQUIRED FOR INQUIRY'
      PULL IDID
    END
IF FILEDT = ' ' THEN
    DO
      SAY 'ENTER FILE DT REQUIRED FOR INQUIRY IN MM/DD/YYYY FORMAT '
      PULL FILEDT
    END
IF SQLINR = ' ' THEN
    DO
      SAY 'ENTER THE REGION FROM WHERE ID IS REQUIRED'
      PULL SQLINR
    END
IF IDID = 'END' | FILEDT = 'END' | SQLINR = 'END' THEN
    DO
      SAY 'COMMAND ENDED. THANK YOU'
      EXIT
    END
   INTLL  = LEFT(USERID(),3)
/* */

Step: 2: To allocate file where JCL will be returned with the user id automatically appended 


  "ALLOC FI(JCLFILE) DA('"USERID()".PABCB.N.TEMP.ABCD') OLD CATALOG  REUSE",
      "SPACE(1,1) TRACKS LRECL(80) BLKSIZE(3120) RECFM(F,B)"

Step 3: To create JCL


   IF ID <> "END" THEN DO
      JCL.1   = "//#ABC"INTLL"C JOB (00011100000"USERID()"),'X',"
      JCL.2   = "//             CLASS=X,"
      JCL.3   = "//             MSGCLASS=0,"
      JCL.4   = "//             REGION=4M,"
      JCL.5   = "//             NOTIFY="USERID()
      JCL.6   = "/*JOBPARM S="ABCV
      JCL.7   = "//*"
      JCL.8   = "//STEP01S  EXEC PGM=IKJEFT01"
      JCL.9   = "//STEPLIB   DD  DSN=DB2E.PSYSB.P.ABCD.SDSNLOAD,DISP=SHR"
      JCL.10  = "//SYSTSPRT  DD  SYSOUT=*"
      JCL.11  = "//DETAILS   DD  SYSOUT=*"
      JCL.12  = "//FREELST   DD  SYSOUT=*"
      JCL.13  = "//SYSTSIN   DD  *"
 JCL.14 = " EXEC 'ISPS.PABCB.P.ABC.EXEC(PVDREQR)' '"ID" "FILEDT" "SQLINR"'"
    END
      "EXECIO * DISKW JCLFILE (STEM JCL. FINIS)"
      "FREE FI(JCLFILE)"

Step 4: To submit JCL


      "SUBMIT '"USERID()".PABCB.N.TEMP.ABCD'"

After this, you can see the JCL in spool by checking the jobname #ABC*






No comments:

Post a Comment