Page 1 of 1

Read 4 byte field in Variable Block File

PostPosted: Wed Jul 11, 2012 11:06 pm
by priyanshu90
For a variable block file we have first four bytes for the Record length. How can we move that 4 byte field in a variable in our program?

Re: Read 4 byte field in Variable Block File

PostPosted: Wed Jul 11, 2012 11:40 pm
by Robert Sample
The FIRST question is, why would you want to do that?

Second, the record descripter word (RDW) is not part of a COBOL program as it is controlled by the operating system.

Thrid, you can get the record length by using the RECORD VARYING clause in the FD description for the file, which gives you the same thing as if you accessed the RDW.

Re: Read 4 byte field in Variable Block File

PostPosted: Thu Jul 12, 2012 12:02 am
by dick scherrer
Hello and welcome to the forum,

What you are tryiing to do probably should not be done. . .

If you explain why you believe this is needed, someone may have a suggestion.

Re: Read 4 byte field in Variable Block File

PostPosted: Thu Jul 12, 2012 12:49 am
by priyanshu90
dick scherrer wrote:Hello and welcome to the forum,

What you are tryiing to do probably should not be done. . .

If you explain why you believe this is needed, someone may have a suggestion.

Normally for a variable block file there is always a field in the copybook for that file which has the length stored for each record. However in this case the field is blank and does not contain any value..This is why i need to use those 4 bytes

Re: Read 4 byte field in Variable Block File

PostPosted: Thu Jul 12, 2012 1:07 am
by Akatsukami
priyanshu90 wrote:
dick scherrer wrote:Hello and welcome to the forum,

What you are tryiing to do probably should not be done. . .

If you explain why you believe this is needed, someone may have a suggestion.

Normally for a variable block file there is always a field in the copybook for that file which has the length stored for each record. However in this case the field is blank and does not contain any value..This is why i need to use those 4 bytes

Note that this is a case where obsessing on the wrong question leads to the wrong answer being given. As Mr. Sample writes:
you can get the record length by using the RECORD VARYING clause in the FD description for the file, which gives you the same thing as if you accessed the RDW

Re: Read 4 byte field in Variable Block File

PostPosted: Thu Jul 12, 2012 9:30 am
by Anuj Dhawan
As an Application Programmer, you never need to bother about the contents of RDW. By any chance are you talking about to determine the "length of contents" in some COBOL variable read in to from a VB file?

Re: Read 4 byte field in Variable Block File

PostPosted: Thu Jul 12, 2012 2:49 pm
by priyanshu90
Anuj Dhawan wrote:As an Application Programmer, you never need to bother about the contents of RDW. By any chance are you talking about to determine the "length of contents" in some COBOL variable read in to from a VB file?


Yes I am

Re: Read 4 byte field in Variable Block File

PostPosted: Thu Jul 12, 2012 4:50 pm
by Robert Sample
If used on an input file, the RECORD VARYING clause sets the variable to the length of each record when a READ is done. If used on an output file, you must set the length before doing the WRITE.

In other words, you do not need to access the RDW since the RECORD VARYING clause gives you the exact same data in a COBOL way.

Re: Read 4 byte field in Variable Block File

PostPosted: Thu Jul 12, 2012 6:14 pm
by Anuj Dhawan
I'm bit confused now and afraid if OP is talking about this: :?

01  TEXT1           PIC X(40) VALUE 'THIS IS THE STRING'.


INSPECT FUNCTION REVERSE(TEXT1) TALLYING L FOR LEADING SPACES
COMPUTE L = LENGTH OF TEXT1 - L

Re: Read 4 byte field in Variable Block File

PostPosted: Thu Jul 12, 2012 7:17 pm
by priyanshu90
The RECORD VARYING CLAUSE gave me the desired result..Thanks Guys :)