Handling output data

Several operations require the handler to use output data from the RPG program.

Using the recordName subfield

If the file is externally described, use the recordName subfield to determine which record format is associated with the output data.

Using the relative record number

The RPG programmer may use the RECNO to specify the relative record number for the new record. For system files, the relative record number may only be used to write to existing records which have been deleted. If the rrn subfield is greater than zero, then the RPG programmer intends the record to replace the deleted record at the specified relative record number.

Handling output data using data structures

  • Use the outputBuffer pointer subfield to locate the output buffer for the file and use the outputBufferLen subfield to determine the number of bytes provided for the output buffer.
  • For an externally-described file, use the outputNullMap pointer subfield to access the output null map for the file and use the outputNullMapLen subfield to determine the number of bytes provided for the output null map. The output null map is an array of indicators with one element for each field in the record. For a field which is null-capable, a value of '1' indicates that the field has the null value, and a value of '0' indicates that the field does not have the null value. For a field which is not null-capable, the value will always be '0'. If the outputNullMap pointer is null, the output null map is not relevant for the file within the RPG program.
  • For an externally-described file, use the value of each field in the output buffer according to the data type of the field, and if null-values are relevant for the file, use the indicator in the output null map for each null-capable field.
  • For a program-described file, use the output buffer according to the definition of the record that is agreed upon by the RPG programmer and the handler provider.

Handling output data using name-value information

  • Use the namesValues pointer subfield to access the array of information about each field in the record format.
  • For each output field, or each input or output field in the case of a subfile record format
    • Use the value pointer subfield to locate the buffer available for the field.
    • Use the valueLenBytes subfield to determine the the number of bytes available in the buffer.
    • Use the value of the field in the buffer, according to the data type of the field. See Data types used in name-value information for more information.
    • If the isNullCapable subfield indicates that the field is null-capable, use the hasNullValue to determine whether the field has the null value.