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.
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.
| From | To | Mechanism |
|---|---|---|
| P packed | N zoned | Assignment with scale rules |
| N numeric | A display | Assignment + MASK |
| A digit string | N or P | Assignment parse per rules |
| B binary | N or P | MOVE or assign promote |
| Numeric | Integer whole | INTEGER on assignment |
| Fractional | Rounded currency | ROUNDED on assignment |
| Date internal | Display date | MASK or date format |
| Hex literal | Bit field | Assignment X'...' pattern |
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.
123456DEFINE 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 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.
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.
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.
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.
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.
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.
| Aspect | Conversion focus | Formatting focus |
|---|---|---|
| Primary question | What type are the bytes? | How should output look? |
| Example | A digits → P 2 amount | Commas in report column |
| Failure mode | Runtime invalid data | Misaligned columns |
| Tutorial | This page | /functions/formatting |
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.
1. Assigning numeric value into alphabetic field:
2. Conversion category differs from formatting because:
3. Non-numeric character in digit field during conversion:
4. P packed to display often uses:
5. INTEGER on assignment converts by: