Take input file as FB and produce a different length records.
Take input file as FB and produce a different length records.
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.
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.
- Robert Sample
- Global Moderator
- Posts: 1899
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Take input file as FB and produce a different length records.
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.
- 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.
Re: Take input file as FB and produce a different length records.
Based on the input files' first two characters and then the characters at position 12-13.- How do you know how long each output record should be?
That is we are not sure at this moment. But for now we can fill in spaces.- Where do the extra bytes come from for records that are longer than the 80 byte input length?
Based on the different records type, we need to pick up records from different location from input file.- 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?
We are aiming to use COBOL.- Are you expected to provide a solution using a particular language or utility?
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?- Is there a one-to-one match between input and output records? If not, what is the relationship?
Hope I answered all the questions.
- Robert Sample
- Global Moderator
- Posts: 1899
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Take input file as FB and produce a different length records.
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.
Re: Take input file as FB and produce a different length records.
Based on the input files' first two characters and then the characters at position 12-13.
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.We are aiming to use COBOL.
- Robert Sample
- Global Moderator
- Posts: 1899
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Take input file as FB and produce a different length records.
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.
- Robert Sample
- Global Moderator
- Posts: 1899
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
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