IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Pointer towards Record Descriptor Word(RDW) used in file.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abinash_mohapatra

New User


Joined: 28 Mar 2005
Posts: 7
Location: Bangalore

PostPosted: Mon Apr 25, 2005 6:59 pm
Reply with quote

Hi All

Please give me a pointer towards RDW used in Variable length record. I want to know the actual definition of RDW. It would be great if u could give me reference. Also i want to know the details about the processing of variable length record.

Thanking you in anticipation,.

Regards
Abinash
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Apr 26, 2005 6:06 am
Reply with quote

Hi Abinash,

It's difficult to find all the info needed to process variable files in COBOL. I put the following together to answer that need.

The usual caveats and copouts apply.

I've encountered two situations when attempting to process IBM's variable length records. Here's a description of the methods I use in each of those situations. This may also be valid for non-IBM environments.

1) Don't know the lengths of the recs in the file. (Use Method 1 below.)

2) Can identify each variable rec that you read by knowing the rec type field value of each rec. (Use Method 2.)


Method 1.

In your FD
Code:

 RECORD VARYING FROM 1 TO max len expected
               DEPENDING ON WS-REC-LEN

If you don't know the max len use 32K.

Define the FD 01 as:
Code:

01 IP-REC.
   05 NBR-OF-BYTES PIC X
                   OCCURS FROM 1 TO nn DEPENDING ON WS-REC-LEN.

where, nn = max len expected used in VARYING stmt,
WS-REC-LEN is an unsigned numeric data item large enough to hold "max len expected".

When you read an IP rec, the length of the rec just read will appear in
WS-REC-LEN.

If you decide to write the rec to an OP file it is your responsibility to populate that field with the appropriate length. If you decide to expand or reduce the size of the rec before you write it, you must first adjust the WS-REC-LEN field accordingly.


Method 2.

In the FD
Code:

 RECORD CONTAINS FROM 1 TO max len expected.

If you don't know the max len use 32K.

Define the FD 01 for as many types of recs as you have, e.g.:
(These could also be copybooks.)
Code:

01 IP-REC-1.
   05 REC-TYPE-1 PIC X.
   05 yada, yada, yada
01 IP-REC-2.
   05 REC-TYPE-2 PIC X.
   05 yada, yada, yada
01 yada, yada, yada
.
.
.

In the PD:
Code:

READ IP-FILE
IF REC-TYPE-1 = '1'
   do stuff only using IP-REC-1 datanames
   WRITE OP=REC-1 FROM IP-REC-1
END-IF 
IF REC-TYPE-2 = '2'
   do stuff only using IP-REC-2 datanames
   WRITE OP-REC-2 FROM IP-REC-2
END-IF
etc.

Note that you write the record, not the file.

Also, although I chose to make the rec type PIC X, it could be anything, so long as there is agreement that a given value will always reference a rec of a predetermined length and content.



If you need to update the file and create a new variable OP file
create an OP FD similar to that above. You can use the same copybook or you can create another rec description.

JCL Notes:

Variable recs are built by the access method in 2 parts: control data and user data.
The control data is composed of a 4 byte Block Descriptor Word (BDW) and a 4 byte Record Descriptor Word (RDW). In each the 1st 2 bytes contain a binary representation of the length.

So, when coding the LRECL and BLKSIZE add 4 or 8 bytes respectively to the longest area expected for your data.

Note that in the COBOL pgm you state the data area sizes only. The BDWs & RDWs are not considered in the pgm.

While I'm on the subject of data length, you can always specify a rec or block length LARGER than the ACTUAL largest rec/block in the file. Just make sure that the BLKSIZE is 4 bytes longer than the LRECL. The only downside is that you waste buffer space. This shouldn't present a hardship, but the technique is handy in those situations where you may not know the exact file attributes.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top