|Free AS400 Downloads
|Free Testing Downloads
AS400 FAQs - FLAT FILES
My server logs show that many people are coming to this site with general questions about AS400s, so I've added a few pages in which I discuss some of the topics people are searching for.
How do I read a flat file?
There are essentially two methods to doing this. Firstly, you can copy the flat file into a database file. Why would you want to do this ? Well, if the data is stuff that you need to sort or query, then this is by far the best route. There is a CL command to do this which is CPYFRMIMPF, which copies data from a flat file held in the IFS into a database file. The default settings for this command will copy a CSV or Comma Separated Value file from the IFS into a database file. Very handy.
The alternative is to read in a file in RPG. Now RPG does not natively handle this, but the C programming language does. You can use the C library at runtime in RPGLE by binding to it in the H specs. There's an example and some documentation here: Read Flat file in RPG