Sign in

docs RPG Reference

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

FunctionSpecification
Free-form USAGE keywordFixed-form File DescriptionOutput
Position 17Position 20Positions 18-20
Create new file1 or Add records to existing fileUSAGE(*OUTPUT)O OBlank ABlank ADD
Process fileUSAGE(*INPUT)IBlankBlank
Process file and add records to the existing fileUSAGE(*INPUT : *OUPUT)IAADD
Process file and update the records (update or delete)USAGE(*OUTPUT) or USAGE(*DELETE)UBlankBlank
Process file and add new records to an existing fileUSAGE(*UPDATE : *OUTPUT)UAADD
Process file and delete an existing record from the fileUSAGE(*DELETE : *OUTPUT)UBlankDEL
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.