Page 1 of 1

Converting FB to VB file and vice versa?

Posted: Sun Feb 16, 2014 2:24 am
by BobThomas
Hi,

How to convert a FB file to a VB file in COBOL.This was asked in one of the interview. I'm not sure how to do it. Can some one please assist.

Re: Converting FB to VB file and vice versa?

Posted: Sun Feb 16, 2014 3:04 am
by Robert Sample
You'll need two files, one FB input and one VB output file. IIRC, you will need to use RECORD CONTAINS in your FD and specify the record length for each record before the WRITE statement or you'll just get another FB file on output, even though your code indicates VB.

Re: Converting FB to VB file and vice versa?

Posted: Sun Feb 16, 2014 8:58 pm
by BobThomas
Thanks Robert. But how do we instruct COBOL about RDW, as you said writing length - but what is the syntax?

WRITE WS-LENGTH? Where WS-LENGTH is defined as COMP S9(4)?

Re: Converting FB to VB file and vice versa?

Posted: Sun Feb 16, 2014 11:09 pm
by Robert Sample
You cannot directly use the RDW. However, if you specify

Code: Select all

RECORD VARYING FROM <low> TO <high> CHARACTERS DEPENDING ON <ws-variable> 
you can then move the record length to <ws-variable> before doing the WRITE and the RDW value will be taken from <ws-variable>. You still need OCCURS DEPENDING ON or multiple 01 definitions with different lengths in your FD, however.

Re: Converting FB to VB file and vice versa?

Posted: Tue Feb 18, 2014 9:11 am
by BobThomas
Thanks Robert. Got it.

Appreciate your reply.