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 by using the names and values that are 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 activities
Usually, the generator can perform its clean-up activities during an "end' event. However, in some cases, there might not be an "end" event. This situation 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.
Tip:
If your generator has code that needs
to run when the generation is complete, set the doTerminateEvent
subfield in the parameter that passed to the generator to '1'.
If that indicator is on after the most recent call to the generator, the
RPG runtime calls the generator with a QrnDgEvent_12_Terminate
event.
Warning: During the
QrnDgEvent_12_Terminate event,
the generator cannot call the callback procedures.
Attempting to do so results in an exception.