Start of change

Writing a parser for the RPG DATA-INTO operation code

The DATA-INTO operation imports the data from a structured document into an RPG data structure. The operation requires a parser that parses the data in the document, and uses callback functions to pass the information about named values in the document to the RPG runtime, which places the data into an RPG data structure.

The parser may not always run to completion

Usually, the parser will be able to complete all its calls to the callback functions and return normally. However, in some cases, the call to the parser will be terminated before it has finished parsing. This can occur in the following circumstances:
  • Sufficient data has been supplied to set the RPG variable.
  • An error occurs while data is assigned to the RPG variable.
  • The sequence of calls from the parser is not correct.
Tip: If your parser has code that needs to run when the parsing is complete, enable a cancel handler to perform this code. For example, if the parser is written in RPG, code the final code in an ON-EXIT section for the parser procedure, to ensure that it runs whether the parser ends normally or abnormally.
End of change