How can we help you?

We have hundreds of highly-qualified, experienced experts working in 70+ technologies.

IBM i e-Book

A Developer’s Guide to Mastering IBM i Concepts

System Architecture

Integrated File System

Integrated File System (IFS) in AS/400 (IBM i) is a feature that allows you to work with different types of data, including text files, documents, and directories, in a similar way to traditional file systems on other operating systems. It acts as a bridge between the traditional database-centric world of IBM i and the more common file-based systems.

Why do we use IFS?

The IFS provides a common way to manage and access various types of files and data on your AS/400 system, making it easier to work with different types of information alongside your traditional database files. It’s like having a versatile file storage system within your AS/400 environment, making it more flexible and compatible with various file formats.

Structure of IFS on IBM i

The structure of IFS on IBM I consists of several key elements, including:

1. Libraries: These are collections of objects and files, typically accessed using the QSYS.LIB notation.
2. Files: Files within libraries store various types of data and can be accessed through the IFS.
3. Directories: Directories provide a way to organize and manage files and data within the IFS.
4. Stream Files and Objects: Stream files are a common type of data stored within directories and can be accessed via specified paths. Objects can also be accessed similarly.
5. Folders: These are used to organize and group documents and data in QDLS (Document Library System).
6. Documents: Documents within folders are part of the QDLS structure and are accessible to users.

The IFS allows for the structured organization of data, with libraries holding files and objects that can be accessed through specific paths and directories. Additionally, folders and documents in QDLS provide a further level of organization and accessibility for users.

Stream files

Stream files in AS/400’s Integrated File System (IFS) are a type of data storage used for unstructured content, such as text, documents, images, and more. They provide a flexible way to store and manage various file types alongside traditional database-centric data. Here are some key points about stream files in AS/400’s IFS:

1. Data Type: Stream files can store a wide range of data types, including plain text, binary data, documents (e.g., PDF, DOCX), images, and multimedia files.

2. Flexible Structure: Unlike traditional database files in AS/400, stream files have a flexible structure, making them suitable for various file formats and content.

3. Hierarchical Storage: Stream files are organized in a hierarchical directory structure similar to directories and subdirectories in a file system.

4. Access: Stream files can be accessed and managed through standard file operations and file protocols. This includes reading, writing, copying, moving, and deleting files.

5. Integration: The IFS allows you to seamlessly integrate stream files with traditional database files, making it easy to work with structured and unstructured data in the same environment.

6. File Formats: Stream files can be used to store files in various formats, making them suitable for a wide range of applications, including document management, web content, and more.

7. Security: AS/400 provides security features to control access to stream files, ensuring data confidentiality and integrity.

Stream files in AS/400’s IFS offer a versatile way to handle unstructured data, enabling businesses to manage a variety of file types within the same system, enhancing flexibility and compatibility.

Types of File System

File SystemDescriptionExample
Root File System (/)The primary file system uses the forward slash (/) as the separator for directories and files. It’s the top-level directory in the IFS.`/mydirectory/myfile.txt`
QSYS.LIB File systemA library-based naming convention is often used to access objects and files associated with libraries on AS/400. This system follows the QSYS.LIB structure.`QSYS.LIB/MYLIB.LIB/MYFILE.FILE`    
QDLS FILE SystemThe Document Library System (QDLS) file system for organizing documents and folders. It provides a hierarchical structure for managing documents.`QDLS/MYFOLDER/MYDOCUMENT.PDF`  
QOPT File SystemThe QOPT file system is used for optional integrated file systems and may be used to customize the naming and organization of files.Customized naming and organization rules

These file systems offer different naming conventions and structures, allowing users to work with files and directories in a way that best suits their requirements. Each file system has its own set of rules and purposes, making it more convenient for managing and accessing data within the IFS on AS/400.

An IFS “Hello World” Application

Below are the simple RPGLE programs in Free and Fixed format to write Hello World as content in the stream file stored at IFS. Both the programs use the C APIs – open, write, and close to create and write a stream file in the IFS of the IBM I operating system.

First, let’s see the Free-format RPGLE program.

Now, let’s see the RPGLE program in Free format.

Output: Before program run

After program run

Common Commands for IFS in AS400

In AS/400 (IBM i), several commands are commonly used for various tasks related to working with objects, libraries, and data. Here’s a brief explanation of the commands you mentioned:

1. WRKLNK (Work with Links):

Syntax:

WRKLNK  ‘/DIRECTORY_NAME/FILE_NAME’


  – This command allows you to work with symbolic links in the Integrated File System (IFS) on the IBM I platform. Symbolic links are references to other files or directories, providing a convenient way to access or reference files in different locations.

2. DSPF (Display File):

Syntax:

DSPF ‘/ DIRECTORY_NAME/FILE_NAME’


  – DSPF is not a specific AS/400 command. It could be an abbreviation for “Display File,” which typically refers to a display file used in programming on the IBM I platform. Display files are used to define the layout and functionality of screens in interactive applications.

3. EDTF (Edit File):

Syntax:

EDTF ‘/ DIRECTORY_NAME/FILE_NAME’


  – EDTF is an AS/400 command used to edit source files. Source files contain program source code, scripts, or other text-based data. This command opens a source file for editing, allowing developers to make changes to the code.

4. CPYFRMIMPF (Copy from Import File):

Syntax:

CPYFRMIMPF FROMSTMF(‘/DIRECTORY_NAME/FILE_NAME’) TOFILE(LIBRARY_NAME/FILE_NAME) MBROPT(*REPLACE) RCDDLM(*CRLF)


  – This command is used to copy data from an Import File (an external data file) into a database file on the IBM I system. It is often used for importing data from various sources, such as CSV files, into the system’s database files.

5. CPYTOIMPF (Copy to Import File):

Syntax:

CPYTOIMPF FROMFILE(LIBRARY_NAME/FILE_NAME)TOFILE(‘/DIRECTORY_NAME/FILE_NAME’) MBROPT(*REPLACE) RCDDLM(*CRLF) STRDLM(*NONE)


  – CPYTOIMPF is the counterpart to CPYFRMIMPF. It is used to copy data from a database file on the IBM I system into an Import File (an external data file). This command is useful for exporting data from the system to other platforms or applications.

These commands are part of the standard set of commands available on the AS/400 (IBM i) platform and are used for managing and manipulating files, objects, and data.

Access IFS using BD2

You can access the IFS (Integrated File System) on an AS400 system by using DB2. Here are DB2 queries to read and write records in the IFS file. 

Read Record from IFS

Run the below query:

SELECT CAST(LINE AS CHAR(50)) FROM
TABLE(QSYS2.IFS_READ('/home/piofile.csv))

Write a record to the IFS

Run the below query:

CALL QSYS2.IFS_WRITE('/home/piofile.csv,
'insert record in IFS file using SQL’,
OVERWRITE => 'APPEND',
END_OF_LINE => 'CRLF')

How can we help you?

We have hundreds of highly-qualified, experienced experts working in 70+ technologies.

X

Awards and Certifications

company-logo
company-logo
company-logo
company-logo
company-logo
company-logo
company-logo
company-logo
company-logo
company-logo