Add Outfile Support to Your Applications
October 12, 2011 Ted Holt
Note: The code accompanying this article is available for download here.
When I compare IBM i to other operating systems, I am amazed. This well-designed, well-built operating system has numerous features that are foreign concepts to other operating systems. One of those features is that of “outfiles”, files that are built by display-type and work-type commands. If you haven’t done so, consider that it may be advantageous to write your own commands with outfile support.
In general, programs that write to database files always write to certain database files, and that’s as it should be. A file maintenance program that allows users to add, delete, and change customer information always sends output to the customer master file.
But consider a file that is the result of a query process. There are good reasons that such data should be written to a file of the user’s choosing at run time. The user may want to use this file with a query tool, or send it to his PC in CSV format for use with Excel. Allowing a user to specify a file’s name at run time is not unlike his naming a document that he creates with a Word processor.
Here’s a short example application that illustrates the process of creating outfiles. I call it XTRCUS (Extract Customer) because it extracts customer data from the database. It consists of these objects: