Defining a table is declaring a miniature file whose only job is lookup—not sequential GET per transaction, not VSAM update, not report spool. Broadcom wires TABLE into the FILE statement: you name the table, mark TABLE (and optionally INSTREAM), specify ARG for keys and DESC for returned text or values, supply rows either embedded in source or read from an external sequential dataset at JOB initiation, and terminate instream data with ENDTABLE. Every byte in ARG and DESC layout must align with WITH and GIVING fields you use later in SEARCH. Keys must ascend with no duplicates because the runtime builds a binary search structure at load. Beginners treat tables like ordinary input files and wonder why SEARCH mis-decodes department 902 as FINANCE on one run and garbage on the next—usually unsorted instream rows or a WITH field three bytes shorter than ARG. This page walks through instream and external definition line by line, max-table-entries sizing, the 254-byte limits, preparing operations-owned reference files, macro packaging, and compile-time errors that catch sloppy layouts before production night.
1234567891011DEFINE WS-NAME W 30 A DEFINE WS-CODE W 4 A FILE STATES TABLE INSTREAM ARG 1 2 A DESC 4 20 A AL ALABAMA AK ALASKA AZ ARIZONA AR ARKANSAS ENDTABLE
FILE STATES names the table file used in SEARCH STATES. TABLE marks searchable reference data. INSTREAM loads following rows at compile. ARG 1 2 A is a two-byte alphanumeric key starting column one on each instream line. DESC 4 20 A is twenty bytes from column four for state name. Data rows place keys in ARG columns and descriptions in DESC columns—spacing must match definitions exactly. ENDTABLE ends the instream section.
ARG syntax follows FILE field definition pattern: ARG start-column length type. Start column is one-based position within the logical table row. Length is byte count for the search key. Type A is alphanumeric; N numeric; P packed with optional decimals; other types follow FILE rules where supported. SEARCH WITH operand must match ARG length and compatible type— a WITH field of three bytes against ARG 1 4 A leaves the fourth byte undefined in comparison. Numeric ARG with leading zeros in instream data must match how transaction files store codes—pad or define consistently.
DESC uses the same start-length-type syntax for the value SEARCH copies to GIVING on success. Often DESC holds human-readable text, but numeric rates or dates are valid when GIVING target matches. DESC is not searched—only ARG participates in binary search. Multiple conceptual columns in reference data must be packed into one DESC layout or split across multiple tables if you need separate SEARCH calls per attribute.
| Aspect | ARG | DESC |
|---|---|---|
| Purpose | Lookup key | Result payload |
| SEARCH clause | Compared to WITH | Copied to GIVING |
| Sort requirement | Ascending, unique | No sort requirement |
| Max length | 254 bytes | 254 bytes |
ENDTABLE is not optional for instream tables. Broadcom requires the terminator in columns one through eight with column nine blank—same discipline as other Easytrieve special names. Rows after ENDTABLE belong to program structure again, not table data. Omitting ENDTABLE confuses the compiler about where data ends; misplaced ENDTABLE truncates rows silently. In code reviews, verify ENDTABLE alignment with the same care as JOB and REPORT headers.
123FILE DEPTREF TABLE 500 ARG 1 3 N DESC 5 25 A
DEPTREF has no INSTREAM keyword. TABLE 500 reserves space for five hundred entries—adjust for peak row count plus growth. JCL allocates a sequential reference file to DD name matching DEPTREF. At JOB initiation Easytrieve reads rows until EOF or entry limit. Row layout in the file must match ARG 1 3 N and DESC 5 25 A positions. Operations maintains DEPTREF outside compile cycles; developers change max-table-entries when capacity planning demands.
| Scenario | Guidance |
|---|---|
| Stable 200-row code table | TABLE 250 margin for growth |
| Annual ten percent growth | Revisit entry limit yearly |
| Overflow at runtime | Table overflow error—increase limit or prune data |
| Undersized limit | Silent truncation risk—always size above peak |
Use fixed columns in the editor—monospace alignment prevents keys drifting into DESC territory. For numeric ARG, right-align or zero-fill consistently with transaction file definitions. Comment in source above large instream blocks listing owner team and last verification date. When tables exceed roughly one screen of rows, consider external files so diffs stay readable in version control.
1234567FILE ERRMSG TABLE INSTREAM ARG 1 4 A DESC 6 50 A E001 Invalid department code submitted E002 Pay amount exceeds policy maximum E003 Employee record not found on master ENDTABLE
Shared code tables belong in macros included by many programs. Place entire FILE TABLE block through ENDTABLE inside one macro—splitting ARG from rows across macros breaks compile expectations. Consumers invoke macro name in Library; each program SEARCH uses the table file name declared in the macro. Change once, recompile dependents.
| Symptom | Likely definition cause |
|---|---|
| WITH/GIVING length mismatch | DEFINE shorter than ARG or DESC |
| Missing ENDTABLE | Instream terminator omitted or misaligned |
| Table overflow at run | max-table-entries too small for external file |
| Invalid field type for table | Nullable or varying length on ARG/DESC |
Defining a table is writing the rules for a cheat sheet before you fill in answers. ARG tells where the secret code sits on each line and how long it is. DESC tells where the plain-English answer sits and how long that answer can be. INSTREAM means you type the cheat sheet lines right into your program homework. External means the teacher hands you a printed cheat sheet at the door. ENDTABLE is writing THE END so the computer knows you finished the list. You must number codes from smallest to biggest without repeating a code, or the computer's quick lookup trick breaks.
1. ARG on a TABLE file defines:
2. ENDTABLE must appear:
3. Maximum ARG and DESC length on table files is:
4. External TABLE files need:
5. Duplicate ARG values in one table are: