Writing a generator for the RPG DATA-GEN operation code
The DATA-GEN operation generates a structured document from an RPG variable. The operation requires a generator that creates the document using the names and values repeatedly passed to it by DATA-GEN. The generator uses callback functions to pass the text for the document to the RPG runtime, which places the data into an RPG variable or a file in the Integrated File System.
Handling clean-up activitiesUsually, the generator can perform its clean-up activities during an "end' event. However, in some cases, there may not be an "end" event. This can occur in the following circumstances:
- An error occurs during the DATA-GEN operation.
- A DATA-GEN *START operation begins a sequence of DATA-GEN operations, but no matching DATA-GEN *END operation is done before the RPG procedure ends. See Sequences of DATA-GEN operations.