Transferring Data to ASCII Text Files
- Hexadecimal fields change to equivalent ASCII characters for each half-byte. For example, X'D3' expands to ASCII 4433 and is written to the file. When displayed by an editor or printed, the string appears as D3.
- EBCDIC character fields change byte by byte and are mapped into ASCII characters as defined by the translation tables.
- Date, time, and time-stamp data is mapped into ASCII characters as defined by the translation tables.
- Variable-length and null fields are converted to fixed lengths,
and trailing blanks (for character, hexadecimal, date, time, and time-stamp
data) or zeros (for binary, zoned, and packed,) are added to the maximum
length of the field.
Note: Some nondisplayable EBCDIC characters are translated into ASCII control characters on the workstation. If EBCDIC character fields contain nondisplayable data, you might get unexpected results and your ASCII text file might appear to be corrupted.
For example, X'05' in an EBCDIC field is translated to an ASCII X'09', which is an ASCII control character for horizontal tab. Most workstation text editors process this tab character so that the data in your workstation text file appears to be shifted to the right when viewed.
One possible solution to this problem is to define these fields on the host system as hexadecimal fields instead of character fields.
- Binary fields change to ASCII numeric. For example, X'FFD3' with
no decimal position expands to ASCII 20202020202020202D3435. When
displayed by an editor or printed, the string appears as -45.
Note: The length of the ASCII field depends on the length of the binary field.
A binary field on the iSeries, eServer i5, or System i5 is either 2 or 4 bytes long. The resulting ASCII field length is from 6 to 11 bytes, including the sign. Another byte is added for a decimal point.
Table 1 shows the mapping between binary field lengths and their ASCII lengths.
Binary Length | ASCII Length | Value Range |
---|---|---|
2 | 6 | -32768 to 32767 |
4 | 11 | -2147483648 to 2147483647 |
- Zoned decimal fields are changed to ASCII numeric. For example, EBCDIC F0F0F9F5F2D6 with a field length that indicates two digits to the right of the decimal point expands to ASCII 20202D39352E3236. When displayed by an editor or printed, the string appears as -95.26. The resulting workstation field length is equal to the length of the system field plus 1 for the sign and 1 for the decimal point, if specified.
- Packed decimal fields change to ASCII numeric. For example, X'871D' (no
decimal point) changes to ASCII 2D383731. When displayed by an
editor or printed, the string appears as -871.
Since two decimal digits are packed into 1 byte, the length of the resulting workstation field is equal to two times the length of the iSeries, eServer i5, or System i5 field, plus 1 for the decimal point (if specified). This length always includes the sign. A minus sign (-) indicates negative, and a space indicates positive.