RPG/400 Help

WRITE (Create New Records)

*---------*---------------*-----------------*----------------*---------------*
|   CODE  |    FACTOR 1   |     FACTOR 2    |     RESULT     |  INDICATORS   |
|         |               |                 |      FIELD     |               |
*---------*---------------*-----------------*----------------*---------------*
| WRITE   |               | File name       | Data           |    _ ER _     |
|         |               |                 | structure      |               |
*---------*---------------*-----------------*----------------*---------------*

The WRITE operation writes a new record to a file.

Factor 2 must contain the name of a file. A record format name is required in factor 2 with an externally described file. A file name in factor 2 is required with a program described file, and the result field must contain the name of a data structure. The record is written directly from the data structure to the file. The result field must be blank if factor 2 contains a record format name.

The result field must be a data structure name.

Positions 56 and 57 can contain an indicator to be set on if the WRITE operation is not completed successfully. The indicator in positions 56 and 57 will be set on if overflow is reached to an externally described print file and no overflow indicator has been specified on the File description specification. On a WRITE to a subfile (SFILE) record name, you can specify an indicator in positions 58 and 59; it is set on when the subfile is filled.

When using the WRITE operation remember:

See Figure "WRITE Operation" for an example of the WRITE operation.

WRITE Example

Figure 63. WRITE Operation

*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C*  The WRITE operation writes the fields in the data structure
C*  DS1 to the file, FILE1.
C*
C                     WRITEFILE1     DS1                ADD RECORD


[ Top of Page | Previous Page | Next Page | Table of Contents ]