RTNDTA (Return Data) keyword for display files

You use this record-level keyword to specify that when your program sends an input operation to this record format, the IBM® i operating system is to return the same data that was returned on the previous input operation sent to this record format.

The RTNDTA keyword is ignored if the record format has not already been read. When the RTNDTA keyword is in effect, your program can reread data on the display without requiring the IBM i operating system to actually pass data from the display device to your program.

This keyword has no parameters.

The RTNDTA keyword is ignored in the following situations:
  • On the input portion of an input/output operation (Put-Get operation)
  • On an input operation that is preceded by an output operation to the same record format

The RTNDTA keyword has effect only on an input operation sent to the same record format without an intervening output operation to that record format.

You can use RTNDTA as follows:
  • Use RTNDTA to allow a main program to read a record format that is changed by a workstation user. The data read tells the main program which subprogram to call. The subprogram sends an input operation to the same record format, with RTNDTA in effect, to read the same data. This procedure can substitute for passing parameters to subprograms.
    Note: SHARE(*YES) must be specified for both display files.
  • Use RTNDTA to allow an RPG III program to perform file maintenance with less locking of records in the database. For instance, the program reads a database record and displays the record at the display device. The workstation user reviews the record, makes any required changes, and presses the Enter key. While the workstation user is making changes, the database record, if locked, is unavailable to other programs. Hence it is recommended to leave the database record unlocked. However, when the program reads the record from the display and updates the database record, the database record overlays the internal representation of the display record in the program. Instead of preventing the overlay by using different field names for the display record and the database record, the program rereads the display file. With RTNDTA specified, the program retrieves the display record again and can then finish updating the database.

If the UNLOCK keyword is specified, the RTNDTA keyword cannot be specified.

Option indicators are not valid for this keyword.

Example

The following example shows how to specify the RTNDTA keyword.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A          R RECORD1                   RTNDTA
00020A            FLD1           5   I  2  2
00030A            FLD2           5   B  3  2
     A