Page 1 of 1

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

Posted: Tue Dec 22, 2015 10:57 am
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.

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

Posted: Tue Dec 22, 2015 8:00 pm
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.

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

Posted: Mon Dec 28, 2015 1:56 pm
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.

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

Posted: Mon Dec 28, 2015 6:46 pm
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.

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

Posted: Wed Dec 30, 2015 11:15 am
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: :(

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

Posted: Wed Dec 30, 2015 6:37 pm
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.

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

Posted: Tue Jan 12, 2016 11:33 am
by HajiAmida
Thanks for thelogic Robert.

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

Posted: Tue Jan 12, 2016 6:18 pm
by Robert Sample
Glad to be of assistance.