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
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Changeman get multiple "Browse C... elixir1986 Compuware & Other Tools 4 Fri Jul 14, 2017 1:48 am
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am


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