Sign in

docs RPG Reference

File Status Codes

File Status Codes

Any code placed in the subfield location *STATUS that is greater than 99 is considered to be an exception/error condition. When the status code is greater than 99; the error indicator — if specified in positions 73 and 74 — is set on, or the %ERROR built-in function — if the ‘E’ extender is specified — is set to return ‘1’; otherwise, the file exception/error subroutine receives control. Location *STATUS is updated after every file operation.

You can use the %STATUS built-in function to get information on exception/errors. It returns the most recent value set for the program or file status. If a file is specified, %STATUS returns the value contained in the INFDS *STATUS field for the specified file.

The codes in the following tables are placed in the subfield location *STATUS for the file information data structure:

Table 1. Normal Codes

CodeDevice1RC2Condition
00000No exception/error.
00002Wn/aFunction key used to end display.
00011W,D,SQ11xxEnd of file on a read (input).
00012W,D,SQn/aNo-record-found condition on a CHAIN, SETLL, and SETGT operations.
00013Wn/aSubfile is full on WRITE operation.
Note: 1”Device” refers to the devices for which the condition applies. The following abbreviations are used: P = PRINTER; D = DISK; W = WORKSTN; SP = SPECIAL; SQ = Sequential. The major/minor return codes under column RC apply only to WORKSTN files. 2The formula mmnn is used to described major/minor return codes: mm is the major and nn the minor.

Table 2. Exception/Error Codes

CodeDevice1RC2Condition
01011W,D,SQn/aUndefined record type (input record does not match record identifying indicator).
01012Dn/aThe number of keys is not valid for %KDS.
01021W,D,SQn/aTried to write a record that already exists (file being used has unique keys and key is duplicate, or attempted to write duplicate relative record number to a subfile).
01022Dn/aReferential constraint error detected on file member.
01023D,SQn/aError in trigger program before file operation performed.
01024D,SQn/aError in trigger program after file operation performed.
01031W,D,SQn/aMatch field out of sequence.
01041n/an/aArray/table load sequence error.
01042n/an/aArray/table load sequence error. Alternate collating sequence used.
01051n/an/aExcess entries in array/table file.
01061n/an/aError handling for an associated variable for a file parameter
01071W,D,SQn/aNumeric sequence error.
011214Wn/aNo indicator on the DDS keyword for Print key.
011224Wn/aNo indicator on the DDS keyword for Roll Up key.
011234Wn/aNo indicator on the DDS keyword for Roll Down key.
011244Wn/aNo indicator on the DDS keyword for Clear key.
011254Wn/aNo indicator on the DDS keyword for Help key.
011264Wn/aNo indicator on the DDS keyword for Home key.
01201W34xxRecord mismatch detected on input.
01211alln/aI/O operation to a closed file.
01215alln/aOPEN issued to a file already opened.
012163allyesError on an implicit OPEN/CLOSE operation.
012173allyesError on an explicit OPEN/CLOSE operation.
01218D,SQn/aRecord already locked.
01221D,SQn/aUpdate operation attempted without a prior read.
01222D,SQn/aRecord cannot be allocated due to referential constraint error
01231SPn/aError on SPECIAL file.
01235Pn/aError in PRTCTL space or skip entries.
01241D,SQn/aRecord number not found. (Record number specified in record address file is not present in file being processed.)
01251W80xx 81xxPermanent I/O error occurred.
01255W82xx 83xxSession or device error occurred. Recovery may be possible.
01261Wn/aAttempt to exceed maximum number of acquired devices.
01271Wn/aAttempt to acquire unavailable device
01281Wn/aOperation to unacquired device.
01282W0309Job ending with controlled option.
01284Wn/aUnable to acquire second device for single device file
01285W0800Attempt to acquire a device already acquired.
01286Wn/aAttempt to open shared file with SAVDS or IND options.
01287Wn/aResponse indicators overlap IND indicators.
01299W,D,SQyesOther I/O error detected.
01331W0310Wait time exceeded for READ from WORKSTN file.
Note: 1. “Device” refers to the devices for which the condition applies. The following abbreviations are used: P = PRINTER; D = DISK; W = WORKSTN; SP = SPECIAL; SQ = Sequential. The major/minor return codes under column RC apply only to WORKSTN files. 2. The formula mmnn is used to described major/minor return codes: mm is the major and nn the minor. 3. Any errors that occur during an open or close operation will result in a *STATUS value of 1216 or 1217 regardless of the major/minor return code value. 4. See Figure 2 for special handling.

The following table shows the major/minor return code to *STATUS value mapping for errors that occur to programs using WORKSTN files only. See the IBM i documentation for more information on major/minor return codes.

MajorMinor*STATUS
00,02all00000
03all (except 09,10)00000
030901282
031001331
04all01299
08all012851
11all00011
34all01201
80,81all01251
82,83all01255
Note: 1. The return code field will not be updated for a *STATUS value of 1285, 1261, or 1281 because these conditions are detected before calling data management. To monitor for these errors, you must check for the *STATUS value and not for the corresponding major/minor return code value.