View previous topic :: View next topic
|
Author |
Message |
amoljoshi
New User
Joined: 30 Aug 2006 Posts: 3
|
|
|
|
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 |
|
|
shreevamsi
Active User
Joined: 23 Feb 2006 Posts: 305 Location: Hyderabad,India
|
|
|
|
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 |
|
|
chandramouli.v
New User
Joined: 21 Mar 2005 Posts: 12
|
|
|
|
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 |
|
|
amoljoshi
New User
Joined: 30 Aug 2006 Posts: 3
|
|
|
|
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 |
|
|
shreevamsi
Active User
Joined: 23 Feb 2006 Posts: 305 Location: Hyderabad,India
|
|
|
|
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 |
|
|
amoljoshi
New User
Joined: 30 Aug 2006 Posts: 3
|
|
|
|
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 |
|
|
|