Page 1 of 1

Parsing COBOL program

PostPosted: Mon Mar 28, 2011 2:03 pm
by srikkanth.lovable
Friends,

Could you please help me in writing a code snippet of the below requirement:

The COBOL program need to read an Input file ( Input file contains a COBOL program) and output file should write the following

Program_id Copybook/ DCLGEN


For Example :
INPUT FILE CONTAINS :

IDENTIFICATION DIVISION.
PROGRAM ID. SAMPLE01.
---------------------
--------------
COPY <XYZ123>
COPY <ABC123>
--------
----


EXEC SQL
INCLUDE <PQRST>
END-SQL

---------
-------


OUTPUT SHOULD BE

OUTPUT

PROGRAM-ID COPYBOOK
SAMPLE01 XYZ123
SAMPLE01 ABC123
SAMPLE01 PQRST

Please advice.

Re: Parsing COBOL program

PostPosted: Mon Mar 28, 2011 3:17 pm
by enrico-sorichetti
cobol might not be the best language for source program <parsing>
also no need to reinvent the wheel
check the ISPF application "member parts list" ( option 4.12 or 5.12 )

Re: Parsing COBOL program

PostPosted: Mon Mar 28, 2011 3:58 pm
by BillyBoyo
Do you need this for an interview?

Is it a Cobol learnign exercise? If so, there is a Cobol forum. What thoughts do you have about it yourself? Write out in your language for yourself what you think you'd need to do. Then think about how you might do that in Cobol. Then if there is something which you don't understand/doesn't work, come back and explain. You might find helpful bits and pieces if you search the Cobol forum.

If not an exercise in Cobol, take note of enrico's comments.