Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Expanding a copybook called in cobol using clist
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
TAPAS PATEL

New User


Joined: 03 Apr 2009
Posts: 47
Location: CHENNAI

PostPosted: Thu Aug 20, 2009 4:20 pm    Post subject: Expanding a copybook called in cobol using clist
Reply with quote

Hello All,
I am trying to prepare a tool which can expand a copybook used in a cobol program,
This will help me a great deal in analysing the programs which have plenty of copybooks called in it.
I am planning to using clist language for this purpose. Please let me know if this is possible using CLIST.

Thanks,

Tapas Patel
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Aug 20, 2009 4:21 pm    Post subject:
Reply with quote

Probably is, but REXX would be a far far better language to use.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Thu Aug 20, 2009 4:23 pm    Post subject: Reply to: Expanding a copybook called in cobol using clist
Reply with quote

a yes/no question deserves a Yes/no answer...
YES if You have the skills, but

no reason to reinvent the wheel,
the issue has been debated quite a few times,
it would be more productive to use rexx
Back to top
View user's profile Send private message
TAPAS PATEL

New User


Joined: 03 Apr 2009
Posts: 47
Location: CHENNAI

PostPosted: Thu Aug 20, 2009 5:36 pm    Post subject: Reply to: Expanding a copybook called in cobol using clist
Reply with quote

Thanks for the response...I will try to accomplish this using REXX. Can you please advise me, if there is any functionality or utility in REXX that i can use for this purpose.
Back to top
View user's profile Send private message
d_pansare

New User


Joined: 25 Apr 2009
Posts: 20
Location: Pune

PostPosted: Thu Aug 20, 2009 5:44 pm    Post subject:
Reply with quote

You don't have to use any special functionality in REXX to do this.
You will need to write simple REXX program which will read whole Cobol program to Stem Variable.
Then read each line of COBOL and find out the copy book members.
Read the copybook member in another stem variable and then keep inserting copybook stemmed data to first one to get the third stem variable.
At the end you can write the third stem variable to temp file and view it on ISPF.

You need to know some basics of the REXX to write the code. Let the forum know if you are stuck on something.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Aug 20, 2009 5:48 pm    Post subject:
Reply with quote

d_pansare wrote:
You don't have to use any special functionality in REXX to do this.
You will need to write simple REXX program which will read whole Cobol program to Stem Variable.
Then read each line of COBOL and find out the copy book members.
Read the copybook member in another stem variable and then keep inserting copybook stemmed data to first one to get the third stem variable.
At the end you can write the third stem variable to temp file and view it on ISPF.

You need to know some basics of the REXX to write the code. Let the forum know if you are stuck on something.

Whoa back a minute !

You are making some assumptions here. What if a copybook includes another copybook. Once, or multiple times.

Without the full information it is rather risky to make the project spec.

TAPAS PATEL
Click HERE to see an almost identical topic that is currently active.

If the search button is inoperative, please let the moderators know.
Back to top
View user's profile Send private message
TAPAS PATEL

New User


Joined: 03 Apr 2009
Posts: 47
Location: CHENNAI

PostPosted: Fri Aug 21, 2009 9:33 am    Post subject: Reply to: Expanding a copybook called in cobol using clist
Reply with quote

Thanks everybody...
I actually searched in the forum before posting this query and also found that this topic had been/is being discussed,
but as I didn't find an exact answer to my question I posted the query...
Anyways I have started working on this tool and hope to complete it soon Thanks again!! icon_biggrin.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Fri Aug 21, 2009 12:53 pm    Post subject:
Reply with quote

Good Luck and keep us posted about your progress ... icon_smile.gif
Back to top
View user's profile Send private message
udaydara

New User


Joined: 08 Mar 2009
Posts: 10
Location: Hyderabad

PostPosted: Wed Dec 22, 2010 6:33 pm    Post subject: Reply to: Expanding a copybook called in cobol using clist
Reply with quote

Hello,

May I know the steps which you have followed for preparing this tool.
Back to top
View user's profile Send private message
Jeffrey Ranney

New User


Joined: 23 Dec 2010
Posts: 20
Location: USA

PostPosted: Tue Dec 28, 2010 2:40 am    Post subject:
Reply with quote

