|
|||||
|
This document provides an overview (description and discussion of content and size) of binary (or COMP) fields as they are implemented on an IBM Mainframe or a Micro Focus Wintel or Unix environment.
Note: The items in this document are appropriate for applications that are written in COBOL, Mainframe Assembler (HLASM) or PL/I. The IBM Mainframe architecture drove many of the numeric formats that existed in the early ANSI specifications for COBOL.and have been carried forward to the current COBOL ANSI specifications.
The following table shows the structure of a three digit numeric field using the Binary format that is used on an IBM Mainframe System(i.e. the COBOL syntax would be USAGE IS COMP). The field contains a value of one-hundred-twenty-three (or 123). Since the binary format stores the number as an actual binary value the field will only be two (2) bytes in length.
| The BINARY Format for a Numeric Field | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Note-1:
A binary field that is
defined as "Unsigned" (i.e. PIC 999) is an implied positive value. A two (2)
byte unsigned, binary field may contain a range of implied positive values from
0 to 65,535.
Note-2: A binary field that is defined as
"Signed" (i.e. PIC S999) will use the high-order, leftmost bit as the sign. A
zero (0) is a positive sign and a one (1) is a negative sign. A two (2) byte
signed, binary field may contain a range of implied positive values from
-32,767 to +32,767.
The creation and processing of COMP or BINARY data on a Windows or UNIX platform must be done in the same manner as the mainframe. On the mainframe COMP or BINARY fields must be 2, 4, or 8 bytes in length (the mainframe was originally a half-word, full-word and double-word centric system). On Windows or UNIX (using Micro Focus COBOL with Net Express or Server Express) the COMP or BINARY fields may be 1 through 8 bytes in length.
Note: The syntax for COBOL is "USAGE IS COMPUTATIONAL". However, this is usually abbreviated to COMP or may be coded as BINARY.
Notice the following, the record layout for the Item Master File contains two (2) COMP or BINARY fields. These fields are defined as PIC 9(7) and may contain values from zero (0) through 9,999,999 or the binary values of x'000000' through x'98967F' which may be contained in a three (3) byte binary field.
Herein is the problem, on the EBCDIC-encoded, half-word, full-word, double-word, mainframe environment the fields would be allocated with an actual length of four (4) bytes for a binary field. For the Micro Focus, ASCII-encoded, byte-oriented environment the fields would be allocated with an actual length of three (3) bytes for a binary field.
01 ITEM-RECORD.
05 ITEM-NUMBER PIC X(12).
05 ITEM-DATA.
10 ITEM-DESCRIPTION PIC X(48).
10 ITEM-QTY-ONHAND PIC 9(7) COMP.
10 ITEM-QTY-ALLOCATED PIC 9(7) COMP.
10 ITEM-UNIT-OF-MEASURE PIC X(16).
10 ITEM-COST PIC S9(7)V9(2) COMP-3.
10 ITEM-PRICE PIC S9(7)V9(2) COMP-3.
10 ITEM-LADATE PIC X(8).
10 ITEM-LATIME PIC X(8).
10 ITEM-TOKEN PIC X(3).
10 ITEM-D-CODE-1 PIC X.
10 ITEM-D-PERCENT-1 PIC S9(3)V9(4).
10 ITEM-D-CODE-2 PIC X.
10 ITEM-D-PERCENT-2 PIC S9(3)V9(4).
10 ITEM-D-CODE-3 PIC X.
10 ITEM-D-PERCENT-3 PIC S9(3)V9(4).
10 FILLER PIC X(375).
The solution to this problem for the Micro Focus environment is to use the IBMCOMP and NOTRUNC directives when compiling the programs. This will force the mainframe format for COMP or BINARY fields and the field lengths will be the same as the mainframe.
An alternative solution is to modify the copy file and change the PIC 9(7) to PIC 9(8). However, this solution requires a source code change and is not recommended during the first phase of a data migration.
The following table shows the COBOL picture clause, the number of digits, the length of a packed field, the length of a binary (COMP) field for an IBM Mainframe and the length of a binary field for the Micro Focus Net Express environment.
The differences in field (or data string) length are high-lighted in RED .
| COBOL Picture Clause |
Number of Digits |
Length Packed |
Length Binary (IBM) |
Length Binary (Micro Focus) |
| PIC 9 | 1 | 1 | 2 | 1 |
| PIC 99 | 2 | 2 | 2 | 1 |
| PIC 999 | 3 | 2 | 2 | 2 |
| PIC 9(4) | 4 | 3 | 2 | 2 |
| PIC 9(5) | 5 | 3 | 4 | 3 |
| PIC 9(6) | 6 | 4 | 4 | 3 |
| PIC 9(7) | 7 | 4 | 4 | 3 |
| PIC 9(8) | 8 | 5 | 4 | 4 |
| PIC 9(9) | 9 | 5 | 4 | 4 |
| PIC 9(10) | 10 | 6 | 8 | 5 |
| PIC 9(11) | 11 | 6 | 8 | 5 |
| PIC 9(12) | 12 | 7 | 8 | 5 |
| PIC 9(13) | 13 | 7 | 8 | 6 |
| PIC 9(14) | 14 | 8 | 8 | 6 |
| PIC 9(15) | 15 | 8 |