The following definitions define named constants that map to some commonly used %Status codes. Including this code in an RPG program allows you to check for errors using meaningful names instead of the actual code. For example you can code
If %Status = Recordlocked;
instead of
If %Status = 01218;
to detect a locked record. These constants can also be used with the On-error operations in a Monitor block:
On-error Recordlocked;
To use these definitions, code them (or at least the commonly used ones) in a copybook or in an error handling procedure.
Dcl-c Noerror 00000; // No exception/error occurred Dcl-c Fkeypressed 00002; // Function key used to end display Dcl-c Endoffile 00011; // End of file on read Dcl-c Notfound 00012; // No record found on CHAIN, SETLL, and SETGT Dcl-c Subfilefull 00013; // Subfile is full on WRITE operation Dcl-c Negativesqrt 00101; // Negative square root Dcl-c Dividebyzero 00102; // Divide by zero Dcl-c Resulttoosmall 00103; // Intermediate result not large enough to contain result Dcl-c Invalidchars 00105; // Invalid characters in character to numeric conversion functions Dcl-c Invaliddate 00112; // Invalid Date, Time or Timestamp value Dcl-c Dateoutofrange 00113; // Date overflow or underflow, outside *Hival or *Loval Dcl-c Datemaperror 00114; // Date mapping error. 2-character year, date range is not 1940-2039 Dcl-c Invalidcurrlen 00115; // Variable-length field has invalid current length Dcl-c Arrayoutofseq 00120; // Table or array out of sequence Dcl-c Invalidarridx 00121; // Array index not valid Dcl-c Callerror 00211; // Error calling program or procedure Dcl-c Pointererror 00222; // Pointer or parameter error Dcl-c Dumpfailed 00299; // RPG IV formatted dump failed Dcl-c Dsplyerror 00333; // Error on DSPLY operation Dcl-c Dtaaranotfound 00401; // Data area specified on IN/OUT not found Dcl-c Inouterror 00413; // Error on IN/OUT operation Dcl-c Dtaaralocked 00431; // Data area previously locked by another program Dcl-c Commitnotactiv 00802; // Commitment control not active Dcl-c Rollbackfailed 00803; // Rollback operation failed. Dcl-c Commiterror 00804; // Error occurred on COMMIT operation Dcl-c Rollbackerror 00805; // Error occurred on ROLBK operation Dcl-c Decdtaerror 00907; // Decimal data error (digit or sign not valid) Dcl-c Recexists 01021; // Tried to write record that already exists Dcl-c Fileclosed 01211; // I/O operation to a closed file Dcl-c Fileopen 01215; // OPEN issued to a file already opened Dcl-c Recordlocked 01218; // Record already locked Dcl-c Updbeforeread 01221; // Update operation attempted without a prior read. Dcl-c Permioerror 01251; // Permanent I/O error occurred Dcl-c Sessionerror 01255; // Session or device error occurred Dcl-c Jobending 01282; // Job ending with controlled option Dcl-c Ioerror 01299; // I/O error detected Dcl-c Waitexpired 01331; // Wait time exceeded for READ from WORKSTN file Dcl-c Pgmexception 09999; // Program exception in system routine