Problem solve Get help with specific problems with your technologies, process and projects.

CGIDEV2: Building native iSeries Web pages

IBM's CGIDEV2 Web toolkit offers a high quality, low cost alternative that requires a set of skills that closely match those commonly found in most iSeries development shops.

In the last few years there has been a bewildering range of new products and technologies used to help organizations leverage their data and business logic and get their applications and data out to employees, suppliers and customers via the internet.

Many of these technologies fail to meet the realities and requirements of most iSeries shops. They may be difficult to learn, provide only basic emulation services, not mesh well with legacy data or business logic, and/or be hard to justify in terms of training, acquisition, and support costs. IBM's CGIDEV2 Web toolkit offers a high quality, low cost alternative that requires a set of skills that closely match those commonly found in most iSeries development shops.

What is CGIDEV2?

At its core, CGIDEV2 is an iSeries-based program development toolkit that facilitates the development of web-based interactive programs using RPG ILE or Cobol (using the older CGIDEV version) as the backend CGI language. The functionality of this toolset is incorporated into an RPG ILE program by means of a service program that contains all of the procedures required to read input from a browser, generate and send the appropriate response back to the browser.

IBM ships a series of CGI APIs with every iSeries that permits an iSeries program to communicate with the iSeries HTTP Web server. You will likely find these API's in a service program called QZHBCGI in library QHTTPSVR on your iSeries. Unfortunately, these API's are not very programmer-friendly and require more time and patience to deploy than most application developers can afford. What CGIDEV2 does best is to simplify these APIs by hiding their complexity and giving the programmer a generous palate of procedures that simplify communications with the Web Server.

CGIDEV2 was developed by Mel Rothman while he was with IBM Rochester. It was released to the public in 1999. The product was maintained and promoted by Mr. Rothman and Dr. Giovanni B. Perotti of IBM Italy, who has added enhancements, documentation and code samples to the package. Because the product is written in RPG ILE and comes with complete source, end users have also been able to contribute enhancements to the package and modify it for their specific requirements.

Recently, on the retirement of Dr. Perotti, there was an attempt by the Perotti and the user community to get IBM to declare an Open Source designation on the product. This attempt has failed for now; however the IBM Client Technology Center (CTC) in Rochester has taken back the CGIDEV2 product and is committed to continue to distribute and maintain it. The CTC also offers consulting and custom solutions using the CGIDEV2 product and have indicated that they may release the product as Open Source in the future. Jim Herring, IBM director of product management and business operations in the iSeries Division, was recently quoted as saying that once declared open source, IBM may even bundle it with the Apache Server or as part of the iSeries Operating System!

Not another terminal emulator

Many Web solutions developed for the iSeries effectively wrap a Web emulator around legacy 5250-based green screens. That permits instant or rapid deployment of existing green screens to the Web. However, there are many features of 5250 programs that are foreign to the Web. For instance, have you ever been to a popular Web page that asks you to hit an F24 key or a field exit key to continue? Not likely. Similarly, there are critical features of Web pages that are foreign to a 5250 green screen program, such as hyperlinks, the back and reload buttons. Such emulation solutions may quickly bring your 5250 screens to the Web, however they inevitably look and feel like a strange hybrid between Web and 5250 standards. They may also demand a great deal of hardware resources and bandwidth to ensure good response time. CGIDEV2 does not take this approach.

When you write your CGIDEV2 programs, you are writing RPG ILE optimized for the Web. As a result, your programs look and behave like real interactive Web pages with the functionality that users expect on a Web page. The bad news is that with CGIDEV2 your 5250 screens will not be instantly converted to beautiful Web pages. To bring your applications to the Web with CGIDEV2, you have to roll up your sleeves and get busy. Luckily much of your RPG business logic can be used as is or cut and paste into your CGIDEV2 program. If your organization's existing code is well structured and modular with many external CALLs for validation, screens and file updates tasks, then the task of moving to CGIDEV2 is greatly simplified. If your organization still loves large top-down, so-called "fast and efficient" monolith programs, then your task will be a bit greater.

Not another SQL solution.

