Positions 18-20 (Record Addition/Deletion)
Positions 18-20 (Record Addition/Deletion)
Entry : Explanation
ADD : Add a record to the file or subfile.
DEL : Delete the last record read from the file. The deleted record cannot be retrieved; the record is deleted from the system.
An entry of ADD is valid for input, output, or update files. DEL is valid for update DISK files only. When ADD is specified, there must be an A in position 20 of the corresponding file-description specification.
If positions 18-20 are blank, then for an output file, the record will be added; for an update file, the record is updated.
The Record-Addition/Deletion entry must appear on the same line that contains the record type (H, D, T, E) specification (position 17). If an AND/OR line is used following an ADD or DEL entry, this entry applies to the AND/OR line also.
Table 1. Processing Functions for Files
| Function | Specification | |||
|---|---|---|---|---|
| Free-form USAGE keyword | Fixed-form File Description | Output | ||
| Position 17 | Position 20 | Positions 18-20 | ||
| Create new file1 or Add records to existing file | USAGE(*OUTPUT) | O O | Blank A | Blank ADD |
| Process file | USAGE(*INPUT) | I | Blank | Blank |
| Process file and add records to the existing file | USAGE(*INPUT : *OUPUT) | I | A | ADD |
| Process file and update the records (update or delete) | USAGE(*OUTPUT) or USAGE(*DELETE) | U | Blank | Blank |
| Process file and add new records to an existing file | USAGE(*UPDATE : *OUTPUT) | U | A | ADD |
| Process file and delete an existing record from the file | USAGE(*DELETE : *OUTPUT) | U | Blank | DEL |
| Note: Within RPG, the term create a new file means to add records to a newly created file. Thus, the first two entries in this table perform the identical function. Both are listed to show that there are two ways to specify that function. |