Transferring Data to ASCII Text Files

When you create an ASCII text file, the data coming from the iSeries, eServer™ i5, or System i5® changes as follows:
  • 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.

Table 1. Binary-to-ASCII Field Length Mapping
Binary Length ASCII Length   Value Range
2 6 -32768 to 32767
4 11 -2147483648 to 2147483647