Page 1 of 1

About copybooks

PostPosted: Wed Oct 24, 2012 10:35 pm
by VIJAY1
I was given an assignment to use copy book in my program.
The job is to separate records in a file based on a field from single file to 3 different files.
If i use single copy book for all the files ,i get conflicts while writing.
so,should i use diferent copy books .
or is there a method to use a single copy book for all the files.
Thanks in advance.

Re: About copybooks

PostPosted: Wed Oct 24, 2012 10:50 pm
by Robert Sample
Use the copybook in WORKING-STORAGE and use WRITE ... FROM for the three files; there is no problem in COBOL with writing different file record from the same WORKING-STORAGE variable.

Re: About copybooks

PostPosted: Wed Oct 24, 2012 10:53 pm
by Pandora-Box
When you say conflict what is that you mean here?

If errors please post them

Based on your answers we could help you

Re: About copybooks

PostPosted: Wed Oct 24, 2012 11:13 pm
by VIJAY1
when i write WRITE...FROM the source-file..I am not sure about how to reference the desired file since i am using single copy book......
that is what i meant by conflict...

Re: About copybooks

PostPosted: Wed Oct 24, 2012 11:24 pm
by Pandora-Box
Anyway you will be able to discrete the output files

WRITE OUT1 FROM INP
WRITE OUT2 FROM INP and so on

Ofcourse as you said you need a EVALUATE logic to filter based on condition

Re: About copybooks

PostPosted: Wed Oct 24, 2012 11:41 pm
by VIJAY1
Till now i was specifying the 01 rec also in copy book.. is there a way where i can put that in my cobol program and fields alone in copy book.,.
I am a beginner.and i googled at lot but found nothing useful.Help me please..

Re: About copybooks

PostPosted: Wed Oct 24, 2012 11:49 pm
by Robert Sample
If you do NOT place the 01-level variable in the copy book, you can specify the 01-level variable name under each FD and then use COPY. As long as the 01-level variable names are unique, COBOL allows you use the same variable names at lower levels by referencing them as
<variable> IN <01-level variable>

Re: About copybooks

PostPosted: Thu Oct 25, 2012 12:02 am
by VIJAY1
Thank you Robert and premkrishnan. I got it now.:):)
Thanks alot ..