Page 1 of 1

Looping logic in reading COBOL programs dump

PostPosted: Thu Mar 31, 2011 12:10 am
by srikkanth.lovable
Folks,

I have a different requirement in which the program should read an input file which consists of hundreds to COBOL programs ( DUMP ). The loop should be written in such a way that the one single iteration is until it finds next IDENTIFICATION DIVISION in the dump file.

Hope iam clear..Pls advice

Re: Looping logic in reading COBOL programs dump

PostPosted: Thu Mar 31, 2011 12:23 am
by Robert Sample
What if the program has ID DIVISION instead of IDENTIFICATION DIVISION?

And what do you mean by "single iteration"? I don't think you've defined the requirements nearly enough to do anything, much less pose the question on this forum.

Re: Looping logic in reading COBOL programs dump

PostPosted: Thu Mar 31, 2011 12:47 am
by srikkanth.lovable
Thank you for response Robert.

I tell u . I need to read a dump file ( seris of cobol programs one after another ) and find corresponding prog id , copybooks and delgen in an output file.

For eg: C means copybook and D means DCLGEN
PROG1 COPY123 C
PROG1 DRCLAIMD D
PROG2 COPY345 C
PROG3 DRCLATT D
--------------
---------

Note: The copybook or dclgen in the dump file can start from any position from 8 and of any length ( 3 to 8 bytes)

Hope you got it.

Re: Looping logic in reading COBOL programs dump

PostPosted: Thu Mar 31, 2011 1:25 am
by enrico-sorichetti
where do You have issues, with the logic or with the coding ???

does not seem overly complicated ...
start reading
when You find a <identification division> save the program name
when You find a copy/include spit out the saved program name and the copybook name
keep reading

Re: Looping logic in reading COBOL programs dump

PostPosted: Thu Mar 31, 2011 2:51 am
by srikkanth.lovable
I mean the code...

Re: Looping logic in reading COBOL programs dump

PostPosted: Thu Mar 31, 2011 3:05 am
by BillyBoyo
You are able to read a file and write to a new file? So that is the basic part of your program.

Then you need to decide how to identify, from all the records you have read, which ones you want to process.

So, think how you would find the IDENTIFICATION DIVISION. As Robert pointed out, remember that you don't have to spell IDENTIFICATION, you can shorten it to ID (I always did, it makes the program look so much neater).

Generally there is a place you would expect to find this starting (I'm not doing the whole job for you). When you identify it, follow enrico's advice.

You have now provided a little more information on your copybook or dclgen. When you identify them, again follow enrico's advice.

So, how to find them. You have mentioned UNSTRING. OK, you should be able to get it to work. Look it up in the manual. Try to understand it. Try some examples. Make sure you know how it is handling "leading space" - the space at the start of each line. Then transfer the code idea to your reading/writing program.

It'll be a very, very, basic thing. Is this a training task? Or does it have some deeper purpose?