Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 ejck thru rexx to multiple jobs insid... Susanta All Other Mainframe Topics 5 Tue Sep 19, 2017 1:39 pm
No new posts Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am
No new posts BUILD OUTFIL based on condition other... balaji81_k DFSORT/ICETOOL 13 Fri Sep 08, 2017 11:06 pm
No new posts PLI - printing from multiple programs Pedro PL/I & Assembler 8 Fri Sep 08, 2017 6:36 am
No new posts Skip file from delete pema_yozer All Other Mainframe Topics 3 Tue Aug 29, 2017 3:19 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us