How to Create VB File in COBOL

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

Define VB File

Select inp-file-1  assign to DDname1
Select out-file-2 assign to DDname2  

This is output file we are creating as VB.

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.

Writing records to VB file

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

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

Related Posts

Author: Srini

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