Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

reading multiple file layouts in one FD

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: reading multiple file layouts in one FD
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    Post subject:
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    Post subject: Re: reading multiple file layouts in one FD
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    Post subject: Re: reading multiple file layouts in one FD
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    Post subject:
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    Post subject: Re: reading multiple file layouts in one FD
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us