Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Invoke REXX thru JCL to expand the copybooks in programs

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
spizen556

New User


Joined: 02 Apr 2020
Posts: 14
Location: India

PostPosted: Sun Jul 26, 2020 3:53 pm    Post subject: Invoke REXX thru JCL to expand the copybooks in programs
Reply with quote

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.
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2378
Location: Hampshire, UK

PostPosted: Sun Jul 26, 2020 4:27 pm    Post subject: Reply to: Invoke REXX thru JCL to expand the copybooks in programs
Reply with quote

You are using ISPF services therefor you need to provide the ISPF datasets as has been often mentioned in these forums. Search.
Topic locked.
Back to top
View user's profile Send private message
enrico-sorichetti

Senior Member


Joined: 14 Mar 2007
Posts: 10697
Location: italy

PostPosted: Sun Jul 26, 2020 8:01 pm    Post subject: RE Invoke REXX thru JCL to expand the copybooks in programs
Reply with quote

the topic was locked before I could comment Merged it in for you Enrico

why in h**l people reinvent the wheel

I will not comment on the requirement

but what the TS wants is provided just writin the proper jcl by

Member expansion (ISRLEMX)

https://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.f54u200/membexp.htm


the link is for the foreground, let' s leave some work to the TS to find how to do it in batch
... yes, it can be done
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts CA Sysview - JCL or Rexx - Read or Ex... Jasi CA Products 4 Wed Aug 05, 2020 9:19 pm
No new posts Unable to scroll in REXX panel KeshavKunal CLIST & REXX 4 Tue Jul 21, 2020 3:55 pm
No new posts REXX tool to extract all files starti... KeshavKunal CLIST & REXX 4 Tue Jul 21, 2020 3:43 pm
No new posts IOF reading using REXX paval21 CLIST & REXX 0 Mon Jun 15, 2020 9:44 pm
No new posts Need to open a DSN using REXX & e... Y Marwaha CLIST & REXX 10 Fri Jun 05, 2020 7:30 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us