About copybooks



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

About copybooks

Postby VIJAY1 » Wed Oct 24, 2012 10:35 pm

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.
VIJAY1
 
Posts: 26
Joined: Sun Oct 21, 2012 2:49 pm
Has thanked: 3 times
Been thanked: 0 time

Re: About copybooks

Postby Robert Sample » Wed Oct 24, 2012 10:50 pm

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.

These users thanked the author Robert Sample for the post:
VIJAY1 (Wed Oct 24, 2012 10:58 pm)
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: About copybooks

Postby Pandora-Box » Wed Oct 24, 2012 10:53 pm

When you say conflict what is that you mean here?

If errors please post them

Based on your answers we could help you
User avatar
Pandora-Box
 
Posts: 65
Joined: Fri Feb 10, 2012 8:30 pm
Location: Mars
Has thanked: 3 times
Been thanked: 6 times

Re: About copybooks

Postby VIJAY1 » Wed Oct 24, 2012 11:13 pm

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...
VIJAY1
 
Posts: 26
Joined: Sun Oct 21, 2012 2:49 pm
Has thanked: 3 times
Been thanked: 0 time

Re: About copybooks

Postby Pandora-Box » Wed Oct 24, 2012 11:24 pm

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
User avatar
Pandora-Box
 
Posts: 65
Joined: Fri Feb 10, 2012 8:30 pm
Location: Mars
Has thanked: 3 times
Been thanked: 6 times

Re: About copybooks

Postby VIJAY1 » Wed Oct 24, 2012 11:41 pm

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..
VIJAY1
 
Posts: 26
Joined: Sun Oct 21, 2012 2:49 pm
Has thanked: 3 times
Been thanked: 0 time

Re: About copybooks

Postby Robert Sample » Wed Oct 24, 2012 11:49 pm

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>
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: About copybooks

Postby VIJAY1 » Thu Oct 25, 2012 12:02 am

Thank you Robert and premkrishnan. I got it now.:):)
Thanks alot ..
VIJAY1
 
Posts: 26
Joined: Sun Oct 21, 2012 2:49 pm
Has thanked: 3 times
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post