Chapter 5. Using RPG for XML processing 61
5.1.2 Composition planning and design
The StoreSales XML document is the first XML document that required composition at the
store level of our A
2
BCM company scenario. In Chapter 3, “Using SQL to compose XML” on
page 33, we provide an SQL-based solution to generate XML from our database tables for
the StoreSales XML document. Using RPG, we provide another programmatic solution that
shows how to generate the same XML document using RPG, embedded SQL, and the CGI
toolkit.
Since this composition is for several stores to report their data, each contained in a separate
XML document, we require input parameters to be passed to the composition modules to
provide flexibility and reuse of coded solutions. To accomplish this, we provided a CMD
interface to our RPG module, along with an associated help panel (PNLGRP). This interface
allows the same composition module to be used for any number of outbound StoreSales XML
documents that potentially reside in different integrated file system directories with different
document names. In addition, a CLLE program was developed to validate the user input prior
to processing to prevent any errors in user input. This approach grants us flexibility in reuse of
a one-coded solution for any number of document locations and naming conventions that are
provided.
The biggest advantage of using the CGI toolkit is that it removes the complexity of building an
HTML interface, or in our case, an XML document, and publishing it. One service program
supplied in the toolkit does all the work and provides simple procedure interfaces to access
the features supplied by CGI. The developer can just concentrate on business logic required
to generate an XML document.
5.1.3 Composition coding
In this section, we explain the program flow, the different modules, and the Extensible
Stylesheet Language (XSL) document coding.
Program flow
Figure 5-2 illustrates the processing flow of the StoreSales XML document composition.
Note: Control Language Integrated Language Environment (CLLE), Command (CMD),
UIM PNLGRP, and Report Program Generator (RPG) module development are part of the
WebSphere Development Studio for iSeries license program.
62 The Ins and Outs of XML and DB2 for i5/OS
Figure 5-2 StrSlsGenr program flow
Required modules
The following modules were created for composition processing via RPG:
򐂰 STRSLSGENV CLLE to perform command parameter validity checking
򐂰 STRSLSGENR SQLRPGLE to compose an XML document from our database using the
CGI toolkit
򐂰 STRSLSGENR CGI script template that defines our XML document to be produced
򐂰 STRSLSGENR CMD to provide a user interface for input variables
򐂰 STRSLSGENR PNLGRP to provide for help text for each command parameter
The source code for the associated CMD, PNLGRP, and CLLE program, as well as all other
items, is available in the additional materials that are available for download. Module
generation instructions are contained in each of the sample source members. For information
about downloading this code, see Appendix A, “Additional material” on page 207.
Input valid?
Prompt user
for input
CL PGM
STRSLSGENV -
Validate user input
RPG PGM
STRSLSGENR -
Uses CDIGEV2
toolkit to write XML
Yes
No
Generated XML
Document

Get The Ins and Outs of XML and DB2 for i5/OS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.