Character data—names, addresses, status codes, email tokens, product descriptions—is the bread and butter of report titles and file extracts. In Easytrieve, character fields use data type A for alphanumeric. Each byte typically holds one EBCDIC or ASCII character on single-byte character set systems. Character is not a separate keyword; A on a DEFINE line declares how the compiler treats storage, comparisons, and assignments. Misunderstanding character versus numeric types causes leading zeros to vanish, amounts to concatenate as text, and IF comparisons to fail when case or padding differs. This page explains character storage, encoding, length limits, and how A fields behave in logic and reports.
Broadcom defines A as alphanumeric: use when numeric types N, P, B, U, or I do not apply. Character data includes letters, digits, punctuation, and spaces stored as character encodings—not as calculated numbers. A employee name field of length twenty holds twenty bytes—if the name is shorter, remaining bytes are typically spaces unless data arrived differently from the file.
123456FILE CUSTMAST FB(200 2000) CUSTID 1 8 A CUSTNAME 9 30 A STATUS 39 1 A DEFINE WS-MSG W 60 A VALUE 'PROCESSING COMPLETE'
Character fields may be 1 through 254 bytes. FILE definitions pair POSITION (or sequence after prior fields), LENGTH, and A. Wrong length truncates names on reports or reads into the next field bytes. Match COBOL PIC X(n) lengths exactly. Overlay definitions can reuse the same bytes with different A field names for alternate views of the same record slice.
| Parameter | Role for character data |
|---|---|
| Position | Starting byte in record (1-based) |
| Length | Number of character bytes (max 254) |
| A | Alphanumeric type code |
| VALUE | Initial literal for working storage |
| HEADING | Default report column title |
| MASK | Edit pattern for DISPLAY and reports |
| VARYING | Variable length with 2-byte prefix |
Default file A fields use EBCDIC encoding on z/OS. Letter A is X'C1' in EBCDIC, digit 1 is X'F1'. Comparisons and sorts follow EBCDIC collating sequence—letters and numbers order differently than ASCII tables. When you MOVE a literal 'A' to a field, the compiler stores the EBCDIC byte. Porting files without translating character fields produces garbage text on ASCII systems.
Declare ASCII on FILE CODE parameter or PARM when files originate from UNIX or Windows. Working storage A fields follow PARM CODE PROCESS. Mixed shops compiling the same program against EBCDIC production files and ASCII test files need separate test data or conversion utilities. Character comparisons in IF use the active code page—'ABC' literal bytes must match file bytes for EQ to succeed.
Working storage A fields initialize to blanks at program start unless VALUE sets another literal. FILE fields read from input carry whatever bytes the record contains—often space-filled for unused name columns. INITIAL and VALUE on DEFINE control starting content for WS fields used as message buffers and flags. Single-character flags like Y/N are A 1 fields compared to one-character literals in IF.
Character IF tests use EQ, NE, GT, LT, GE, LE with relational meaning per collating sequence. EQ compares byte by byte for the defined field length—trailing spaces matter. Comparing STATUS EQ 'A' tests one byte against the literal. Partial comparisons sometimes use overlay fields or indexing rather than built-in substring functions. Case sensitivity follows stored bytes—uppercase file data needs uppercase literals.
1234567IF STATUS EQ 'A' MOVE 'ACTIVE' TO WS-DESC END-IF IF CUSTNAME GT 'M' * collating sequence comparison—not "alphabet after M" END-IF
LINE and TITLE statements list A fields for column output. MASK on DEFINE edits character display—insert commas, suppress leading zeros on numeric-looking text, or format dates stored as character. HEADING provides default column titles. Character fields without MASK print as stored, including trailing spaces unless report writer trims per options.
VARYING on type A creates a two-byte binary length followed by data bytes—pattern for VARCHAR database columns. Total field length includes length prefix plus maximum data size. Reference FLDA for entire field, FLDA:LENGTH for prefix only, FLDA:DATA for text portion per Broadcom Define Files and Fields. DISPLAY HEX shows length and data for debugging.
Account numbers and zip codes with leading zeros belong in A fields—defining them as N drops leading zeros on display and may alter comparisons. Salary amounts belong in P or N with decimals for SUM. When a field holds only digits but is not used in arithmetic, A is often still correct for preservation of leading zeros and exact file layout match.
When character data includes Japanese or Chinese double-byte scripts, K (DBCS) or M (mixed SBCS/DBCS) replace simple A. Shift-in and shift-out codes mark DBCS regions. Beginners in ASCII-only environments may skip K and M until requirements specify multinational data. Literal rules differ—see Literal and Data Formatting Rules before mixing A literals with K fields.
Character data is writing letters in boxes—one letter per box for simple English text. Type A means each box holds a letter, number symbol, or space written the way the mainframe alphabet works. If you use the wrong alphabet book—EBCDIC versus ASCII—the same boxes show different squiggles. Names and words go in A boxes; money math uses different number boxes called P or N.
1. The Easytrieve character data type code is:
2. Maximum length for type A fields is:
3. Working storage A fields initialize to:
4. File A fields are EBCDIC unless:
5. Decimal positions on type A are: