---
title: "How to Create VB File in COBOL"
description: "One of the best method to create VB files in COBOL. Really good stuff to and highly useful for all COBOL programmers."
url: https://srinimf.com/2012/07/08/cobol-how-to-create-vb-file/
date: 2012-07-08
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2012/07/vb-files-cobol.jpg?fit=1200%2C700&ssl=1
categories: ["COBOL"]
tags: ["COBOL Tips and Tricks", "Logic to write COBOL VB FIle"]
type: post
lang: en
---

# 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](https://srinimf.com/2017/04/12/the-best-5-cics-proven-tips-that-unloacked-now/) Cobol program.

Related[Exclusive CICS EIBCALEN and DFHCOMMAREA](https://srinimf.com/2012/05/31/cics-eibcalen-receivedfhcommarea/)

## 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](https://srinimf.com/2012/03/12/cobol-release-and-return-in-sort/) 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](https://srinimf.com/2012/03/29/cobol-arrays-variable-files/) mainframe COBOL.

Related Posts

- [COBOL VB Files – Top Interview Questions](https://srinimf.com/2015/02/04/cobol-tough-interview-questions-on-vb-files/)DateFebruary 4, 2015
- [How to Create VB file Using Varying Clause in COBOL](https://srinimf.com/2010/09/02/cobol-variable-recordvb-files/)DateSeptember 2, 2010
- [COBOL: How to Create a VB Array](https://srinimf.com/2020/04/26/cobol-how-to-create-a-vb-array/)DateApril 26, 2020

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2012%2F07%2F08%2Fcobol-how-to-create-vb-file%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2012%2F07%2Fvb-files-cobol.jpg%3Ffit%3D1200%252C700%26ssl%3D1&description=How%20to%20Create%20VB%20File%20in%20COBOL)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2012/07/08/cobol-how-to-create-vb-file/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2012/07/08/cobol-how-to-create-vb-file/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2012/07/08/cobol-how-to-create-vb-file/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2012/07/08/cobol-how-to-create-vb-file/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20How%20to%20Create%20VB%20File%20in%20COBOL&body=https%3A%2F%2Fsrinimf.com%2F2012%2F07%2F08%2Fcobol-how-to-create-vb-file%2F&share=email)
-

### Like this:

Like Loading…