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:[email protected]] On Behalf Of Ron Thomas Sent: Friday, March 22, 2013 10:08 AM To: [email protected] 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 [email protected] with the message: INFO IBM-MAIN
