One of the challenges of working with IBM AS/400 (also known as System i) platform is that is designed following completely different principles from other contemporary systems. For one, they use a text-based interface, which now feels ancient and unfamiliar to most. These systems can be powerful, but they are certainly complex. There is no tutorial, and not easy way to discover information. You need to read a manual to use them, but even that are hard to find. In a word, they are esoteric: they work for people trained in them, but they are hard to understand for newcomers.
So, even relatively simple things, like extracting some files are hard to do: it is difficult to find the files are and to actually perform the commands to extract them. This is where this guide comes in.
The GuideNavigating an AS/400 system can be challenging for inexperienced users, and extracting files is not a common task. Therefore in this guide, we will show you how to extract files using standard tools whenever possible—tools that should be familiar to users across different platforms.
The first step is to ensure that the SSH server in the system is running.
Ensure SSH Server is Running1. Log in the system, you should see a command prompt similar to this.
STRTCPSVR SERVER(*SSHD)
Locate RPG Files in IFSRPG files can be stored in the Integrated File System (IFS) orinside the system database, but they can also be stored. Let’s start with this first case, since it is the easier one.
ssh <user>@<ibm\_system>
2. Locate the files. At this point you can locate the files using standard POSIX tools, like find.
find . -type f -name "*.rpg*"
The previous command will just find RPG source files, but you will need also the DDS files, that describes the format of the data used in RPG programs. Look whether any .dds/.dspf files present in the directory containing RPG files. Once you have a list of these directories, you can proceed to the next step.
scp -r <user>@<ibm\_system>:/path/to/rpg\_files /local/destination
This should take care of the case in which RPG files are available in IFS.
Locate RPG Files in the DatabaseGiven that the files are located in the system database, in theory you could connect to the DB2 database using any Database Tool that supports DB2. The problem is that the files are stored line by line, similar to this.
If you have a DB administrator or developer available to create a script, you can go this route: loop through the tables, extract the lines and reconstruct the file. However, this is not convenient, so we suggest using an external tool.
Install External Tools for Easy Access and LoginNow, that you have enabled SSH, you can access your IBM system from a computer using a more familiar system (i.e., Windows, macOS, Linux).
The extension allows you to connect to an IBM i system and comes with several browsers (IFS, Object file system, etc.) to explore the files present in the system and work with them. It is mainly designed to develop code on an IBM i system, but it also allows accessing the system in a way that would be familiar to any sysadmin or developer.
Download the Source FilesWe can now proceed to download the RPG source files stored in the database.
Click on New File… and pick a name, for instance, hello.sql.
SELECT SCHEMA\_NAME AS LIBRARY\_NAMEFROM QSYS2.SYSSCHEMASORDER BY SCHEMA\_NAME;
The select the statement and click the button (Run SQL statement) in the top right corner to execute the SQL statement.
A list of libraries will appear in the bottom panel.
A form will appear. Input the name of the first library you have found. In our example is STRUMENTA1.
Select the files. Clicking on the filter will update the list of files in the library. In the Object Browser you will see a list of folders for each kind of file, such as qrpglesrc for RPG files. The terminology might seem confusing: we are using the Object Browser, and what we would call source code files (i.e., RPG files) are referred to as objects or members. That is because in IBM parlance a source file the group of files inside a library. The actual files are members or objects.
Download the files. Right-click on the qrpglesrc (RPG source files) and click Download.
You will be prompted for a location where to save the files. Repeat the process for qddsrc (DDS source files).
Access the TerminalYou should now verify that you have access to the Bash terminal on your IBM system.
In the previous image the system is called pub400. A menu will appear, which will include the item Terminals. Click on it and a new menu will appear on the top center of VS Code.
Select the PASE item. This would make appear the bash terminal on the lower part of VS Code. If there is no PASE item, you will have to install the IBM Portable Application Solutions Environment for i (PASE for i) on your IBM system.
ResourcesThis article provides insight into the Strumenta approach in migrating an ERP system from IBM RPG to Python based on our experience with a real project in the manufacturing industry.
This article explores the challenge will be transforming RPG code into Clear Sequence Diagrams
If you are looking for a Ready-to-go parser here you can find a tutorial.
The post Extract RPG files from AS/400 or System i appeared first on Strumenta.