View previous topic :: View next topic
|
Author |
Message |
suzeet
New User
Joined: 16 May 2005 Posts: 54
|
|
|
|
Recently someone has asked me, Why we read a file and write a record in Cobol? Can anybody put some light on this topic |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Hi suzeet,
Quote: |
Why we read a file and write a record in Cobol? |
It is something like why we code IDENTIFICATION DIVISION first.
It is simply because of Data Processing thru programming.
You write a File in order to get an output and since you may need an input for that you need to READ a file...
Please make ur question more clear...If I dont answer ur question....
Regards,
Priyesh. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Suzeet,
You write a record because variable length recs can be chosen, so you need a way to choose.
Reading a rec doesn't afford you that kind of choice. Usually the I/P recs are defined w/multiple 01 levels in the FD and each usually contains an id field. You just do a read of the file and then determine from the id what kind of rec you just read. |
|
Back to top |
|
|
Rameshs
New User
Joined: 15 Jun 2005 Posts: 53 Location: India, Chennai
|
|
|
|
Hai,
Can you give me an example for multiple 01 levels in FD entry
i couldn't able to understand what you are telling |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Rameshs,
Just define the file as you usually do (the FD). Define the rec as you usually do (01... 05... etc.). Then just define another 01, 05, etc., then another and another if you want to.
Each 01 will describe a different type of rec. One of the fields in each rec would define the rec-type.
If the file is fixed format all the defs would be of equal lengths. If variable format the defs would be of UNequal lengths.
You would READ the file and, depending on the rec-type, process the rec just read. If you defined multi def O/P recs you would select the appropriate rec to WRITE.
HTH |
|
Back to top |
|
|
suzeet
New User
Joined: 16 May 2005 Posts: 54
|
|
|
|
Priyesh,
I mean to say while reading we read a file not reading it record by record. While writing we write it record by record not write that file. I mean write <file-name> |
|
Back to top |
|
|
|