This should be a rather simple CLIST or REXX program.
Find the name of the COPYBOOK on a line of code, then open the copybook library and read it line by line inserting BEFORE the line after the COPY line in the code as MSGLINEs or NOTELINEs.
A RESET will then remove these lines from the source code.
If you have not yet figured this out, please reply and I will derive the source code for this. Happy Holidays !!
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Tue Dec 28, 2010 3:03 am    Post subject: Reply to: Expanding a copybook called in cobol using clist
Reply with quote

what about investigating the use of ISRLEMX
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ispzu270/6.4?ACTION=MATCHES&REQUEST=expand&TYPE=FUZZY&SHELF=ISPZPM70&DT=20080613002317&CASE=&searchTopic=TOPIC&searchText=TEXT&searchIndex=INDEX&rank=RANK&ScrollTOP=FIRSTHIT#FIRSTHIT
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu Dec 30, 2010 9:10 pm    Post subject:
Reply with quote

Try this:
Code:
/* REXX EDIT MACRO                                              */ 
/* EXPAND ALL COPY STATEMENTS IN A COBOL PROGRAM                */ 
ADDRESS ISREDIT                                                     
"MACRO PROCESS"                                                     
/* ============================================================ */ 
                                                                   
CPYLIB = "your.coybook.library"                               
C_CNT = 0                                                           
                                                                   
/* ------------------------------------------------------------ */ 
/* 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)                                           
   UPPER CMD                                                         
   if datatype(CMD) = 'NUM' then do                                   
      CMD = SUBWORD(LINE,3,1)                                         
      CPY = SUBWORD(LINE,4,1)                                         
   end                                                               
   IF CMD \= 'COPY' & CMD \= 'INCLUDE' THEN ITERATE                   
   CPY = STRIP(CPY,'L','&')                                           
   CPY = STRIP(CPY,'T','.')                                           
   CALL EXPAND_COPYBOOK                                               
END                                                                   
                                                                     
"UP MAX"                                                             
"DOWN " CURRLN                                                       
ZEDLMSG = 'Use the UNEC command to remove ' C_CNT ' expanded copybooks'
ADDRESS ISPEXEC "SETMSG MSG(ISRZ000)"                                 
                                                                     
EXIT 0                                                               
                                                                   
/* ------------------------------------------------------------ */ 
EXPAND_COPYBOOK:                                                   
   /* CHECK IF COPYBOOK EXISTS */                                   
   DSN = CPYLIB || "("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                                                 
   /* P = P + D          */                                           
   /* if P = 6 then do   */                                           
   /*    D = -1          */                                           
   /*    P = 4           */                                           
   /* end                */                                           
   /* if P = 1 then do   */                                           
   /*    D = +1          */                                           
   /*    P = 3           */                                           
   /* end                */                                           
      MARK = '|++++|'                                                 
   /* MARK= overlay('+',MARK,P,1) */                                 
   /* MARK= overlay('+',MARK,P,1) */                                   
      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                                                                 
/* ------------------------------------------------------------ */     
/* ============================================================ */     
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Thu Dec 30, 2010 9:13 pm    Post subject:
Reply with quote

In above code, I talk about UNEC command to remove the expanded copybooks - that is nothing but a combination of some edit-commands:

Code:
/* REXX EDIT MACRO                                              */
ADDRESS ISREDIT                                                   
"MACRO PROCESS"                                                   
"NUMB OFF"                                                       
"BOUNDS 1 80"                                                     
"RESET"                                                           
"X ALL"                                                           
"FIND ALL '|++++|' 1"                                             
"FIND ALL '|++++++|' 73"                                         
"DELETE ALL NX"                                                   
"RESET"                                                           
"UP MAX"                                                         
"BOUNDS"                                                         
EXIT 1                                                           
Back to top
View user's profile Send private message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Thu Jan 19, 2012 7:35 pm    Post subject: Reply to: Expanding a copybook called in cobol using clist
Reply with quote

Hi,

Could some one tell me where do I need to put data set library name where my COBOL program resides in mentioned REXX code?

Thanks
Neil
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1712
Location: UK

PostPosted: Thu Jan 19, 2012 8:47 pm    Post subject:
Reply with quote

