Mainframe Path Start learning free
Applied11 min readLesson 3 of 3

Conversion pitfalls, quality, governance and the system of record

Mainframe data uses EBCDIC text and numeric formats such as packed decimal that other platforms do not understand. Converting it wrongly corrupts data silently. Once data is available elsewhere, quality checks, governance, security and a clear system of record keep the copies trustworthy.

Why conversion goes wrong

A mainframe record is a sequence of bytes whose meaning is given by its copybook. Text fields use EBCDIC, but numeric fields may be packed decimal, zoned decimal or binary. A tool that converts the whole record from EBCDIC to ASCII as if it were text will translate the numeric bytes too, and destroy them. Conversion must be field by field, driven by the copybook.

How the same value can be storedWhat it means
PIC X(5)
Text in EBCDIC; convert using the correct code page
PIC S9(5)
Zoned decimal: one digit per byte, sign held in the zone of the last byte
PIC S9(5) COMP-3
Packed decimal: two digits per byte, sign in the last half-byte; must not be character-converted
PIC S9(4) COMP
Binary, big-endian; byte order matters on little-endian platforms
COMP-1 / COMP-2
Floating point, normally IBM hexadecimal format rather than IEEE; needs explicit conversion

Classic symptoms

Symptom on the targetLikely cause
Last digit of an amount shows as a letter, for example 12C or 12LZoned decimal sign treated as text (C for positive, D for negative in the zone)
Amounts are garbage or huge numbersPacked or binary fields were translated as characters
A few symbols such as square brackets are wrongWrong EBCDIC code page used, for example 037 instead of 1047
Lines shifted or records mergedVariable-length records or binary data containing line-end byte values
Records sort in a different orderEBCDIC and ASCII collating sequences differ
Packed decimal bytes in hex (illustrative)
PIC S9(5) COMP-3   value +12345   bytes  12 34 5C
PIC S9(5) COMP-3   value -12345   bytes  12 34 5D
PIC 9(5)  COMP-3   value  12345   bytes  12 34 5F
TRY IT YOURSELF

A PIC S9(5) COMP-3 field contains hex 00 12 3D. What value is it?

Show a hint

Read the digits, then the last half-byte is the sign: C positive, D negative.

Show the solution

Digits 00123 with sign D, so the value is -123.

Data quality

Old files often contain values the programs tolerate but a database will reject: dates such as 00000000 or 99999999 used as markers, spaces in numeric fields, low-values (hex 00) as defaults, and codes no longer documented. Profile the data before migration, agree rules for each oddity with the business, and reconcile after every load: record counts, sums of amount fields and checks on key ranges should match source and target.

Governance and security

One system of record

For each piece of data there should be exactly one system of record: the place where it is created and changed, and whose value wins in a dispute. Everything else is a copy. During a migration the system of record can move, but only at a planned, single moment.

Common mistakes

Converting whole records as text

Character conversion destroys packed, zoned and binary fields. Convert field by field using the copybook.

Assuming the code page

Different EBCDIC code pages differ for some characters. Confirm which one the data uses before converting.

Letting copies become masters

If more than one place accepts updates, data diverges. Name one system of record and make copies read-only.

What you will see at work

Key terms

Check your understanding.
Take this lesson's quiz and save your progress. Free.

Take the lesson quiz
← Replication, change data capture and analytics accessBack to Data modernization