REXX errors 16, 40 and 43 — label not found, incorrect call, routine not found
TSO/E REXX reports run-time errors as IRX00nnI, where nn is the REXX error number. The message names the exec and line; the traceback shows the failing clause.
What happened
A REXX exec stopped part way through. TSO/E printed a message starting IRX00nnI Error running followed by the exec name, the line number and a short text. With tracing on, a line marked +++ shows the clause that failed.
52 +++ signal check_totls
IRX0016I Error running MPRPT01, line 52: Label not found
61 +++ part = substr(line, 1, pos('=', line) - 1)
IRX0040I Error running MPPARSE, line 61: Incorrect call to routine
18 +++ call mpfmtdt today
IRX0043I Error running MPDAILY, line 18: Routine not foundWhat it means
TSO/E REXX error numbers run from 1 to 99 and map directly to message numbers: error 16 is IRX0016I, error 40 is IRX0040I, and so on. The message is in the TSO/E Messages manual under that ID.
- 16 — Label not found. Control was sent to a label (for example by
SIGNAL) that does not exist in the exec. - 40 — Incorrect call to routine. A routine was called with arguments it cannot accept — very often a built-in function such as SUBSTR, C2D or POS given a bad length, position or type. In the example,
posreturned 0, so the length became -1. - 43 — Routine not found. REXX searched for a function or subroutine and did not find it anywhere in the search order.
For a call, TSO/E REXX searches internal labels first, then built-in functions, then external routines: function packages, then load libraries and execs. Execs are searched in the library the caller came from, then any ALTLIB libraries, then SYSEXEC and SYSPROC (by default). A quoted name skips the internal labels.
Typical causes
- 16 — a typo in the label or in the SIGNAL target; a label removed during editing; a condition trap (
SIGNAL ON ERROR) with no matching label. - 40 — an argument computed from data that was empty or not found; non-numeric data passed where a number is required.
- 43 — a typo in the routine name; the external exec is in a library not allocated to SYSEXEC/SYSPROC in this session or batch job; a subroutine that exists only in a test library.
Symptoms
- The exec ends at once; output up to that line is produced, nothing after.
- In batch (IRXJCL or IKJEFT01), the message is in SYSTSPRT and the step return code is not zero.
- Errors 40 can be data-dependent: the same exec works for most input and fails for one record.
Where to look
- The full IRX message: exec name and line number.
- The
+++traceback line showing the clause as written. - The exec source at that line, in the ISPF editor.
- For 43, the SYSEXEC and SYSPROC allocations (in TSO,
LISTALC STATUS; in batch, the JCL).
How to diagnose
- Go to the line number in the source and read the clause.
- For 16, search the exec for the label name exactly as written, followed by a colon.
- For 40, add
trace i(ortrace r) before the failing line to see the intermediate values passed to the function. - For 43, check spelling, then check that the library holding the routine is in the search order for this environment.
How to fix
Correct the label or routine name, add the missing label, or guard the function call so bad input is caught first (for example, test that POS found the character before using its result). For 43, allocate the right library to SYSEXEC or SYSPROC, or use ALTLIB, in every environment where the exec runs — including batch.
How to prevent
- Code
SIGNAL ON SYNTAXwith a handler that displaysRC(the error number),SIGL(the line) andERRORTEXT(RC). - Validate data before passing it to built-in functions.
- Keep shared routines in one documented library that every job and logon allocates.
Production considerations
Interview question
How would you make a REXX exec report syntax errors in a useful way?
Stuck on something else?
Ask the community or search the full course.