For many organizations, business logic coded in RPG or COBOL is their “secret sauce,” providing them with a profitable long-term competitive edge. It therefore makes good business sense to leverage this investment when embarking on digital transformation initiatives or even when enhancing existing applications. In this article, we'll share ways to combine PHP and RPG to achieve lasting business results while raising the stature of IT in the eyes of management.
RPG was designed to execute business logic flawlessly. The PHP language was built for developing web applications and APIs. How can RPG and PHP complement one another? In working with companies utilizing IBM i systems (and AS/400 and iSeries before that) for many years, we’ve used two highly effective and easy techniques to combine these two languages: PHP applications calling RPG business logic, and the reverse, RPG applications enriched by calling PHP scripts to perform tasks that are easier in PHP.
For companies looking to utilize existing RPG-based business logic to update their look or expand their self-service possibilities through web-based applications or web services, PHP can call RPG.
I first explored the power of PHP calling RPG in 2008 when I helped Allied Beverage Group, a premier wine and spirits distributor now located in Elizabeth, New Jersey, develop their flagship business-to-business e-commerce system. Called eBiz, this web-based application provides self-service opportunities to customers and sales representatives, boosting sales and reducing the number of calls coming to the customer service department. The IT team took existing “green screen” RPG applications and created self-contained modules containing product ordering logic that could be called from PHP. This ensured that the logic remained consistent between the classic 5250 application and the new web-based one. We were honored for this work by winning the COMMON/IBM Innovation award, and, best of all, eBiz is still going strong today, having gained wide adoption and being enhanced continuously to meet changing business and market needs.
We chose the PHP Toolkit to call the RPG programs as it is a robust way to call RPG programs and other IBM i resources efficiently and flexibly, as well as being free and open source. I helped develop the PHP Toolkit and still maintain it today with others. We ship the toolkit with our Seiden Group CommunityPlus+ PHP distribution for IBM i and the toolkit source code is available at Github. More examples for how to use the toolkit are available on our site.
When speaking with King Harrison of K3S, he described his company’s RPG business logic as their “treasure.” Their carefully architected RPG routines provide a solid foundation on which they can build a wide variety of highly graphical front ends that can keep up with changing technology. When he developed web pages to show inventory information, he used the PHP Toolkit to call these RPG “APIs,” as King refers to them. The speed is superb and the charts allow business experts to make superior decisions. For details, read “RPG APIs: A Modernization Treasure.”
Creative developers looking for the most straightforward way to do a job can enhance RPG programs by calling scripts written in PHP, Python, and other open-source languages of the PASE environment. These “scripting” languages provide features that, while possible to implement in RPG, are simpler or more flexible in other languages such as PHP.
For example, they can:
Over the last few years, we’ve worked with many companies to help them connect to APIs and web services, as well as creating their own.
Some of the most common types include:
One interesting recent project was to enhance a custom RPG-based CRM with functionality that would track marketing email opens and link clicks. We developed PHP scripts to do all that and then worked with our client to make sure the PHP scripts could be called easily from their RPG programs. For calling the PHP scripts, we recommended Scott Klement’s open source HTTPAPI tool.
Additional tools that allow calling PHP and Python scripts via web URLs include:
PHP can also be called directly from RPG without using a web URL though it will have a bit of a slower startup than with the above HTTP techniques.
Examples include:
The best way to start is with a small, but useful project idea. When you combine RPG and tools such as PHP, Python, and Node.js, you can say “yes” to many projects that would otherwise be difficult. If you need to install PHP, we recommend our own CommunityPlus+ PHP, but Zend Server PHP also works. With a small project, you can learn a new language gradually and you are welcome to contact us for suggestions or to discuss a boost to get started.
Alan Seiden is the principal of Seiden Group, which helps companies bridge the gap between traditional IBM i technology, such as RPG, with open source tools and techniques, such as PHP, Python, Node.js, APIs, and web services.
For the past two decades, we've made it our business to help you work smarter. From commerce challenges to ERP customizations, we support the power of your big ideas by helping you work more strategically, more intuitively, and more efficiently.
2658 Scranton Road, Suite 3
Cleveland, Ohio 44113
216.369.3600
No Comments Yet
Let us know what you think