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

reading multiple file layouts in one FD


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
amoljoshi

New User


Joined: 30 Aug 2006
Posts: 3

PostPosted: Wed Aug 30, 2006 11:57 am
Reply with quote

Hi,

I have a requirement in which my COBOL program should be able to read files with different record lengths in the same DD statement. i.e. the program should be able to read any file which I give as input. Normally this is not allowed as we need to specify a FD clause with the record length of the input file. In this case , the record length of the input file can differ from one file to the other. Still my program is supposed to handle this. Is there any way of achieving this in COBOL?

Many thanks,
Amol
Back to top
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Wed Aug 30, 2006 1:37 pm
Reply with quote

hi amol,

Yes, You can declare different record layout under single FD. Like

FD INPUT-FILE
.
.
.
.

01 IN-FIRST-REC PIC X(100)
.
.
.
01 IN-SECOND-REC PIC X(800)
.
..
01 IN-THIRD-REC PIC X(500)
.
.


You can use any of the layout described in the FD based in the type of record you are currently reading.

For example : A file having one Header, Multiple Detail Line and One Footer at the End..

Clear??

~Vamsi
Back to top
View user's profile Send private message
chandramouli.v

New User


Joined: 21 Mar 2005
Posts: 12

PostPosted: Wed Aug 30, 2006 2:05 pm
Reply with quote

Hi Amol,

As described by shree vamsi we can provide different record layouts under single FD.

FD FILE1.
01 REC1 PIC X(50).
01 REC2 PIC X(70).
01 REC3 PIC X(80).

If the i/p file is Variable then the above layout will do with diff layouts.
If the i/p file is Fixed length then all the record must be of same size the above declaration wont accept.

Regards,
Chandramouli.V
Back to top
View user's profile Send private message
amoljoshi

New User


Joined: 30 Aug 2006
Posts: 3

PostPosted: Wed Aug 30, 2006 2:07 pm
Reply with quote

vamsi,

thanks for replying.

My problem is that I wouldnt be knowing the record lengths of the input files . If I knew the different lrecls then I would have coded them as mentioned by you. My program should be able to handle ANY lrecl which I feed in to it. Any suggestions?

Amol
Back to top
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Wed Aug 30, 2006 3:06 pm
Reply with quote

If input file is of Variable lenght(FORMAT=VB), then all the possible record lenghts need to be declared.
If format = FB, and don't know LRECL, Then you can't handle in the length of FD dynamically.

~Vamsi
Back to top
View user's profile Send private message
amoljoshi

New User


Joined: 30 Aug 2006
Posts: 3

PostPosted: Wed Aug 30, 2006 3:27 pm
Reply with quote

Vamsi.

Thanks.

That's what I thought. It would have been great if I could dynamically build the FD clause at runtime, depending upon the length of the input file, but as you mention, it isnt allowed.

Amol
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top