difference between of accessing vb and fb file in cobol program.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Sushil Vaidya
Registered Member
Posts: 15
Joined: Wed Dec 18, 2013 11:19 pm

difference between of accessing vb and fb file in cobol program.

Post by Sushil Vaidya »

Hi.

What is the difference between of accessing vb and fb file in cobol program?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: difference between of accessing vb and fb file in cobol program.

Post by Robert Sample »

There is no difference in accessing a VB and an FB file to COBOL. The VB data set must have some indication of the variable lengths -- either multiple 01 levels in the FD with different lengths, or an OCCURS DEPENDING ON in the FD 01 -- but otherwise they are accessed exactly the same. If OCCURS DEPENDING ON is used, then generally you have to be careful about moving into and out of WORKING-STORAGE because it is easy to get the wrong length and move too much data.
Sushil Vaidya
Registered Member
Posts: 15
Joined: Wed Dec 18, 2013 11:19 pm

Re: difference between of accessing vb and fb file in cobol program.

Post by Sushil Vaidya »

Thanks.

I was talking to one of my colleague and he said that FD entry for VB files will have RECORD IS VARYING FROM $ to $$$$.

Where $ and $$$$ represents the minimum and maximum length of records expected.

He also said that VB files will have 4 bytes of RDW. Record Descriptor Word. First two bytes of it tells the system the length of the being READ in every read. Is this correct also?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: difference between of accessing vb and fb file in cobol program.

Post by Robert Sample »

RECORD IS VARYING is another way to tell COBOL that the data set has variable length records -- multiple 01 levels in the FD and OCCURS DEPENDING ON are not the only two ways. I apologize if I gave that impression.

Yes, a variable length data set has 4 bytes of RDW at the front of each record that indicate how long the record is. HOWEVER, a COBOL programmer does NOT have access to the RDW -- you don't account for it in the COBOL program and you cannot use it for anything. If you put a RECORD IS VARYING or RECORD CONTAINS clause in the FD, you can have the system put the length of the record into a variable; if you do use one of these clauses, you also set the length of the record to write by moving the length into the variable.

Spanned records are another form of variable length records; in a spanned record, the RDW is replaced by the SDW (Segment Descriptor Word). The difference is that an RDW has 2 bytes of length and 2 bytes of binary zero while the SDW uses the second 2 bytes to indicate how the record is spanned (contained in the block, starts in the block but doesn't end, ends in the block but doesn't start, neither starts nor ends in the block).
Sushil Vaidya
Registered Member
Posts: 15
Joined: Wed Dec 18, 2013 11:19 pm

Re: difference between of accessing vb and fb file in cobol program.

Post by Sushil Vaidya »

Thanks Robert.

I had been reading about spanned records but one thing I could not understand that what practical situation makes you to have spanned-records? I mean, why do you need a span-record, can such situation not be handled by regular records, like FB?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: difference between of accessing vb and fb file in cobol program.

Post by Robert Sample »

I've only had to use spanned records once in my career, although I access them frequently (SMF records are spanned). The use of spanned records is indicated when the variable length portion of the record is large compared to the fixed length portion. IBM used to (and may still; I'm not sure) reserve bytes in the block sufficient to hold the largest possible record when writing records, so regular VB blocks could leave a lot of unused space. VBS blocks will not have more than 4 bytes of unused space since partial records will be used as needed. The application where I used spanned records involved a base length of 900 bytes but the variable portion was 22,500 bytes so the unused space in each block if VB could be near 23,400 bytes.
User avatar
ffiliricwilkins4
New Member
Posts: 1
Joined: Thu May 05, 2022 1:44 pm
Location: NYC USA

Re: difference between of accessing vb and fb file in cobol program.

Post by ffiliricwilkins4 »

interesting information
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.”