spizen556
New User
Joined: 02 Apr 2020 Posts: 14 Location: India
|
|
|
|
Hi All,
My apologize for a big post.
I have written rexx code to expand the copybooks in the PDS.
PGM1:
Code: |
/**REXX**/
/*TRACE ALL
CLRSCRN
ADDRESS TSO
SAY "ENTER THE PDS WITH PROGRAMS TO EXPAND COPYBOOKS"
PULL PDS1
PDS1=STRIP(PDS1)
PDS2 = "'"||PDS1||"'"
/*
SAY PDS2
*/
X = OUTTRAP('ML.')
"LISTDS "PDS2" MEMBERS"
X = OUTTRAP('OFF')
K = 1
J = 1
DO N = 7 TO ML.0
PARSE VAR ML.N MEMBER
MEM1=STRIP(MEMBER)
DSN1=PDS1||'('||MEM1||')'
ADDRESS ISPEXEC "EDIT DATASET('"DSN1"') MACRO(MACROE)"
END
EXIT
|
MACROE:
Code: |
/* REXX EDIT MACRO */
/* EXPAND ALL COPY STATEMENTS IN A COBOL PROGRAM */
/*TRACE ALL */
ADDRESS ISREDIT
"MACRO"
/* ============================================================ */
CPYLIB = "Copybook library"
DB2LIB = "DCLGEN Library Name"
C_CNT = 0
ADDRESS ISREDIT
ISREDIT "C ALL" COPH COPY
ISREDIT "UNEC"
/* ------------------------------------------------------------ */
/* LOOP THROUGH PROGRAM SOURCE */
"(CURRLN) = LINENUM .ZCSR" /* CURRENT LINE */
"(LASTLN) = LINENUM .ZLAST" /* LAST LINE NUMBER */
I = 0
DO FOREVER
I = I + 1
IF I > LASTLN THEN LEAVE
"(LINE) = LINE " I
LINE = SUBSTR(LINE,7,64)
CMD = SUBWORD(LINE,1,1)
CPY = SUBWORD(LINE,2,1)
VAR1 = SUBWORD(LINE,3,1)
VAR2 = SUBWORD(LINE,4,1)
UPPER CMD
UPPER CPY
UPPER VAR1
UPPER VAR2
IF PREVAR = 'INCLUDE' THEN DO
CMD = PREVAR
CPY = SUBWORD(LINE,1,1)
end
IF CMD = 'EXEC' & CPY = 'SQL' & VAR1 = 'INCLUDE' & VAR2 = ' ' then do
PREVAR = VAR1
iterate
end
IF CMD = 'EXEC' & CPY = 'SQL' then do
CMD = SUBWORD(LINE,3,1)
CPY = SUBWORD(LINE,4,1)
end
if datatype(CMD) = 'NUM' then do
CMD = SUBWORD(LINE,3,1)
CPY = SUBWORD(LINE,4,1)
end
UPPER CMD
UPPER CPY
IF CMD \= 'COPY' & CMD \= 'INCLUDE' THEN ITERATE
CPY = STRIP(CPY,'L','&')
CPY = STRIP(CPY,'T','.')
CPY = STRIP(CPY,,'"')
CPY = STRIP(CPY,,"'")
CALL EXPAND_COPYBOOK
PREVAR = ' '
/* EXIT(RC) */
END
ADDRESS ISPEXEC
"ISREDIT RENUM"
"ISREDIT UNNUMB"
"ISREDIT SAVE"
"ISREDIT END"
EXIT 0
/* ------------------------------------------------------------ */
EXPAND_COPYBOOK:
/* CHECK IF COPYBOOK EXISTS */
DSN = CPYLIB || "("CPY")"
RC = SYSDSN("'"DSN"'")
IF (RC \= 'OK') THEN
DSN = DB2LIB || "("CPY")"
RC = SYSDSN("'"DSN"'")
IF (RC \= 'OK') THEN DO
MSG = "'COPYBOOK NOT FOUND:" CPY "'"
"ISREDIT LINE_AFTER " I "= NOTELINE" MSG
RETURN
END
C_CNT = C_CNT + 1
/* READ COPYBOOK */
ADDRESS TSO
"ALLOC FI(IFILE) DA('" || DSN || "') SHR"
'EXECIO * DISKR IFILE (STEM BOOK.'
'EXECIO 0 DISKR IFILE (FINIS'
'FREE F(IFILE)'
ADDRESS ISREDIT
/* PASTE COPYBOOK INTO PROGRAM SOURCE */
IF I < CURRLN THEN CURRLN = CURRLN + BOOK.0 /* COUNT new LINES */
LN = I
P = 1
D = +1
DO J = 1 TO BOOK.0
MARK = '|++++|'
TXT = SUBSTR(BOOK.J,7,66)
TXT = TRANSLATE(TXT,"'",'"') /* DOUBLE TO SINGLE QUOTE */
MSG = '"' || MARK || TXT || CPY || '"'
"ISREDIT LINE_AFTER " LN "= DATALINE" MSG
LN = LN + 1
END
LASTLN = LASTLN + BOOK.0 /* ADD COPYBOOK LINES */
RETURN
/* ------------------------------------------------------------ */
/*
|
If i give EX before the member name and if i provide DSN name then the above code expands all the copybooks in all programs.
Now my requirement is expand all the copybooks in 20k programs for some verification. If i try the above process it's taking lot of time and mainframe session is getting closed. So thought doing it in batch mode.
I tried below JCL. Job ran good but it's not invoking my rexx code.
JCL:
Code: |
//TSOBATCH EXEC PGM=IKJEFT01,DYNAMNBR=200
//SYSTSIN DD DUMMY
//MYINDD DD DISP=SHR,DSN=<PDS TO EXPAND THE PROGRAMS>
//SYSPRINT DD SYSOUT=*
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
EX 'REXX CODE PDS (PGM1)'
/*
|
I have modified PGM1 a bit as below and ran the another JCL now i'm getting some error while invoking MACROE
PGM1:
Code: |
/**REXX**/
TRACE ALL
ARG LIB
ADDRESS TSO
PDS1=STRIP(LIB)
PDS2 = "'"||PDS1||"'"
SAY PDS2
X = OUTTRAP('ML.')
"LISTDS "PDS2" MEMBERS"
X = OUTTRAP('OFF')
K = 1
J = 1
DO N = 7 TO ML.0
PARSE VAR ML.N MEMBER
MEM1=STRIP(MEMBER)
DSN1=PDS1||'('||MEM1||')'
ADDRESS ISPEXEC "EDIT DATASET('"DSN1"') MACRO(MACROE)"
END
EXIT
|
JCL:
Code: |
//STEP1 EXEC PGM=IKJEFT01,
// PARM=('%PGM1','PROGRAMS PDS')
//SYSEXEC DD DISP=SHR,DSN=<REXXPDS>
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD DUMMY
|
OUTPUT:
Code: |
17 *-* ADDRESS ISPEXEC "EDIT DATASET('"DSN1"') MACRO(MACROE)"
>>> "EDIT DATASET('PROGRAMS PDS(PROGRAM1)') MACRO(MACROE)"
+++ RC(-3) +++
|
Can someone please help to resolve the issue. |
|