How to Create VB File in COBOL

Creating Variable file (VB) is very common in production with COBOL. Just few things we need to take care while writing a Cobol program.

Select inp-file-1  assign to DDname1
Select out-file-2 assign to DDname2     ===> This is output file we are creating as VB
COBOL for advanced learners
COBOL for advanced learners

In the file section:

FILE SECTION.
 FD  Out-file-2

    RECORD IS VARYING IN SIZE
               FROM integer-1 TO integer-2
               DEPENDING ON data-nm-1.

01 Vb-rec    PIC  X(2000).
01  minimum-size.
     05  minimum-sized-element     PIC X(integer-1).
01  maximum-size.
     05  maximum-sized-element     PIC X(integer-2).
·
·
·

WORKING-STORAGE SECTION.
 77  data-nm-1                   PIC 9(5).

·
·
·

The next step is in the procedure division, when you want to write a record, you also need to move value I.E.

Move +100 to data-nm-1. 
write  reco-1 into Vb-rec.

This way you write records into VB file. This is also a powerful method to create VB files in mainframe COBOL.

Advertisements

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.