Character Encoding Formats and Packed Decimal
Part Two - Challenge #07

Background:

As mentioned in previous challanges:

  1. z/OS default character coding is EBCDIC
  2. ASCII can be stored in z/OS data sets and Unix files
  3. ISPF Editor has several features for viewing ASCII hexadecimal character format
      a. HEX ON (primary command)
      b. SOURCE ASCII (primary command)
      c. HX (line command)

Another important character encoding scheme is Packed Decimal.
  Storing numbers in Packed Decimal format improves application performance for arithmetic processing.
  Applications must convert EBCDIC numbers into either packed or zoned decimal to perform arithmetic functions.
  Therefore, if the numbers are stored in packed or zoned decimal, then application cycles are reduced.

Outline of tasks in this challenge:

  1. View PDS members with EBCDIC, Packed Decimal, and ASCII
  2. Observe Hexadecimal values for the EBCDIC, Packed Decimal, and ASCII characters
  3. Execute a REXX routine designed convert Packed Decimal and ASCII characters to EBCDIC,
      then write the converted Packed Decimal and ASCII to the display screen
  4. Same PDS member has 2 lines at the bottom in EBCDIC with a signed number and character text
  5. Edit the PDS member and manually convert the EBCDIC signed number to Packed Decimal and the EBCDIC text to ASCII.

A Character Encoding Summary is available to complete the challenge. Browse this document before you begin.

References drop down includes Character Encoding Summary.

Challenge Preparation:

Edit member DATACODE in Z99999.PDS.DATA
  Observe some characters look funny and "Data contains invalid (non-display) characters"

Enter the following on the primary command line:
reset ; source ascii
The ==MSG> will be supressed and ASCII translation will be applied to all characters in DATACODE

Observe below many of the non-displayed characters are displayed. The previous displayed characters are not displayed.
The reason for all the @ characters is because an EBCDIC space is an ASCII @ character. The hexadecimal value is x'40'. When x'40' is displayed as EBCDIC, a blank space is displayed. When x'40' is displayed as ASCII, @ is displayed.

Enter the following on the primary command line:
reset
The display will return to default EBCDIC translation as shown below

Observe below translation is back to default EBCDIC

Enter the following line command as shown below on the first line
hx
The first line number will show Hexadecimal representation of each character on the line

Observe the first line is all EBCDIC spaces, x'40'

It is possible to overtype the Hexadecimal values

Overtype the first 4 Hexadecimal values, 40404040 with 81826162 as shown below, then press enter

Line 1 now displays ab followed by 2 strange characters

Enter the following as shown below
cols; source ascii
to display a column ruler and translate Hexadecimal to ASCII

Observe line 1, column 1-4.
Columns 3 and 4 have ab and columns 1 and 2 are strange.
Therefore, while z/OS default Hexadecimal translation is EBCDIC, z/OS can display ASCII

Enter cancel to return to PDS directory without saving changes

From the PDS directory command line enter the following:
tso a2e

a2e is a REXX routine that was quickly written to:
  1. Read DATACODE lines
  2. Translate Packed Decimal and ASCII to EBCDIC and write the line only when the following is true:
   a. Valid Packed Decimal sign found in last "nibble" of column 4
   b. Valid Packed Decimal number found in columns 1, 2, 3, 4, and last "nibble" of column 4
   c. Valid ASCII space character, x'20', found in any column between column 5 and 80

Note: a2e, (a)scii (2) (e)bcdic

Challenge:

Edit DATACODE and change the last line (9) as follows:
1. change +432 in columns 1-4 to Packed Decimal format
2. change the characters in columns 5-80 to ASCII

Helpful hints:
  While in ascii mode, what you type will be ascii, but that x'C4' in column 12 will require special handling
  5-57 reads - Packed Decimal is superior for arithmetic performance
  58-80 are spaces that need to be changed from EBCDIC to ASCII - F11 to see columns 72-80

F3 to save changes, then
tso a2e
can be used to validate your line 9 Packed Decimal and ASCII changes
  No @ characters should be on the line 9 characters displayed on the screen

Once the changes are complete, then edit DATACODE member and type the following:
rep p2.output(#07)
and enter the following line command on line 000001
c999
F3 to exit edit session.
You just completed the challenge and demonstrated above average skills with hexadecimal, EBCDIC, and ASCII.

Next: Challenge #08

In the event original copy of DATACODE is needed
  Edit member DATACODE in Z99999.PDS.DATA
  D999 on line number 1
  copy 'zos.mtm2017.public.pds.data(datacode)'