Example: For a file of invoice records sorted by company name, the Invoice Amount, Amount Paid, and Balance Due fields are to be converted from packed-decimal to printable format. In addition, any leading zeros will be suppressed and both commas and decimal points will be inserted. (The following figure gives the input record layout.)
To sort the records, convert the three fields of packed-decimal data, and insert the commas and decimal points, the following is coded.
The effect of OUTREC processing on the input record is shown in the following figure.
Explanation: First the records are sorted alphabetically by company name (1,23,CH). Then, three fields--the Invoice Amount (24,4,PD), the Amount Paid (28,4,PD), and the Balance Due (32,4,PD)--are converted from packed-decimal (PD) into readable format and editing by an MFX editing mask (M2) that suppresses the printing of leading zeros and inserts the appropriate commas and decimal points. The number-colon entries (c:) that precede each of the four fields assign a new starting position or, when printing, column for each of the four fields. For example, the Company Name field, which originally began in byte 1 for a length of 23 bytes, now begins in byte 17; the Invoice Amount field, which began in byte 24, begins in byte 52, and so on. Note that after the data is converted and edited, the lengths of the packed-decimal fields increase from four bytes each to ten bytes and that the fields are each separated by twelve blanks.