Sign in

docs RPG Guide

Valid File Operations

Valid File Operations

Table 1 shows the valid file operation codes allowed for DISK files processed by keys and Table 2 for DISK files processed by non-keyed methods. The operations shown in these figures are valid for externally described DISK files and program-described DISK files.

Before running your program, you can override a file to another file. In particular, you can override a sequential file in your program to an externally described, keyed file. (The file is processed as a sequential file.) You can also override a keyed file in your program to another keyed file, providing the key fields are compatible. For example, the overriding file must not have a shorter key field than you specified in your program.

Note: When a database record is deleted, the physical record is marked as deleted. Deleted records can occur in a file if the file has been initialized with deleted records using the Initialize Physical File Member (INZPFM) command. Once a record is deleted, it cannot be read. However, you can use the relative record-number to position to the record and then write over its contents.

Table 1. Valid File Operations for Keyed Processing Methods (Random by Key, Sequential by Key, Sequential within Limits)

File-Description Specifications PositionsCalculation Specifications Positions
17182028134226-35
IP/SK/A/P/G/ D/T/Z/FCLOSE, FEOD, FORCE
IP/SAK/A/P/G/ D/T/Z/FWRITE, CLOSE, FEOD, FORCE
IP/SLK/A/P/G/ D/T/Z/FCLOSE, FEOD, FORCE
UP/SK/A/P/G/ D/T/Z/FUPDATE, DELETE, CLOSE, FEOD, FORCE
UP/SAK/A/P/G/ D/T/Z/FUPDATE, DELETE, WRITE, CLOSE, FEOD, FORCE
UP/SLK/A/P/G/ D/T/Z/FUPDATE, DELETE, CLOSE, FEOD, FORCE
IFK/A/P/G/ D/T/Z/FREAD, READE, READPE, READP, SETLL, SETGT, CHAIN, OPEN, CLOSE, FEOD
IFAK/A/P/G/ D/T/Z/FWRITE, READ, READPE, READE, READP, SETLL, SETGT, CHAIN, OPEN, CLOSE, FEOD
IFLK/A/P/G/ D/T/Z/FREAD, OPEN, CLOSE, FEOD
UFK/A/P/G/ D/T/Z/FREAD, READE, READPE, READP, SETLL, SETGT, CHAIN, UPDATE, DELETE, OPEN, CLOSE, FEOD
UFAK/A/P/G/ D/T/Z/FWRITE, UPDATE, DELETE, READ, READE, READPE, READP, SETLL, SETGT, CHAIN, OPEN, CLOSE, FEOD
UFLK/A/P/G/ D/T/Z/FREAD, UPDATE, DELETE, OPEN, CLOSE, FEOD
OBlankAK/A/P/G/ D/T/Z/FWRITE (add new records to a file), OPEN, CLOSE, FEOD
OBlankK/A/P/G/ D/T/Z/FWRITE (initial load of a new file)3, OPEN, CLOSE, FEOD
Note: 1. An L must be specified in position 28 to specify sequential-within-limits processing by a record-address file for an input or an update file. 2. Externally described files require a K in position 34; program-described files require an A,P,G,D,T,Z, or F in position 34 and an I in position 35. 3. An A in position 20 is not required for the initial loading of records into a new file. If A is specified in position 20, ADD must be specified on the output specifications. The file must have been created with the IBM i CREATE FILE command.

Table 2. Valid File Operations for Non-keyed Processing Methods (Sequential, Random by Relative Record Number, and Consecutive)

File-Description Specifications PositionsCalculation Specifications Positions
1718203444-8026-35
IP/SBlankCLOSE, FEOD, FORCE
IP/SBlankRECNOCLOSE, FEOD, FORCE
UP/SBlankUPDATE, DELETE, CLOSE, FEOD, FORCE
UP/SBlankRECNOUPDATE, DELETE, CLOSE, FEOD, FORCE
IFBlankREAD, READP, SETLL, SETGT, CHAIN, OPEN, CLOSE, FEOD
IFBlankRECNOREAD, READP, SETLL, SETGT,
UFBlankREAD, READP, SETLL, SETGT, CHAIN, UPDATE, DELETE, OPEN, CLOSE, FEOD
UFBlankRECNOREAD, READP, SETLL, SETGT, CHAIN, UPDATE, DELETE, OPEN, CLOSE, FEOD
UFABlankRECNOWRITE (overwrite a deleted record), READ, READP, SETLL, SETGT, CHAIN, UPDATE, DELETE, OPEN, CLOSE, FEOD
IRA/P/G/ D/T/Z/ F/ Blank1OPEN, CLOSE, FEOD
IRBlank2OPEN, CLOSE, FEOD
OBlankABlankRECNOWRITE3 (add records to a file), OPEN, CLOSE, FEOD
OBlankBlankRECNOWRITE4 (initial load of a new file), OPEN, CLOSE, FEOD
OBlankBlankBlankWRITE (sequentially load or extend a file), OPEN, CLOSE, FEOD
Note: 1. If position 34 is blank for a record-address-limits file, the format of the keys in the record-address file is the same as the format of the keys in the file being processed. 2. A record-address file containing relative record numbers requires a T in position 35. 3. The RECNO field that contains the relative record number must be set prior to the WRITE operation or if ADD is specified on the output specifications. 4. An A in position 20 is not required for the initial loading of the records into a new file; however, if A is specified in position 20, ADD must be specified on output specifications. The file must have been created with one of the IBM i file creation commands.