View previous topic :: View next topic
|
Author |
Message |
TAPAS PATEL
New User
Joined: 03 Apr 2009 Posts: 47 Location: CHENNAI
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Probably is, but REXX would be a far far better language to use. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
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 |
|
|
TAPAS PATEL
New User
Joined: 03 Apr 2009 Posts: 47 Location: CHENNAI
|
|
|
|
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 |
|
|
d_pansare
New User
Joined: 25 Apr 2009 Posts: 20 Location: Pune
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
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 |
|
|
TAPAS PATEL
New User
Joined: 03 Apr 2009 Posts: 47 Location: CHENNAI
|
|
|
|
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!! |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Good Luck and keep us posted about your progress ... |
|
Back to top |
|
|
udaydara
New User
Joined: 08 Mar 2009 Posts: 10 Location: Hyderabad
|
|
|
|
Hello,
May I know the steps which you have followed for preparing this tool. |
|
Back to top |
|
|
Jeffrey Ranney
New User
Joined: 23 Dec 2010 Posts: 20 Location: USA
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
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 |
|
|
nileshyp
New User
Joined: 22 Jun 2005 Posts: 65 Location: Mumbai
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
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 |
|
|
Mickeydusaor
Active User
Joined: 24 May 2006 Posts: 258 Location: Salem, Oregon
|
|
|
|
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 |
|
|
nileshyp
New User
Joined: 22 Jun 2005 Posts: 65 Location: Mumbai
|
|
|
|
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 |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2593 Location: Silicon Valley
|
|
|
|
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 |
|
|
nileshyp
New User
Joined: 22 Jun 2005 Posts: 65 Location: Mumbai
|
|
|
|
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 |
|
|
jerryte
Active User
Joined: 29 Oct 2010 Posts: 202 Location: Toronto, ON, Canada
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
nileshyp wrote: |
Now my question is where do I need to specify COBOL Program name (i.e. NPUROCF.USER.COBOL(RPCNP050)) |
Well, I have already told you this. It is an edit macro which means that you have to be editing (or viewing) the program source and you type the macro name on the command line and press enter. The actions it takes will be against the source code you are viewing. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2593 Location: Silicon Valley
|
|
|
|
Quote: |
Now my question is where do I need to specify COBOL Program name |
Expanding on Nic's response: specify the dataset name in panel ISREDM01. |
|
Back to top |
|
|
|