IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Read File & Write Record


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
suzeet

New User


Joined: 16 May 2005
Posts: 54

PostPosted: Mon Jul 25, 2005 5:24 pm
Reply with quote

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
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Mon Jul 25, 2005 5:57 pm
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Jul 26, 2005 6:46 am
Reply with quote

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
View user's profile Send private message
Rameshs

New User


Joined: 15 Jun 2005
Posts: 53
Location: India, Chennai

PostPosted: Tue Jul 26, 2005 10:29 am
Reply with quote

Hai,

icon_confused.gif 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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Jul 27, 2005 5:47 am
Reply with quote

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
View user's profile Send private message
suzeet

New User


Joined: 16 May 2005
Posts: 54

PostPosted: Wed Jul 27, 2005 11:07 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Error to read log with rexx CLIST & REXX 11
Search our Forums:

Back to Top