Easytrieve CHAR (Type A)

Documentation and forums often say CHAR when they mean character fields—the bytes that store names, codes, and messages. In Easytrieve source, that role is filled by the single letter A on DEFINE and FILE lines, not a spelled-out CHAR keyword like some SQL dialects use. Learning to read 20 A as twenty-byte alphanumeric prevents confusion when migrating from COBOL PIC X or from languages with explicit char types. This page focuses on the syntax pattern for declaring CHAR-equivalent fields, optional parameters that apply only to A, and examples you can paste into Library sections.

Progress0 of 0 lessons

Reading the A Type Code

After field length on DEFINE or FILE, the next token is the data type letter. A signals alphanumeric: each byte is a character in the active code page. Contrast with N for zoned numeric, P for packed, B for binary. The letter is always uppercase in manuals; lowercase a may compile but violates style guides. 30 A means thirty character bytes, not thirty characters of a different encoding width—DBCS uses K or M instead.

text
1
2
3
4
5
6
FILE ORDERS FB(100 1000) ORDERID 1 10 A SHIPTO 11 35 A COUNTRY 46 3 A DEFINE WS-BUFFER W 132 A

DEFINE Syntax for CHAR (A) Fields

Working storage character fields use W as location instead of a record position. Required tokens: field-name, W, length, A. Optional: VALUE literal, HEADING, MASK, VARYING, OCCURS, INDEX. Omit DEFINE keyword when fields immediately follow their FILE—the field line alone suffices in Library section FILE blocks.

CHAR (A) DEFINE examples
DefinitionMeaning
WS-FLAG W 1 ASingle-byte Y/N flag
WS-MSG W 40 A VALUE 'READY'40-byte message initialized
WS-LINE W 80 AFull print line buffer
WS-CODE W 5 A HEADING 'CODE'Report column heading set
WS-VAR W 252 A VARYINGMax 250 data + 2 length bytes

FILE Syntax for CHAR Fields

FILE field lines list name, starting byte position, length, A. Positions are one-based within the record. Sequential fields must not overlap unless intentional overlay. Character length must match external layout—if COBOL copybook shows PIC X(20) at byte 100, Easytrieve declares position 100 length 20 type A.

text
1
2
3
* COBOL: 05 CUST-NAME PIC X(30) at byte offset 10 FILE CUSTFILE FB(80 800) CUSTNAME 10 30 A

Parameters Valid for A Only

VALUE accepts quoted alphanumeric literals matching field length or shorter with padding rules on assignment. HEADING supplies default report titles. MASK edits output—character masks use A in mask identifier lists like MASK (A BWZ 'text'). VARYING applies only to A for variable-length SQL-style fields. DECIMALS and EVEN are invalid on A. INTEGER, ROUNDED, TRUNCATED on assignment apply to numeric receives, not to declaring A.

CHAR Length Limits

Minimum length 1 byte. Maximum 254 bytes for standard A fields. Report LINE width and LINESIZE may display fewer characters than defined length—truncation is a report layout issue, not a DEFINE error. When BUFFER spans multiple physical records, declare separate FILE fields or use OCCURS with INDEX for table character slots.

CHAR vs PIC X Translation

COBOL PIC X(n) maps to n A in Easytrieve with matching position. PIC A(n) alphabet only still uses A type in Easytrieve—validation of alphabetic-only content is application logic, not type enforcement. PIC X with VALUE SPACES parallels A working storage default blanks. Group items in COBOL become multiple A fields or one large A spanning the group length depending on whether you need subfields addressable.

CHAR and Literals in MOVE

Assign character fields from quoted literals or other A fields. MOVE 'ABC' TO WS-CODE fills bytes; shorter literals pad with spaces in longer fields per assignment rules. Assigning numeric fields to A may produce edited character digits in the receive field—useful for DISPLAY without separate picture clauses. Assigning A to numeric types requires numeric content or conversion errors.

text
1
2
3
4
5
DEFINE F1A W 4 A DEFINE F2N W 4 N 0 VALUE 1234 F1A = F2N * F1A may contain edited character digits per assignment examples

CHAR with MASK

MASK controls how character fields print. Mask literals in quotes define punctuation positions. BWZ suppresses leading zeros on numeric-looking character data. Report LINE uses MASK from DEFINE when present. Test masks with small DISPLAY statements before batch runs producing thousands of pages—mask errors are visible immediately in SYSPRINT.

When Not to Use A

  • Amounts that SUM on reports—use P or N with decimals.
  • Binary counters from APIs—use B or I.
  • Double-byte Japanese text in one field—use K or M.
  • Dates stored as binary integers—often P or special date types.

Common CHAR (A) Syntax Mistakes

  1. Coding A 2 with decimal positions after A.
  2. Using CHAR or X instead of letter A on DEFINE.
  3. Length mismatch versus copybook—off-by-one shifts entire file map.
  4. VALUE literal longer than field length without truncation awareness.
  5. VARYING length forgetting two-byte prefix in total length.

Explain It Like I'm Five

CHAR is what grown-ups call the A sticker on a storage box. The sticker says this box holds letters, not special money-number packing. The number before A tells how many letter slots are in the box—like 20 A means twenty slots. You write the letter A in your instruction book because Easytrieve does not spell out CHAR in the rules.

Exercises

  1. Convert COBOL PIC X(15) at position 50 to Easytrieve FILE syntax.
  2. Define WS-ERR-MSG as 80-byte A with VALUE literal.
  3. List three optional parameters valid on A fields.
  4. Explain why A 2 is invalid syntax.
  5. Write MOVE from literal to single-byte flag field.

Quiz

Test Your Knowledge

1. On a DEFINE line, letter A means:

  • Alphanumeric (character) data
  • ASCII only
  • Automatic length
  • Array

2. Valid DEFINE for 10-byte character working storage:

  • DEFINE WS-CODE W 10 A
  • DEFINE WS-CODE W 10 A 2
  • DEFINE WS-CODE W 10 CHAR
  • DEFINE WS-CODE 10 X

3. CHAR fields in FILE statements need:

  • Position, length, and A
  • Only name and A
  • JCL DD
  • REPORT name

4. VALUE on an A field accepts:

  • Alphanumeric quoted literal
  • Numeric literal only
  • Hex only
  • No literals

5. MASK on A fields controls:

  • Display editing on reports and DISPLAY
  • JCL CLASS
  • Sort order
  • Packed length
Published
Read time13 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 type A DEFINE and FILE syntaxSources: Broadcom Easytrieve Report Generator 11.6 TechDocs, DEFINE Statement, Describe Files and FieldsApplies to: Easytrieve CHAR type A field declaration