Converting FB to VB file and vice versa?

All sort of Mainframes Interview Questions.
Post Reply
User avatar
BobThomas
Registered Member
Posts: 70
Joined: Sat Jun 15, 2013 11:04 am

Converting FB to VB file and vice versa?

Post 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.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1885
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Converting FB to VB file and vice versa?

Post 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.
User avatar
BobThomas
Registered Member
Posts: 70
Joined: Sat Jun 15, 2013 11:04 am

Re: Converting FB to VB file and vice versa?

Post 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)?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1885
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Converting FB to VB file and vice versa?

Post 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.
User avatar
BobThomas
Registered Member
Posts: 70
Joined: Sat Jun 15, 2013 11:04 am

Re: Converting FB to VB file and vice versa?

Post by BobThomas »

Thanks Robert. Got it.

Appreciate your reply.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “Interview Questions.”