Chapter 8. Using XML with COBOL 163
Table 8-2 Options for file reference variables
The initialization needed to read from a file named ‘CAMT.STMT.XML’ is shown in Example 8-7.
Example 8-7 Initialization of a file reference variable
When the file reference variable is subsequently referred to, the specified file option is
executed. Therefore, if the file is used, such as in an insert operation, the file is read into DB2
and inserted without materializing in application memory.
8.2 The BankStmt application in COBOL
This section contains implementation steps of the BankStmt application in COBOL.
The purpose of the application is to demonstrate how to use COBOL with DB2 pureXML. We
emphasize the steps and choices that are related to XML, disregarding irrelevant code and
components such as presentation layer or user dialog. The application might therefore seem
simple compared to a real-life application.
We use the same subset of the ISO 20022 standard, namely the BankToCustomerStatement
message, which is used throughout the book.
The BankToCustomerStatement message is sent by the account servicer to an account
owner or to a party authorized by the account owner to receive the message. It is used to
inform the account owner, or authorized party, of the entries booked to the account, and to
provide the owner with balance information about the account at a given time.
For the COBOL application, we use the database schema that focuses on the statement as a
business object. This approach implies that the BankToCustomerStatement is saved whole
as one XML document, rather than shredding the message into smaller documents before
saving them.
FILE-OPTION Constant Operation
SQL-FILE-READ 2 Input from application to database. A regular file can be
opened, read, and closed
SQL-FILE-CREATE 4 Output from database to application. Creates a new file
if one does not exist. If one does exist, an error is
SQL-FILE-APPEND 8 Output from database to application. Appends data to an
existing file. If one does not exist, a new file is created.
SQL-FILE-OVERWRITE 16 Output from database to application. Overwrites an
existing file. If one does not exist, a new file is created.
Note: Apply PTF for currently open APAR PM25980 when using binary file reference and
locator variables. It solves issues for not UTF-8-encoded XML files.

Get Extremely pureXML in DB2 10 for z/OS now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.