June 25


What is RPG OA?

By NickLitten

June 25, 2017

RPG, Access, ILE, Open, RPGOA, webservices

I was talking about RPG OA today. If you’re an IBM i techie, then you will know about OA already. You probably understand its power and potential in our IBM-i world. If you’re a bit more old school, you’ve been churning out column-based code for years, or you are living under a rock in a desert somewhere, or you just don’t know what the hell I am mumbling about – then here is a quick little primer:

Rational Open Access: RPG Edition, which is shortened to RPG OA, was developed by IBM to give us programmers a simple”ish” method to pass data from a RPG program to an external service (for example a web browser).

What is rpg oa? 1

RPG OA uses a single RPG opcode to let RPG programs, with traditionally limited interfacing capabilities, communicate data from DB2 database tables (5250 display files) with other interfaces that it cannot talk to normally…. this might mean Web services, browsers, mobile devices, XML/JSON files, external databases, and the list goes on.

RPG OA can be easily added to old RPG code in Green screens programs and new RPG programs. OA does not affect functionality of existing DSPF programs, add the line of code, recompile and they will continue to work how they have for years, decades, centuries /insert maniacal laughter

Without getting too technical — The RPG OA Handler populates a data structure from the data fed into it (for example what is being sent to a green screen) and this lets us extend the existing  RPG I/O model to talk to virtually any *internet* device we can think of. More than that, we can even use RPG OA to talk to places on our own machine (ie: the IFS) without using clunky API access.

So, think about this – if we have a program that is writing to a table and we want to get that table data somewhere else. Lets say a file in the IFS. We could write a DB2-IFS handler and then just add that line of the code to any existing program and data would be automatically written to an IFS file as that program writes to the table. Cunning stuff!

The great thing about it is that it’s a simple line of code to add to the DSPF specification on the F-SPEC so existing RPG programmers can quickly add it.

How Does Open Access Work?

The Handler programmatically determines the amount of data it wants and can make the selection at the time of the open operation.

In other words, pretty much the same as the old SPECIAL file interface but with the addition of full file and record names, key data, etc. A full description of each field (known as a Name/Value handler) along with the data and keys. The description includes information such as Field name, Length, Data type, Decimal places, etc.

The Handler can pass back full status data to the user program. For example, field values like RRN, Status codes, etc.

What type of Handler do you need?

Use a “Buffer” handler if:

  • Processing requirements are specific for each type of “file”
  • For example UPS web services are different to FedEx web services – so it might be easier to write two seperate handlers
  • Or … When the handler does not need to know the content of the data (It simply passes it on as a “lump” such as when using a data queue)

Use a “Name/Value” handler when:

  • You need to adapt the output of an existing program
  • The behavior is consistent and can be used in many places (For example writing to or reading from an IFS file, or Reading and writing Excel spreadsheets)

The more generic a handler is the more complex it is to write. But you can easily write handlers for IFS files, spreadsheets, etc.

Want to know more?

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Join the IBM i Community for FREE Presentations, Lessons, Hints and Tips