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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Pointer towards Record Descriptor Word(RDW) used in file.
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    Post subject:
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    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 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 generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm


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