SQL (and the API's that allow access to a database using SQL including JDBC and ODBC), have made Web-based reporting using the iSeries database simple to implement. Most languages commonly used for Web development use OBDC (PHP, Perl) or JDBC (Java, JSP) for data access. These solutions can work exceptionally well for simple queries. However, many organizations, for one reason or another, do not have an adequately normalized database to take full advantage of an SQL solution. Many organizations still have vestiges of hierarchical structure databases, or suffer from poor design or complex business relationships that cannot be expressed well using simple SQL statements. Such issues are hard to overcome using typical SQL solutions and may require complex SQL statements or temporary tables that can affect performance or require nightly data extractions that affect the timeliness of data.

Because of RPG's close relationship to the iSeries database, non-normalized databases, multi-record formats and multi-membered files are not a big inconvenience for an RPG programmer. However, when working with an SQL solution, these characteristics may require various techniques that may impact performance of the query, accuracy or timeliness of the data.

CGIDEV2 allows you to use what is best for your application - SQL (with RPGSQLLE or OPNQRYF) or regular RPG data access (SETLL, READ, CHAIN). This can give CGIDEV2 a big advantage over other purely SQL solutions.

As CGIDEV2 is a native iSeries solution; you will not need to add additional PC servers. You can even integrate CGIDEV2 programs into your current production library list. Similarly, there is no need to replicate data from the DB/400 database to another database. This simplifies back up, recovery and other administrative tasks -- fast and free.

One of the biggest selling points of CGIDEV2 is its cost. The package is available at no cost from the new IBM CGIDEV2 Web site and the required HTTP sever comes installed with the OS/400 operating system. The CGIDEV2 installation kit comes with an automated installation process and many working examples, allowing you to get it up and running very quickly.

You will also need to be at OS/400 V4R5 or greater and have an RPG IV compiler at V4R3 or above. All development may be done directly on the iSeries using IBM source editor (SEU) for the Windows-phobic. However much better productivity can be achieved using an HTML editor and storing HTML source in the IFS. I use WebSphere Development Studio for iSeries because it has a strong WYSIWYG HTML editor and tight integration with the iSeries for management of IFS files.

Because CGIDEV2 uses the lightweight iSeries HTTP Server (powered by Apache) you will probably not have to upgrade your hardware to deploy a CGIDEV2 project. In fact, moving users from interactive green screens to CGIDEV2 programs will likely reduce CPU usage because CGIDEV2 programs are processed in a batch subsystem and typically take fewer resources than interactive green-screen programs. Because CGIDEV2 programs are compiled RPG ILE code and not interpreted script or bytecode, CGIDEV2 programs provide very good response time, especially on intensive data retrieval tasks.

Separation of Presentation and Business Logic

Another nice feature of CGIDEV2 is that it encourages the programmer to separate the program logic from the presentation of the Web page. CGIDEV2 does this by allowing the programmer to keep the static portion of the web page in an HTML Skeleton file. This HTML skeleton file can be stored in a separate source physical file member or as text file on the iSeries' Integrated File System (IFS). This technique is not unlike the way iSeries programmers have been separating DDS display files from the logic of the program for years. This technique also permits an organization to separate much of the screen design tasks from programming tasks thus liberating the programmer from many on-going Web maintenance "look and feel" tasks like changing static text, logos and fonts.

It is interesting to note that ability to separate the business logic from the presentation of the Web page is missing or added as an afterthought, in other Web languages like PHP, Perl and JSP.


CGIDEV2 is not alone in its class. While IBM has been mostly promoting its Java/Websphere solution, other companies such as BDC Websmart, Prodata's RPG Server Pages and Profound Logic's RPG Smart Pages have been successfully targeting the same CGI/HTTP niche as CGIDEV2 with commercial solutions. These commercial products typically come with more evolved visual development environments and may add additional functionality like templates, quick-start or green-screen conversion wizards or better state and session tracking. These products are also worth investigating for their additional features and support.

Leveraging your organization's existing skill set

While other technologies such as WebSphere/Java and .net may offer additional functionality in building interactive web sites, the total cost of adopting and maintaining these technologies, including the difficulty of finding qualified people who also understand your business, can make the decision to adopt these technologies very difficult. This is especially true for small and medium-sized organizations with limited resources. CGIDEV2 allows an iSeries shop to develop web applications in-house with existing staff without significant cost or learning curve.

A big strength of CGIDEV2 technology is its proximity to the skill set found in many iSeries development shops. While CGIDEV2's RPGLE-based development environment looks very familiar to RPG programmers, the end-user deliverables appear very new and exciting when compared to regular iSeries green screens. The Web paradigm permits new functionality that was largely missing in 5250 programming, such as mouse-click hyperlinks, pull-down menus, moveable windows, embedded images, audio, and video.

As an experienced RPGIV programmer with exposure to ILE techniques and a bit of HTML, you can ramp up on this technology in just a few days. For RPG programmers, it is a great tool to get started with Web programming, as it does not require a large investment of time or money. It can also be a natural starting point to start learning additional Web technologies such as CSS, JavaScript, JSP and XML.

Some considerations

There are also some additional considerations to take into account before adopting CGIDEV2. Firstly CGIDEV2 is iSeries specific. It will not migrate to Linux or Windows, so if you are in the process of migrating your ERP to Microsoft Access or a piece of Linux shareware, then this solution may not be right for your organization.

CGIDEV2 may be mastered quickly by experienced iSeries programmers. It builds on their experience with RPG, DDS, CL and the iSeries database. This is not a wizard type tool for an iSeries neophyte and is not a recommended starting pace for a new iSeries programmer.

Although it is now supported by IBM, and the CTC offers custom solutions based on this technology, as of today you cannot buy a service contract from IBM for CGIDEV2. The best place for support is one the CGIDEV2 message board, which is monitored both by CTC staff and the two original developers of CGIDEV2.

All in all, the great price tag, the ease of learning and integration, and low hardware requirements should make CGIDEV2 an easy sell especially in organizations hampered by budgets and indecisive to committing to new technologies.

For further information

Check out the new IBM Web site and get the CGIDEV2 download.

Visit Giovanni's Easy400 site with CGIDEV2 installation instructions, tutorials and addition mail and security tools.

If you need support, visit the Easy400 Discussion Group for CGIDEV2 support.

About the author: Martin Cytrynbaum is an analyst/programmer on midrange systems with Liberty and Associates, a Montreal-based IBM Business Partner specializing in modernizing legacy applications. Click here to contact Martin.

Dig Deeper on RPG iSeries programming