Easytrieve Conversion Functions Index

Conversion transforms data from one internal or external representation to another—character digits into packed amounts, packed payroll totals into zoned tape format for legacy downstream, binary counters into printable SYSPRINT columns. Easytrieve performs much conversion implicitly on assignment and MOVE when source and target types differ in Library DEFINE. Explicit conversion functions appear in Plus Application Reference for specialized radix and edit operations. MASK on DEFINE influences how numeric stores render when moved to alphabetic output. Beginners confuse conversion with formatting—conversion answers what bytes mean; formatting answers how humans read them on paper. Invalid source data causes runtime failures during conversion—validate before MOVE from partner files. This index catalogs conversion mechanisms, documents type pairs, explains promotion rules at high level, and links to formatting index for display-only masks.

Progress0 of 0 lessons

Types Involved in Conversion

Easytrieve quantitative types include N zoned numeric, P packed decimal, B binary, F floating where documented. Alphabetic A and bit patterns B for flags. Conversion paths depend on source-target pair—see data types tutorials for packed zoned binary alphabetic deep dives. Length and decimal count on DEFINE determine truncation on convert.

Conversion Capabilities Index

Conversion paths and mechanisms
FromToMechanism
P packedN zonedAssignment with scale rules
N numericA displayAssignment + MASK
A digit stringN or PAssignment parse per rules
B binaryN or PMOVE or assign promote
NumericInteger wholeINTEGER on assignment
FractionalRounded currencyROUNDED on assignment
Date internalDisplay dateMASK or date format
Hex literalBit fieldAssignment X'...' pattern

Assignment and MOVE Conversion

Primary conversion vehicle: TARGET = SOURCE or MOVE SOURCE TO TARGET. Compiler applies documented conversion between types. Truncation drops high or low digits when target shorter. Padding adds spaces to alphabetic or leading zeros per edit. Test every production path with maximum and minimum source values plus invalid partner samples.

text
1
2
3
4
5
6
DEFINE WS-AMT W 7 P 2 DEFINE WS-PRINT W 9 A MASK 'ZZZ,ZZ9.99' JOB ACTIVITY CONVERT WS-PRINT = WS-AMT DISPLAY WS-PRINT

MASK and Implicit Edit on Convert

MASK on DEFINE attaches edit pattern to field—moving numeric into MASKed alphabetic produces formatted string with commas decimals and sign placement. Wrong MASK width truncates leftmost digits—size PRINT field wider than MASK pattern requires. MASK is conversion-to-display bridge—detailed patterns in formatting functions index.

Character Digits to Numeric

Partner sends amount as A field with digits and optional decimal point in character form. Assignment into P field parses digits per rules—embedded spaces or letters cause runtime issues. Trim character field procedurally before convert when spaces pad partner layout. Testing functions index covers validation before convert step.

INTEGER ROUNDED TRUNCATED as Conversion

Fractional to whole conversion uses INTEGER modifier—drops decimal portion per assignment documentation. ROUNDED converts fractional to nearest representable value in target scale. TRUNCATED drops excess precision. These modify assignment result—function-like behavior without separate function call syntax.

Binary and Hex Conversions

Bit fields and binary counters convert for display or arithmetic. Assignment from binary to packed for report SUM. Hex literals X'00FF' into bit field for mask operations— see bit fields tutorial. Length mismatch on binary MOVE misaligns word boundaries—match DEFINE length to file DCB.

Date Format Conversion

Internal CCYYMMDD to MMDDYY display requires overlay or conversion macro—not automatic on IF compare. Convert once to WS-DATE-DISPLAY for TITLE; keep WS-DATE-COMPARE numeric for IF. Date functions index covers calendar; this index covers representation change between layouts.

Explicit Plus Conversion Functions

Application Reference may list named conversion functions for radix change hexadecimal display or specialized edit—names vary by release. Treat as optional layer atop assignment conversion—compile test on target LPAR. Document function name in program header when used for audit trail across decades of maintenance.

Conversion Versus Formatting

Category boundary
AspectConversion focusFormatting focus
Primary questionWhat type are the bytes?How should output look?
ExampleA digits → P 2 amountCommas in report column
Failure modeRuntime invalid dataMisaligned columns
TutorialThis page/functions/formatting

Validation Before Convert

  1. Test character field contains only valid digit set.
  2. Verify decimal point position matches implied scale.
  3. Route invalid records to exception file before assignment convert.
  4. Compare converted sample against reference calculator or SQL CAST.
  5. Log first failing record key for partner data quality tickets.

Common Conversion Mistakes

  • MASK width too small for converted magnitude.
  • Assigning alphabetic with letters into numeric uncaught.
  • Assuming implicit round when TRUNCATED is default.
  • Binary length mismatch on MOVE between types.
  • Display date compared to internal date without convert.
  • Plus conversion function on Report Generator LPAR.

Explain It Like I'm Five

Conversion is changing the shape of the same idea. The number five can live in a coin box as five cents or written as the word five on paper—different shapes, same meaning. Easytrieve converts when you copy from one box type to another. If you copy gibberish into a number box, the machine gets confused—check the source is really a number first. MASK is stencils that make numbers look pretty when written for people to read.

Exercises

  1. Define P amount and A MASKed print field; assign and describe output shape.
  2. List three failure cases for A-to-P conversion from partner file.
  3. Explain INTEGER as fractional-to-whole conversion on assignment.
  4. Route invalid digit string to exception before convert assign.
  5. Contrast conversion versus formatting with one sentence each.

Quiz

Test Your Knowledge

1. Assigning numeric value into alphabetic field:

  • Converts per compiler rules—verify output
  • Always compile error
  • Always zeros
  • Impossible

2. Conversion category differs from formatting because:

  • Conversion changes stored representation; formatting emphasizes display masks
  • Identical
  • Formatting is JCL
  • Conversion is FILE only

3. Non-numeric character in digit field during conversion:

  • Runtime error or invalid result
  • Ignored silently always
  • Becomes zero always
  • Compiles only

4. P packed to display often uses:

  • Assignment with MASK or EDIT patterns
  • FILE SORT
  • JCL DD
  • SCREEN only

5. INTEGER on assignment converts by:

  • Taking whole number portion on numeric assign
  • Alphabetic to packed
  • Opening VSAM
  • String scan
Published
Read time16 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 assignment type conversion and MASK patternsSources: Broadcom Easytrieve Report Generator 11.6 Assignment Statement, DEFINE MASK documentationApplies to: Easytrieve type conversion and display transform