Literals are fixed values you embed in Easytrieve source instead of reading from files or working storage. When you MOVE 'ACTIVE' TO STATUS, compare GROSS GT 0, or assign F2P = X'123D', you are using literals. Broadcom defines three primary literal families beginners encounter daily: alphanumeric strings in single quotes, numeric constants without quotes, and hexadecimal byte patterns prefixed with X. Understanding how each type is written, how long it may be, and how the compiler converts it to match field formats prevents subtle runtime bugs in comparisons, masks, and report titles.
Identifiers name things—EMPNO, WS-TOTAL, CALC-TAX. Literals are the values themselves. The apostrophe is the primary signal: 'Y' is literal text, Y alone is a field reference if defined. Numeric literals look like numbers in other languages: 100, -45.67, +0. Hexadecimal literals use X'...' syntax for byte-level constants. Mixing these categories produces compile errors or wrong comparisons when a numeric literal is assigned to an alphabetic field without implicit conversion support.
Alphanumeric literals are enclosed in single quotes and may be up to 254 characters long. They may contain letters A through Z and digits 0 through 9. On the mainframe, EBCDIC encoding applies; ASCII applies on UNIX and Windows per Broadcom platform notes. Use alphanumeric literals in IF comparisons, MOVE and assignment statements, TITLE and LINE report text, DISPLAY messages, VALUE clauses on DEFINE, and HEADING text.
1234567IF STATUS EQ 'A' MOVE 'CLOSED' TO WS-MSG END-IF DEFINE WS-FLAG W 1 A VALUE 'Y' TITLE 01 'PAYROLL LISTING FOR ' SYSDATE
Empty strings are valid: '' represents zero characters when business logic requires clearing or initializing text fields. Trailing spaces inside quotes are significant—'AB' and 'AB ' differ in length and comparison results.
Because single quotes delimit literals, an apostrophe inside the text must be coded as two consecutive single quotes. The name O'KELLY becomes 'O''KELLY'. Forgetting to double the quote terminates the literal early and produces syntax errors or stray tokens the compiler cannot parse.
| Intent | Coded literal | Character count |
|---|---|---|
| Active status code | 'A' | 1 |
| Department label | 'HUMAN RESOURCES' | 17 |
| Name with apostrophe | 'O''KELLY' | 7 |
| Empty string | '' | 0 |
| Padded code | '001 ' | 4 (space included) |
Numeric literals contain up to 18 digits. You may prefix a plus or minus sign for algebraic sign. A single decimal point indicates fractional precision up to 18 decimal positions total across the literal. Numeric literals appear unquoted in assignments, IF numeric comparisons, arithmetic expressions, and some parameter positions. All operands in pure arithmetic expressions must be numeric fields or numeric literals.
1234567WS-COUNT = 0 WS-RATE = +125.50 WS-DISC = -0.075 IF GROSS GT 1000.00 WS-BONUS = GROSS * 0.10 END-IF
Compare numeric literal precision to field DECIMALS on DEFINE. Assigning 123.456789012345678901 to a field with fewer decimal positions truncates or rounds per product rules and field type. Integer-looking literals like 42 still participate in packed, zoned, or binary conversion when assigned to typed numeric fields.
Hexadecimal literals represent byte values not easily typed on a keyboard. Prefix with X and open a single quote: X'4040'. Each pair of hex digits compresses to one byte. Only 0-9 and A-F are permitted. Common uses include bit masks in AND, OR, and XOR expressions, initializing packed fields, and testing specific EBCDIC or binary bit patterns.
123456DEFINE F1P W 2 P MASK HEX DEFINE F2P W 2 P VALUE X'123D' F1P = F2P AND X'FFFE' F1P = F2P OR X'000F' F1P = F2P XOR X'FFFF'
X'0000' defines two bytes of binary zeros. X'40' defines one byte (EBCDIC space in many code pages). Length in bytes equals half the count of hex digits inside the quotes—an odd digit count is invalid. When DISPLAY shows hex results, verify mask width matches field LENGTH to avoid truncating high-order bits.
Sites processing double-byte character sets use DBCS literals enclosed in apostrophes with shift-out and shift-in codes marking DBCS subfields. MIXED literals combine single-byte (SBCS) and DBCS characters in one quoted string, also up to 254 bytes including shift codes. Beginners at ASCII-only shops may never code these, but multinational payroll and customer name fields depend on them. Continuation rules for DBCS literals require shift-in before the continuation character and shift-out before continuing DBCS on the next line.
On the mainframe, the compiler converts literals to match the subject element of each statement—the field, file, printer, or terminal context that receives or compares the value. On an assignment to a zoned numeric field, a numeric literal converts with format rules documented in Literal and Data Formatting Rules. On IF against an alphabetic field, alphanumeric literals must be compatible or conversion applies. Unsupported format relationships produce compile errors rather than silent corruption.
| Type | Syntax pattern | Typical use |
|---|---|---|
| Alphanumeric | 'text' | Status codes, titles, messages |
| Numeric | 123 or -45.67 | Arithmetic, thresholds, counters |
| Hexadecimal | X'4040' | Bit masks, binary initialization |
| DBCS | '[shift]...' | Kanji-only text constants |
| MIXED | 'SBCS[DBCS]' | Mixed-language headings |
TITLE and LINE statements intermix literals with field names. Literals supply column headings, punctuation, and static labels; fields supply data values. DISPLAY uses the same pattern for batch log lines. Font numbers prefixed with # on some statements apply to fields and literals in extended report processing—#1 before a literal selects a font table entry per release documentation.
When a literal exceeds column 72, use minus or plus continuation at the end of the line. Broadcom examples split VALUE 'ABC- across lines with continuation to form one logical literal ABC-DEF. Do not insert comment lines inside a continued literal. See the continuation lines tutorial for minus versus plus resume positions when splitting mid-word.
A literal is a sticker you put directly on a box instead of writing a name tag that points somewhere else. 'HELLO' is the sticker with the word HELLO on it. 42 is a sticker with the number forty-two. X'FF' is a special sticker with secret machine codes only the computer reads easily. If your sticker has a quote mark inside the words, you draw two little marks so the computer knows the sticker has not ended yet.
1. Alphanumeric literals in Easytrieve are enclosed in:
2. The maximum length of an alphanumeric literal is:
3. To code O'KELLY as a literal you write:
4. A hexadecimal literal is prefixed with:
5. Numeric literals may contain at most: