We are having a requirement that we need to create an interface file with different sections as follows. File Header, Data Header, Data Details and Footer. Each record is of variable length. But the information should follow the same format such as File Header should be first record then followed by data header and data details. Data Header and Data details will be repeated for many transactions. Last record will be footer record. The output should be in CSV format. As the information has variable length records, I created a flat file and using data structure I defied the comma as delimiter and FTP the file. But the output has blanks in the field when the value is not completely filled the field length. Is there any way that I can remove the blanks in the field or there is a better way to create the output file.
Sample of the CSV file is as follows.
I come across this problem about a week ago. I needed to put Report Heading on first line, date time on second line and columns heading on third line. I just made a flat file write three records from Datastructures in RPG. Then in CL I write two CPYTOIMPF commands first for this flat file and second for the Physical File. Remember to change parameter MBROPT(*REPLACE) for flat file and MBROPT(*Add) for physical file. The output will be a single file with all information
Thanks for all your replies. Regarding using BIF, I have fields with numeric and non numeric, hence concat not possible. I don't have multiple physical files to use CPYTOIMPF. As it is a fixed length file there is no way I can use CPYTOIMPF.
What is your interface looking for in the format? If the blanks are stripped out, is the data left or right justified? What if the field is like a mini data structure containing flags? You may want to keep the blanks in the file. Are they causing a problem withe the interface or is this just to make the file more readable?
Your best bet may be to define a flat record format for each record type. The using the BIF mention in this post concatenate them together. This would eliminate any spacing.
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!
Discuss This Question: 9  Replies
Thanks for all your replies. Regarding using BIF, I have fields with numeric and non numeric, hence concat not possible. I don't have multiple physical files to use CPYTOIMPF. As it is a fixed length file there is no way I can use CPYTOIMPF.
Any other suggestions.
Hi All,
Thanks for all your suggestions. I need to research more as I didn't get the required answer.
Hi Todd,
Thanks for the information. It will work.