Take input file as FB and produce a different length records.

All sort of Mainframes Interview Questions.
Post Reply
HajiAmida
Registered Member
Posts: 10
Joined: Mon Dec 15, 2014 9:57 pm

Take input file as FB and produce a different length records.

Post by HajiAmida »

Hi,

I need help in this interview question:

If the input file have a fixed record length as 80. But output file should have records with different lengths. Output file should have first record of say length 100, second record of 75, third is of 80. How can we do it, write a pseudo code.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Take input file as FB and produce a different length records.

Post by Robert Sample »

You haven't provided enough information to even start any pseudocode. Questions you need to answer first include:
- How do you know how long each output record should be?
- Where do the extra bytes come from for records that are longer than the 80 byte input length?
- For shorter records, how do you create them -- chop off the front? chop off the back? extract specific bytes from different spots in the record?
- Are you expected to provide a solution using a particular language or utility?
- Is there a one-to-one match between input and output records? If not, what is the relationship?

The program would be a pretty simple one in COBOL -- one you know the answers to these questions.
HajiAmida
Registered Member
Posts: 10
Joined: Mon Dec 15, 2014 9:57 pm

Re: Take input file as FB and produce a different length records.

Post by HajiAmida »

- How do you know how long each output record should be?
Based on the input files' first two characters and then the characters at position 12-13.
- Where do the extra bytes come from for records that are longer than the 80 byte input length?
That is we are not sure at this moment. But for now we can fill in spaces.
- For shorter records, how do you create them -- chop off the front? chop off the back? extract specific bytes from different spots in the record?
Based on the different records type, we need to pick up records from different location from input file.
- Are you expected to provide a solution using a particular language or utility?
We are aiming to use COBOL.
- Is there a one-to-one match between input and output records? If not, what is the relationship?
I don't think that we can have a one-to-one match. But manually if we verify then we can identify from which input record the output record is created. Or can you suggest a way to verify the output based on the input?

Hope I answered all the questions.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Take input file as FB and produce a different length records.

Post by Robert Sample »

Your answers seem to indicate this is not an interview question, even though the first post mentioned that, and the post is in the Interview Questions part of the forum.
HajiAmida
Registered Member
Posts: 10
Joined: Mon Dec 15, 2014 9:57 pm

Re: Take input file as FB and produce a different length records.

Post by HajiAmida »

Based on the input files' first two characters and then the characters at position 12-13.
We are aiming to use COBOL.
These two are from the interview. Other questions I made up, not because I wanted to cheat but I wanted to learn more. I saw your replies on other posts and was sure that you can give a great help. I am sorry if I have done a wrong thing. :sorry: :(
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Take input file as FB and produce a different length records.

Post by Robert Sample »

The COBOL logic is straightforward: read a record, determine which output file it belongs in, create the output record, write it, and read another record until end of file.
HajiAmida
Registered Member
Posts: 10
Joined: Mon Dec 15, 2014 9:57 pm

Re: Take input file as FB and produce a different length records.

Post by HajiAmida »

Thanks for thelogic Robert.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Take input file as FB and produce a different length records.

Post by Robert Sample »

Glad to be of assistance.
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.”