Sourcetable Integration

Export AS400 to CSV

Jump to


    Welcome to our comprehensive guide on how to export data from AS400 to a CSV file. The IBM AS400 system is renowned for its robustness and reliability, but integrating its data with modern applications and databases can be greatly simplified by exporting it to the universally accessible CSV format. This not only makes the data easier to read but also puts it into a manageable format for systems like SQL Server and spreadsheets, enhancing data analysis and reporting capabilities. On this page, we'll delve into what AS400 is, the step-by-step process for exporting data to a CSV file using various methods and tools, practical use cases for such exports, and an innovative alternative to CSV exports using Sourcetable. Additionally, we'll address frequently asked questions about the export process to help you streamline your data management tasks.

    Understanding AS400

    The AS/400, introduced by IBM in 1988, is a family of midrange computers that culminated from the succession of the System/36 and System/38 platforms. This system is renowned for its stability, security, reliability, and scalability, making it an ideal choice for small and medium-sized businesses. The AS/400 runs on the OS/400 operating system, which includes an integrated relational database management system, Db2. The unique aspect of the AS/400 is its use of a technology independent machine interface (TIMI), allowing applications to run independently of the underlying hardware processor.

    AS400 software, also known as IBM i, is an operating system and software platform developed to operate on IBM's midrange servers. Since its inception in 1988, it has become popular across numerous industries due to its reliability, ease of management, and scalability. The AS400 software platform is highly integrated and supports a wide range of business applications. The software is constantly evolving to satisfy modern business requirements and retains backward compatibility with legacy applications while supporting modern applications and integrations with other platforms.

    As a type of service, the AS400 system is not only used for enterprise resource planning (ERP) but also for database management, web, and mobile business applications. The system offers integrated web services and can run applications in the cloud, making it a cost-effective and comprehensive solution for businesses. While the AS400 can function as a database management system and is often associated with ERP software systems, it is important to note that the AS400 itself is not an ERP system. Today, the AS400 is recognized as part of IBM Power Systems, which continues to serve companies around the world.

    Exporting AS400 Data to a CSV File

    Using CPYTOIMPF Command

    To export a table to a CSV file on the AS400, the CPYTOIMPF command is used. This command allows for the file to be placed within the Integrated File System (IFS) by specifying the TOSTMF option. An example command would look like this: CPYTOIMPF FROMFILE(DBFILE) TOSTMF('/outputfile.csv') STMFCODPAG(*PCASCII) RCDDLM(*CRLF). Alternatively, to load the exported CSV file into a specified library, the TOFILE keyword can be used instead of TOSTMF.

    Transferring Data to a PC

    Once the CSV file is created on the IFS, it can be transferred to a PC using the "Data Transfer from iSeries" function of IBM iSeries Client Access. This facilitates the movement of data from the iSeries environment to a more accessible format for users on their personal computers.

    Automating Export with Triggers

    A trigger can be implemented to automatically export data to a CSV file each time the associated database file is written to. This ensures that the CSV file remains up-to-date with the latest data changes without manual intervention.

    Exporting CSV File Using FTP

    In scenarios where the CSV file needs to be moved to another location, such as a server or a different PC, FTP (File Transfer Protocol) is necessary. With the right permissions and network configurations, FTP allows for the secure transfer of the generated CSV file from the IFS to the desired destination.

    CL Program Automation for Export and FTP

    A simple Command Language (CL) program can be created to handle the export of the CSV file and then use FTP to send it to another location. This programmatic approach streamlines the process, making it more efficient and less prone to human error.

    Sourcetable Integration

    Streamline Your Workflow with Sourcetable

    Instead of the traditional method of exporting your AS400 data to a CSV file and then importing it into another spreadsheet program, consider the advanced capabilities of Sourcetable. Sourcetable offers a seamless experience by syncing your live data directly from your AS400 system, eliminating the extra steps involved in the CSV export-import process.

    With Sourcetable, automation and business intelligence are at the forefront. By automatically pulling in data from various sources, not only do you save time, but you also reduce the risk of human error associated with manual data transfers. Plus, Sourcetable's familiar spreadsheet interface means there's no steep learning curve, so you can dive right into data querying and analysis.

    Common Use Cases

    • A
      Sourcetable Integration
      Use case 1: Transferring data from an IBM iSeries AS400 systems DB2 database to SQL Server for analysis and reporting
    • A
      Sourcetable Integration
      Use case 2: Consolidating data from multiple AS400 tables into a single CSV for easier data management and manipulation in SQL Server
    • A
      Sourcetable Integration
      Use case 3: Automating the process of data exportation with triggers to streamline the workflow between AS400 systems and SQL Server databases
    • A
      Sourcetable Integration
      Use case 4: Utilizing the CSV export functionality to perform regular backups or migrations of large datasets to SQL Server
    • A
      Sourcetable Integration
      Use case 5: Enabling direct downloads of AS400 table data to a PC for users who need local access to the data in a universally readable format

    Frequently Asked Questions

    What commands can be used to export data from AS400 to a CSV file?

    The CPYTOIMPF command can be used to export a data table to a CSV file and place it on the IFS or copy it to a library. Additionally, the Data Transfer from iSeries function of IBM Client Access can be utilized to download data to a CSV file.

    Can I automate the export of CSV files from AS400?

    Yes, a trigger or automated processes such as FTP can be used to export data to a CSV file.

    Is there a way to use SQL with CPYTOIMPF for exporting data?

    Yes, CPYTOIMPF supports copying from an SQL VIEW, and you can use the RUNSQLSTM command to run SQL statements that insert into a physical file, which can then be used with CPYTOIMPF to copy data to a CSV file.

    What are the alternatives to using PHP for exporting and importing CSV files on AS400?

    Alternatives include using CPYTOIMPF and CPYFRMIMPF commands or creating a custom import/export process using RPG or PHP based on performance and error handling preferences.

    Does CPYTOIMPF support the use of queries when exporting to CSV?

    Yes, CPYTOIMPF does support the use of a query when exporting data to a CSV file.


    In summary, exporting data from AS400 to a CSV file can be efficiently accomplished using the CPYTOIMPF command, which allows for copying files directly to the Integrated File System (IFS) in CSV format. Whether you're placing a CSV file on the IFS with the TOSTMF option, or loading it into a library using the TOFILE keyword, the process is streamlined for your convenience. Additionally, IBM iSeries Client Access provides the "Data Transfer from iSeries" function to facilitate direct downloads to a PC, and triggers can be utilized for automatic data exports. However, instead of navigating through these traditional methods, consider simplifying your workflow by using Sourcetable to directly import your data into a spreadsheet. Sign up for Sourcetable to get started and enhance your data management experience.

    Start working with Live Data

    Analyze data, automate reports and create live dashboards
    for all your business applications, without code. Get unlimited access free for 14 days.