It is an edit macro - you execute it when you are in the code (for goodness sake (because I see you have been here 7 years)!)
Back to top
View user's profile Send private message
Mickeydusaor

Active User


Joined: 24 May 2006
Posts: 258
Location: Salem, Oregon

PostPosted: Thu Jan 19, 2012 10:11 pm    Post subject:
Reply with quote

This is only going to work if your copy library members are in a PDS, if they are stored on Panvalet or Librarian this Rexx will not give what you want..
Back to top
View user's profile Send private message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Thu Jan 19, 2012 10:36 pm    Post subject: Reply to: Expanding a copybook called in cobol using clist
Reply with quote

Thanks Mick..

But still I am confused as my PDS name is NPUROCF.USER.COBOL(RPCNP050) and where do I need to place it?
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2019
Location: Silicon Valley

PostPosted: Thu Jan 19, 2012 11:14 pm    Post subject: Reply to: Expanding a copybook called in cobol using clist
Reply with quote

Quote:
you execute it when you are in the code


More specifically, while you are editing or viewing your cobol source, you type the name of the "EXPAND ALL COPY STATEMENTS" macro program and press Enter. It does not need to know the name of the cobol source library because you already specified it when you got into the editor.

But note that the "EXPAND ALL COPY STATEMENTS" macro contains this line, which you need to customize:
Code:
CPYLIB = "your.coybook.library"   

It assumes that the cobol source and the copybooks are in different libraries.

Quote:
still I am confused as my PDS name is NPUROCF.USER.COBOL(RPCNP050) and where do I need to place it?

You do not adequately explain what your PDS is... is it cobol source or the copybook?
Back to top
View user's profile Send private message
nileshyp

New User


Joined: 22 Jun 2005
Posts: 65
Location: Mumbai

PostPosted: Fri Jan 20, 2012 9:56 am    Post subject: Reply to: Expanding a copybook called in cobol using clist
Reply with quote

Hi Pedro,

My COBOL program resides in :- NPUROCF.USER.COBOL
My Copybook library is :- PVCCP.R2C.CPY

I have already mentioned CPYLIB = PVCCP.R2C.CPY

Now my question is where do I need to specify COBOL Program name (i.e. NPUROCF.USER.COBOL(RPCNP050))

Regards,
Neil
Back to top
View user's profile Send private message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 183
Location: Toronto, ON, Canada

PostPosted: Sun Jan 22, 2012 3:23 pm    Post subject:
Reply with quote

Another option is to run a compile on the program which will expand the program for you. Put the compile listing into a dataset. Then View the dataset and use the below macro on the listing. This will convert it back into COBOL code.
Code:
/*  REXX macro to convert COBOL compile listing into source code                                         
*/                                                     
                                                       
ADDRESS ISPEXEC "CONTROL ERRORS RETURN"                 
ADDRESS ISREDIT                                         
                                                       
"MACRO (PARM1)"                                         
IF RC <> 0 THEN DO                                     
  SAY 'ERROR:  not a view/edit session.  rc=' rc       
  EXIT                                                 
END                                                     
                                                       
"(state) = USER_STATE"                                 
                                                       
/* Find only line of cobol code and delete the rest */ 
"X ALL"                                                 
"F P'######' 4 ALL"                                     
"X '==>' 10 ALL"                                       
"DEL X ALL"                                             
                                                       
/* Blank out line labels */                             
"C P'¬' ' ' 19 24 ALL"                                 
                                                       
/* Shift all lines */                                   
"(LASTLN) = LINENUM .ZLAST"                             
DO I = 1 TO LASTLN                                     
  "SHIFT ( &I 18"                                       
END                                                     
                                                       
/* Strip lines to max 72 chars */                       
"(lrecl) = LRECL"                                       
"C P'¬' ' ' 73 &lrecl ALL"                             
                                                       
/* Restore session */                                   
"RESET"                                                 
"USER_STATE = (state)"                                 
"L 1"                                                   
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the code in CLIST to enable t... jackzhang75 CLIST & REXX 1 Fri Dec 02, 2016 3:02 am
No new posts How does a called pgm know if its cal... Graeme Westerman COBOL Programming 4 Tue Nov 29, 2016 9:25 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us