Easytrieve Binary (Type B)

Binary type B stores raw bytes—not zoned digits, not packed nybbles. Mainframe programs use binary for bit flags, binary counters from system APIs, and COBOL COMP/COMP-4 layouts. Easytrieve distinguishes quantitative B fields with decimal positions where the high-order bit is sign from non-quantitative B where every bit is data. Confuse the two and sign handling inverts. Bit manipulation with AND, OR, and XOR hex masks clears status bits and merges flag bytes. Currency belongs in P, not B—but B is essential for interface records and low-level control blocks. This page teaches declaration, sign rules, masks, and debugging.

Progress0 of 0 lessons

Declaring Type B Fields

Syntax: field-name, location, length, B, optional decimal positions. FLAGS 20 2 B defines two-byte non-quantitative binary—sixteen data bits. COUNTER 22 4 B 0 defines four-byte quantitative binary integer with zero decimals—sign bit applies. Length typically up to four bytes in standard tables; verify DEFINE documentation for your release capacity.

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

Quantitative vs Non-Quantitative

Binary field modes
ModeDecimal positionsHigh-order bitTypical use
Non-quantitativeOmittedData bitFlags, bit maps, raw bytes
Quantitative0-10 specifiedSign bitBinary numeric values

Specifying decimal positions—even 0—makes B quantitative. Omitting decimals entirely yields non-quantitative where all bits contribute to magnitude without signed interpretation. Choose mode before writing IF comparisons on high bit as flag versus sign.

Bit Manipulation Assignments

Logical assignment format: receive = send AND mask, OR mask, XOR mask. Masks may be hex literals X'FFFE' or binary-friendly fields. AND clears bits where mask is zero. OR sets bits where mask is one. XOR toggles bits. Broadcom assignment examples use packed fields with MASK HEX for display—binary logic applies to underlying bytes. Test each operation with DISPLAY HEX before production flag updates.

B vs I Integer

Type I is native integer—must be 2, 4, or 8 bytes, decimals blank or zero, host endianness. Type B supports up to four bytes with optional decimal semantics as binary numeric. APIs documenting 32-bit int may map to I 4; bitfield structures from COBOL may map to B 2 non-quantitative. Do not interchange blindly—hex patterns differ.

COBOL COMP Alignment

COBOL COMP binary items align to B fields when length and decimal usage match. SYNC boundaries in copybooks affect starting position—Easytrieve FILE position must match physical layout. COMP-4 and COMP-5 variants may differ from older COMP—consult copybook for exact byte length.

Arithmetic on Binary

Quantitative B fields participate in arithmetic expressions with conversion to internal forms. Adding two binary counters works when both quantitative with matching decimals. Non-quantitative B in arithmetic may misinterpret sign bit as data—keep flags separate from math fields. SUM on reports applies to quantitative B rarely in business reports— usually P and N dominate totals.

DISPLAY HEX Debugging

DISPLAY HEX reveals bit patterns invisible in character DISPLAY. Compare before and after AND OR XOR operations. Mask width must match field length—two-byte field uses four hex digits inside X'....'. Varying fields exclude standard HEX in some contexts per screen formatting docs—use fixed B for flag tutorials.

When to Use B

  • Status halfword flags from subsystem APIs.
  • Binary record counts in control blocks.
  • COBOL copybook COMP binary items.
  • Bit testing before conditional IF logic.
  • Hex initialization VALUE X'0000' on small fields.

When Not to Use B

  • Employee salaries and tax amounts—use P.
  • Display numeric reports—use N or P with MASK.
  • Character codes with leading zeros—use A.
  • Portable cross-platform integers—I with endian caution.

Common Binary Mistakes

  1. Using quantitative B for pure bit flags—sign bit corrupts flag test.
  2. Wrong mask width—X'FF' on four-byte field misses high words.
  3. Declaring COMP-3 packed file field as B.
  4. Expecting DISPLAY decimal readable output on flag bytes.
  5. Mixing endian assumptions from PC test on z/OS production.

Explain It Like I'm Five

Binary fields are rows of light switches—on or off in each spot. Sometimes the first switch means plus or minus for a number; sometimes every switch is just a flag for something like is the door open. AND OR XOR are rules for flipping groups of switches using a stencil (the mask). You look at the switches in hex code because they are too small to read as letters.

Exercises

  1. Define 2-byte non-quantitative B flags field.
  2. Write F1 = F2 AND X'00FF' and explain cleared bits.
  3. Contrast quantitative B 2 0 vs non-quantitative B 2.
  4. State when B is preferred over P for a field.
  5. Describe DISPLAY HEX verification after XOR mask.

Quiz

Test Your Knowledge

1. Binary numeric fields use type letter:

  • B
  • I
  • P
  • X

2. Non-quantitative B field high-order bit is:

  • A binary digit (data bit)
  • Always sign only
  • Unused
  • Always zero

3. Quantitative B field high-order bit is:

  • Sign bit
  • Always padding
  • Zone nybble
  • Parity

4. Bit masks in assignment use operators:

  • AND OR XOR with hex literals
  • ONLY plus
  • ONLY EQ
  • JCL

5. Maximum binary field length documented is:

  • 4 bytes
  • 18 bytes
  • 10 bytes
  • 254 bytes
Published
Read time13 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 type B binary and logical assignment masksSources: Broadcom Easytrieve Report Generator 11.6 TechDocs, DEFINE Statement, Assignments and MovesApplies to: Easytrieve binary type B fields and bit operations