Supported RPG Features

After READC returns a changed subfile record, the program can modify field values and issue UPDATE on the subfile format to write those changes back to the in-memory subfile buffer. The updated values are visible when the subfile is next displayed via EXFMT SFLCTL.

DOW NOT Done;
  READC SFLREC;
  IF %EOF();
    Done = *ON;
  ELSE;
    // Process the changed record, then clear the option field
    OPT = *Blank;
    UPDATE SFLREC;
  ENDIF;
ENDDO;

// Next EXFMT shows the cleared OPT field
EXFMT SFLCTL;

UPDATE targets the subfile record at the RRN of the most recent READC or CHAIN. No other subfile I/O operations should be performed between the READC/CHAIN and the UPDATE.

Issuing UPDATE on a subfile format without a prior successful READC (or CHAIN) raises a runtime error with file status 1221 ("Update or delete without a prior input operation"). Programs can trap this with a MONITOR/ON-ERROR block or the (E) extender.

For a WORKSTN file, the format named on UPDATE must be a subfile record format that the DCL-F exposes via the SFILE keyword. The compiler rejects the following at compile time (reported as "Factor 2 is not a WORKSTN subfile-format name"):

(UPDATE on a disk record format remains valid and is unaffected by these checks.)