Skip to content
David Cumps
Ancient Technologies: RPG & AS/400

Ancient Technologies: RPG & AS/400

Originally published on my old blog at cumps.be on March 21, 2004.

I just finished a school project in RPG. In the beginning I hated RPG and the AS/400 it was running on. When you’re used to writing languages like PHP, C++, C#, Perl and even batch, RPG seems like a nightmare, crazy syntax, column-based, numeric vs character variable handling, …

And then we had to do a project for that class. The teacher talked about a previous group doing something with HTML and CGI on the AS/400, so I decided to take on the challenge and write a complete website that uses the AS/400 as back-end with RPG as the language.

Some obstacles I encountered:

  • The website was going to be written in PHP, but our AS/400 didn’t support it, so the decision was quickly made to host the site on another server. But this adds the difficulty of communicating between site and AS/400. In the end the site is running on Windows 2000 with IIS and uses DB/400 for data storage on the AS/400.
  • The first communication attempt: DB/400 supports stored procedures, so we’ll just access the RPG programs through stored procedures. But again, problems, at first we simply couldn’t connect to the server, we later figured out it had to do with permissions. But after those permissions there was no way I could call a stored procedure from PHP.
  • So I changed the way of communicating. First I created a PHP class that can easily construct a command to call the RPG program. It takes the program name and parameters and executes it. What happens in the back is, a query string is constructed, it gets called on the AS/400, there a program pulls in the query string and parses it, after which it calls the appropriate RPG program. Each RPG program has some return value which gets sent back to the PHP object that initially made the call and then the returned info gets processed on the website.

Here’s how it goes in the final result:

Icekings architecture: PHP site calling RPG programs on the AS/400

Of course there were also a lot of obstacles getting to know RPG and the way it works with the system, especially in the capitalization department, sometimes it’s case sensitive when you don’t want it, and another time it’s back to case insensitive.

But in the end, now it’s finished, I’m amazed by the result. A fully working PHP website on a separate server, running Windows, with an AS/400 back-end, using RPG as the language to talk with DB/400. It amazes me that a technology that old can play along with a new technology like PHP.

You May Also Like

Orkut: An Overview

Orkut: An Overview

A first look at Orkut, Google's invite-only social network: profiles, friends, communities and a lot of personal questions.