Personally, I'd really prefer to have someone do a compile of the source,
using the ADATA compile parameter. Output the ADATA to a sequential data
set (or member of a PDS), then read that. The compiler has done 99.9% of
the hard work at this point.

ADATA reference:
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3PG50/APPENDIX1.7



On Fri, Mar 22, 2013 at 12:48 PM, Charles Mills <charl...@mcn.org> wrote:

> As one who has done it as part of a larger product, it is a bear.
>
> If you don't mind a few false positives, then just parsing for the word
> COPY and picking off the next token (as someone else wrote), and optionally
> OF ddname, will get you there.
>
> COBOL syntax is downright ugly, and doing it right is a bear. You have to
> consider:
>
> - Comments, as the other poster wrote.
> - String literals, with their goofy continuation rules.
> - Comment paragraphs -- those things like DATE-WRITTEN.
> - Maybe some other things -- I would have to look at my code to be sure.
>
> Rules are slightly different for older versions of COBOL.
>
> There is also EXEC-SQL INCLUDE which works similarly to COPY but is a
> different sequence.
>
> Oh, also BASIS ...
>
> Not sure if the Rexx stem variable approach will work -- I have seen COBOL
> programs of several hundred thousand lines. I guess that will be okay:
> 200,000 80-byte images is only 16 MB LOL.
>
> And sometimes a shop has programs that seem to be syntactically invalid
> but which nonetheless compile without error, and if you can't handle them,
> you're the bad guy, not the program, because "it's been this way for years
> and was never a problem, and anyway we don't have a budget to fix it, so
> you better fix your program."
>
> Charles
>
> -----Original Message-----
> From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On
> Behalf Of Ron Thomas
> Sent: Friday, March 22, 2013 10:08 AM
> To: IBM-MAIN@LISTSERV.UA.EDU
> Subject: Parsing cobol code for copybooks
>
> Hello. Could some one let us know how to create a process which extracts
> all copybooks from a program and looks in to the copybook library and check
>  if it exists ,  if exists  reads the copybook variables in the copybook
> and search in the program and writes the lines  which uses the variable to
> a output file.
>
> Please let us know how we can acheive the same?
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>



-- 
This is a test of the Emergency Broadcast System. If this had been an
actual emergency, do you really think we'd stick around to tell you?

Maranatha! <><
John McKown

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to