Easytrieve Character Data Type

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.

Progress0 of 0 lessons

Type A — Alphanumeric Character Storage

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.

text
1
2
3
4
5
6
FILE 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'

Length and Layout

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.

Character field parameters
ParameterRole for character data
PositionStarting byte in record (1-based)
LengthNumber of character bytes (max 254)
AAlphanumeric type code
VALUEInitial literal for working storage
HEADINGDefault report column title
MASKEdit pattern for DISPLAY and reports
VARYINGVariable length with 2-byte prefix

EBCDIC on the Mainframe

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.

ASCII Files and PARM CODE

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.

Initialization and Default Values

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.

Comparisons and IF Logic

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.

text
1
2
3
4
5
6
7
IF STATUS EQ 'A' MOVE 'ACTIVE' TO WS-DESC END-IF IF CUSTNAME GT 'M' * collating sequence comparison—not "alphabet after M" END-IF

Character in Reports

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 Length Character Fields

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.

Character vs Numeric for Digits

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.

DBCS Character Types K and M

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.

Common Character Type Mistakes

  1. Using N for a nine-digit ID that must keep leading zeros.
  2. Wrong length truncating names on customer reports.
  3. Comparing unequal lengths without noticing trailing spaces.
  4. Assuming ASCII test file matches EBCDIC production comparisons.
  5. Adding decimal positions to A fields—invalid syntax.

Explain It Like I'm Five

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.

Exercises

  1. Define a 30-byte character name field and 1-byte status flag in a FILE.
  2. Write IF logic comparing status to Y and N literals.
  3. Explain why zip codes should often be A not N.
  4. State default initialization for working storage character fields.
  5. Describe when VARYING applies to character data.

Quiz

Test Your Knowledge

1. The Easytrieve character data type code is:

  • A (alphanumeric)
  • C (character)
  • X (text)
  • S (string)

2. Maximum length for type A fields is:

  • 254 bytes
  • 80 bytes
  • 128 bytes
  • 18 bytes

3. Working storage A fields initialize to:

  • Blanks (spaces)
  • Zeros
  • LOW-VALUES
  • NULL

4. File A fields are EBCDIC unless:

  • FILE or PARM declares ASCII CODE
  • JOB names ASCII
  • REPORT LINESIZE 132
  • Always ASCII

5. Decimal positions on type A are:

  • Not allowed
  • Required
  • 0 through 18
  • Only on reports
Published
Read time14 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 type A alphanumeric field rulesSources: Broadcom Easytrieve Report Generator 11.6 TechDocs, DEFINE Statement, Describe Files and FieldsApplies to: Easytrieve alphanumeric character fields type A