Read RDW Values of a VB file.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
BobP
Registered Member
Posts: 44
Joined: Mon Jun 17, 2013 1:33 pm

Read RDW Values of a VB file.

Post by BobP »

Hi,

I have file which is varuiable-blocked (VB) file. It's LRECL is 3000. In this, first record is of length is 100 bytes, 2nd, 5th record length is 300 bytes etc.

How to identify the length of the each Record in that VB file using COBOL? Is it possible to read the file using COBOL and get the record length? Can there be an alternate solution too?
Thanks,
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Read RDW Values of a VB file.

Post by William Collins »

Look at RECORD IS VARYING DEPENDING ON .... For reading, it the DEPENDING ON value will contain the record-length read.
criagk
New Member
Posts: 2
Joined: Wed Feb 04, 2015 2:56 pm

Re: Read RDW Values of a VB file.

Post by criagk »

Is not it more easy in a SORT JCL?
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Read RDW Values of a VB file.

Post by William Collins »

There are a couple of topics here on getting the record-length in SORT, so that would be an alternative.
BobP
Registered Member
Posts: 44
Joined: Mon Jun 17, 2013 1:33 pm

Re: Read RDW Values of a VB file.

Post by BobP »

Thanks William.

I have declared the FD section as,

Code: Select all

FD CUST-RECORD-IN 
DATA RECORD IS CUST-REC-IN 
RECORDING MODE IS V 
RECORD IS VARYING IN SIZE FROM 1 TO 2021 CHARACTERS 
DEPENDING ON CUST-RECORD-RDW. 
Each time I read the record, length of the record, is captured in CUST-RECORD-RDW.

Someone suggested that SSRANGE can also be s use in knowing the length of the records, how can that be possible, do you know?
Thanks,
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Read RDW Values of a VB file.

Post by William Collins »

I suggest you ask that someone how to use SSRANGE for that.

The above code gives you the length of each record as it is read. Why would you want to consider something which would obviously be more complex, more obscure, and wouldn't work (which you'd know, from reading the documentation of SSRANGE in the Programming Guide).
BobP
Registered Member
Posts: 44
Joined: Mon Jun 17, 2013 1:33 pm

Re: Read RDW Values of a VB file.

Post by BobP »

Thanks. SSRANGE can be used to chekc the array bounds, that's what I know but to use in this situation is a different matter and was surprised with this suggestion.
Thanks,
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: Read RDW Values of a VB file.

Post by William Collins »

Well, the suggestion by your someone was indeed nonsense :-)

SSRANGE doesn't check "array" bounds (even ignoring that COBOL doesn't have arrays, it has tables). SSRANGE simply ensures that the data-references resolved from subscripting or reference-modification is within the bounds of the table or field, respectively.

You could look at it as "bounds checking" for a one-dimensional table, but for a multi-dimensional table you can "bust" a subscript but still reference data within the table, without SSRANGE even squeaking.
BobP
Registered Member
Posts: 44
Joined: Mon Jun 17, 2013 1:33 pm

Re: Read RDW Values of a VB file.

Post by BobP »

William Collins wrote:Well, the suggestion by your someone was indeed nonsense :-)
My view on this is as yours, I agree! :D
Thanks,
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”