What's New in V5R4 RPG?

XML Parsing Support

Finally, what about this new XML support? The RPG compiler now offers direct access to an XML parser. Some of this direct-language XML parsing support was added to the ILE COBOL compiler in V5R3. While RPGers had to wait a while longer, the RPG support includes some options to simplify the process-enough to make COBOL developers green with envy. Whether you're using XML to consume Web services or to simply exchange data with customers or suppliers, if you've tried the other options to interface to XML parsers from RPG programs, you'll be very interested in looking at what the V5R4 RPG compiler can do for you.

A new operation code, XML-SAX, provides a direct RPG-language interface to a simple API for XML (SAX) parser. This support is somewhat similar to the V5R3 COBOL support and is also reminiscent of the ways many RPGers have been parsing XML using either the XML Toolkit for iSeries from IBM or Scott Klement's iSeries port of the Expat parser.

The simpler (and consequently far more interesting) option for RPGers is supported by another new operation code, XML-INTO. This operation code, in its simplest form, extracts data from an XML document (which can be in an RPG field or an IFS file) and places the contents of the element and attribute values into matching variable(s)-most likely a DS.

To give you an idea of how this works, let's assume we have a simple XML document that looks like this:

AS/400 Magazine
iSeries Magazine
eServer Magazine, iSeries Edition
IBM Systems Magazine, i5 Business Systems Edition

Assuming the XML is in an RPG field named MyXMLDoc, we could parse the contents of the document into a DS like this:

D  MagazineNames   DS                 Dim(4) Qualified
D  Name                         50A
D  Version                      10A

C                   XML-Into  MagazineNames %XML('MyXMLDoc')

If you haven't yet had occasion to parse an XML document from an RPG program, take our word for it-this is FAR simpler than the other methods we've used.

We don't have enough space to go into detail on either of the XML parsing options here, but you can read more about them and see some more complex examples in the March edition of IBM Systems Magazine, i5 Business Systems edition.

Sneak Preview
That's our sneak preview of RPG at V5R4. We've barely scratched the surface of the capabilities in this new release, particularly in the case of the XML parsing support. Even so, we hope we've given you enough information to whet your appetites and have you looking forward to a chance to try these new features for yourselves.

Jon Paris is a technical editor with IBM Systems Magazine and co-owner of Partner400.

Susan Gantner is a technical editor with IBM Systems Magazine and co-owner of Partner400.

comments powered by Disqus



2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

New and Improved XML-INTO

Namespace support makes the opcode a viable option

Authenticating on the Web

The finer points of OpenRPGUI, Part 1

The Microphone is Open

Add your voice: Should IBM i include open-source RPG tools?

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters