View previous topic :: View next topic
|
Author |
Message |
ganeshprasanna
New User
Joined: 21 Feb 2009 Posts: 36 Location: South Portland, Maine
|
|
|
|
Hi,
I have a Variable record length ESDS whose length may vary from 1 to 1300. Now i need to read the file sequentially in Cobol(batch program). After reading the record, depending on the some condition i write the same record to another file(length same as input record) or change a field(change the length) and then write to another ESDS file. How can i achieve this? Can i know the Record length of each record read using RBA?
Ganesh |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
How can i achieve this? Can i know the Record length of each record read using RBA? |
I don't know of any way in COBOL to know this -- you don't really have access to the RBA in COBOL.
But, you don't need it. Go to the manuals link at the top of the page, find the COBOL Language Reference manual, and read section 5.2.5.3 on the RECORD CONTAINS clause of the FILE SECTION. When this is used, COBOL will set a numeric variable to have the length of each record as you read it. This works for sequential as well as VSAM file, so there's no reference to the RBA required. It also works for output files.
Sometimes you limit your responses by attempting to restrict things too much in the problem statement. If you have to know the RBA, you cannot do what you want in COBOL If you don't care about the RBA but just want the record length, it can easily be done. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
If 'am not mistaken, this
Quote: |
After reading the record, depending on the some condition i write the same record to another file(length same as input record) or change a field(change the length) and then write to another ESDS file. |
is your problem statement. If yes, why at all RBA is a concern here? |
|
Back to top |
|
|
ganeshprasanna
New User
Joined: 21 Feb 2009 Posts: 36 Location: South Portland, Maine
|
|
|
|
Thanks Robert & Anuj.
My concern is with respect to the file structure, as the record may have any of the many defined variable layouts(there are 26 layouts a record might fit into). Is there a way by which i just have to write the input to output file without moving to any of the layouts?
ex: Record 1 -> Can be of layout 3(record length = 123)
Record 2 -> Can be of layout 5(record length = 234)
Now, can i write these records to output file without moving it into any file record layouts, but keeping the record length same in the output?. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Use the RECORD CONTAINS clause on both input and output file, set the output file length from the input file length, and write the record of the correct length. You don't need to define each possible layout -- use an 01 that has an 05 with OCCURS DEPENDING ON so the correct record length is used. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If your file is variable length but the data is in multiple fixed format records, i suspect there is some record-id or layout-code in each record.
The programs that currently process this data probably use this to determine which part of the code to execute.
Suggest you do the same in this program. It this requires 26 output formats, so be it. If the records do not already use ODO (Occurs Depending On), you may add confusion.
So far, there has not been a very clear description of just what is needed. . .
It may also be that i'm just slower than usual today |
|
Back to top |
|
|
|