Working with the IFS in RPG IV

Scott Klement

This eBook is intended to help an experienced RPG IV programmer learn how to read, write and manipulate documents within the Integrated File System on an IBM iSeries/400 server.

It is assumed that the reader of this tutorial is already familiar with the RPG IV language, including prototypes sub-procedures and service programs.

Legal Notice
Table of Contents
1. Introduction to the IFS
1.1. What is the Integrated File System?
1.2. What is a stream file?
1.3. What different file systems can I work with in RPG?
1.4. IFS information in the Information Center
1.5. An IFS "Hello World" Application
1.6. Looking at our example from OS/400
2. The Basics of Stream Files
2.1. Opening Files with the open() API
2.1.1. Creating a header member
2.1.2. Prototyping the open() API
2.1.3. The path parameter
2.1.4. The oflag parameter
2.1.5. The mode parameter
2.1.6. The codepage parameter
2.1.7. The return value of the open() API
2.1.8. Code snippet showing the use of the open() API
2.2. Closing a file with the close() API
2.3. Writing streams with the write() API
2.4. Reading a stream file with the read() API
2.5. Example of writing and reading data to a stream file
2.6. Error handling
2.6.1. Retrieving the error number.
2.6.2. What does the error number mean?
2.6.3. Getting a human-readable error message
2.6.4. Utilities for communicating errors
2.7. Our last example with error handling added
2.8. Example of writing raw data to a stream file
3. Other simple, but helpful IFS commands
3.1. Checking existence and permissions to files
3.2. Example of checking for an object in the IFS
3.3. Changing permissions on an existing IFS Object
3.4. Example of changing an IFS objects permissions
3.5. Retrieving Stream File Stats
3.6. Adding a *SAME option to the permission changer
3.7. Deleting IFS objects
3.8. Renaming IFS objects
3.9. Example of renaming and deleting IFS objects
4. Accessing stream files randomly
4.1. Positioning to a given point in the file
4.2. Example of using lseek() to jump around the file
4.3. Organizing a stream file into records
4.4. Calculating number of records in a file
4.5. Example of reading/writing/updating records in a stream file
5. Text files
5.1. How do text files work?
5.2. Writing text data to a stream file
5.3. Reading text data from a stream file
5.4. Example of writing and reading text files
5.5. Using code pages with text files
5.6. Example of writing & creating an ASCII text file
5.7. Example of a report in ASCII
6. Additional Text Formats
6.1. Comma Separated Values (CSV) Format
6.2. Example of creating a CSV file
6.3. HTML (web page) format
6.4. Example of creating an HTML file
7. Working with directories
7.1. How directories work
7.2. Creating directories
7.3. Removing directories
7.4. Switching your current directory
7.5. Opening Directories
7.6. Reading Directories
7.7. Closing an open directory
7.8. Example of reading a directory
7.9. Example of making a DIR command for QSHELL
7.10. Example of Reading a directory recursively