Page 1 of 1
difference between of accessing vb and fb file in cobol program.
Posted: Sun Aug 26, 2018 9:09 am
by Sushil Vaidya
Hi.
What is the difference between of accessing vb and fb file in cobol program?
Re: difference between of accessing vb and fb file in cobol program.
Posted: Sun Aug 26, 2018 11:25 am
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.
Re: difference between of accessing vb and fb file in cobol program.
Posted: Sun Aug 26, 2018 6:30 pm
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?
Re: difference between of accessing vb and fb file in cobol program.
Posted: Sun Aug 26, 2018 6:42 pm
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).
Re: difference between of accessing vb and fb file in cobol program.
Posted: Sun Mar 06, 2022 9:25 am
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?
Re: difference between of accessing vb and fb file in cobol program.
Posted: Mon Mar 07, 2022 1:59 am
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.
Re: difference between of accessing vb and fb file in cobol program.
Posted: Thu May 05, 2022 1:47 pm
by ffiliricwilkins4
interesting information