Conversion of Data Types [ Micro Focus COBOL Compatibility Guide ] MPE/iX 5.0 Documentation
Micro Focus COBOL Compatibility Guide
Conversion of Data Types
The Convert3 utility converts COMPUTATIONAL, COMPUTATIONAL-3,
COMPUTATIONAL-6
and DISPLAYdata from RM/COBOL format to the formats used by this system.
The following sections describe how these types of data are converted.
COMP/COMPUTATIONAL Data
The RM/COBOL system represents COMP (or COMPUTATIONAL) data in packed
decimal format with one character per byte stored in each least
significant four-bits. The most significant half-byte always contains
zero. If the picture-string specifies a signed representation, an
additional byte is added to the least significant end of the string: a
negative value is represented by the hexadecimal value x"D", and a
positive value is represented by the hexadecimal value x"B".
Consider the following examples:
----------------------------------------------------------------------
| | | |
| Value | Picture Clause | RM Representation |
| | | (Hexadecimal) |
| | | |
----------------------------------------------------------------------
| | | |
| 1234 | PIC 9(5) COMP | 00 01 02 03 04 |
| | | |
| 1234 | PIC S9(5) COMP | 00 01 02 03 04 0B |
| | | |
| -1234 | PIC S9(5) COMP | 00 01 02 03 04 0D |
| | | |
----------------------------------------------------------------------
The conversion program produced by Convert3 converts COMP data fields
into DISPLAY format, with sign trailing separate. This is compatible
with this COBOL system's treatment of RM/COBOL COMP fields in the source
program when the RM directive is set. See the chapter Rebuild in the
Conversion Series 2 Part for details. If the data item is signed, the
sign byte has the most significant half-byte set to hexadecimal value 2.
After conversion, the examples above are represented as follows:
----------------------------------------------------------------------
| | | |
| Value | Picture Clause | This COBOL's |
| | | Representation |
| | | (Hexadecimal) |
| | | |
----------------------------------------------------------------------
| | | |
| 1234 | PIC 9(5) DISPLAY | 30 31 32 33 34 |
| | | |
----------------------------------------------------------------------
| | | |
| 1234 | PIC S9(5) DISPLAY | 30 31 32 33 34 2B |
| | | |
----------------------------------------------------------------------
| | | |
| -1234 | PIC S9(5) DISPLAY | 30 31 32 33 34 2D |
| | | |
----------------------------------------------------------------------
COMP-3/COMPUTATIONAL-3 Data
The RM/COBOL system represents COMP-3 data in packed decimal format with
the least significant half-byte holding the sign.
This sign half-byte contains the following values:
-------------------------------------------------------------------
| | |
| Field | RM Sign half-byte value (Hexadecimal) |
| | |
-------------------------------------------------------------------
| | |
| Unsigned | F |
| | |
| Signed, | B or F |
| Positive | |
| | |
| Signed, | D |
| Negative | |
| | |
-------------------------------------------------------------------
Consider the following examples:
----------------------------------------------------------------------
| | | |
| Value | Picture Clause | RM Representation |
| | | (Hexadecimal) |
| | | |
----------------------------------------------------------------------
| | | |
| 1234 | PIC 9(5) COMP-3 | 00 23 4F |
| | | |
| 1234 | PIC S9(5) COMP-3 | 00 23 4F |
| | | |
| -1234 | PIC S9(5) COMP-3 | 00 23 4D |
| | | |
----------------------------------------------------------------------
The only requirement for conversion is that the sign half-byte has to be
changed for signed positive fields to hexadecimal value C. After
conversion, the examples above are represented as follows:
----------------------------------------------------------------------
| | | |
| Value | Picture Clause | This COBOL's |
| | | Representation |
| | | (Hexadecimal) |
| | | |
----------------------------------------------------------------------
| | | |
| 1234 | PIC 9(5) COMP-3 | 00 23 4F |
| | | |
| 1234 | PIC S9(5) COMP-3 | 00 23 4C |
| | | |
| -1234 | PIC S9(5) COMP-3 | 00 23 4D |
| | | |
----------------------------------------------------------------------
COMP-6/COMPUTATIONAL-6 Data
The RM/COBOL system holds COMP-6 data in a similar format to COMP-3 data,
except there is no sign half-byte. If a sign is indicated in the picture
clause it is ignored and has no effect. The value held is always
positive.
Consider the following examples:
----------------------------------------------------------------------
| | | |
| Value | Picture Clause | RM Representation |
| | | (Hexadecimal) |
| | | |
----------------------------------------------------------------------
| | | |
| 1234 | PIC 9(5) COMP-6 | 00 12 34 |
| | | |
| 123456 | PIC S9(6) COMP-6 | 12 34 56 |
| | | |
----------------------------------------------------------------------
In order to maintain the size and capacity of the data items, this COBOL
system treats COMP-6 data items as this COBOL's COMP format fields, and
pads the field with binary zeros where necessary. After conversion, the
examples above are represented as follows:
----------------------------------------------------------------------
| | | |
| Value | Picture Clause | This COBOL's |
| | | Representation |
| | | (Hexadecimal) |
| | | |
----------------------------------------------------------------------
| | | |
| 1234 | PIC 9(5) COMP-6 | 00 04 D2 |
| | | |
| 123456 | PIC S9(6) COMP-6 | 01 E2 40 |
| | | |
----------------------------------------------------------------------
The 9(5) COMP field is extended by one byte containing binary zero in
order to maintain the size of the original item. See the section
COMPUTATIONAL-6 (COMP-6) Data Types in the chapter RM/COBOL Source
Compatibility for details.
DISPLAY Data
You should be aware of the following differences between the
representation of numeric DISPLAY format data items, with sign INCLUDED,
under the RM/COBOL system and this COBOL system:
* This COBOL system does not encode a sign on the data if the data
is positive, whereas the RM/COBOL system increments the value of
the most significant half-byte by one to denote a positive value.
* This COBOL system increments the value of the most significant
half-byte by four to denote a negative value. The RM/COBOL system
increments the value of the byte by twenty-five (that is,
hexadecimal 19).
When the RM directive is set, a DISPLAY format data item with no sign
clause associated is treated by this system as though you had specified
the SIGN TRAILING IS SEPARATE clause. However, when the RM"ANSI"
directive is set, the same data item is treated as though you had
specified the SIGN TRAILING IS INCLUDED clause. This is the default
state for such data items in this COBOL system. The Convert3 utility
also allows you to specify the type of sign used for DISPLAY format data
items. See the chapter Running Convert3 for details on how you can do
this.
Consider the following examples:
---------------------------------------------------------------------------------------------
| | | | |
| Value | Picture Clause | RM Representation (Hex) | RM Representation (Hex) |
| | | Leading | Trailing |
| | | | |
---------------------------------------------------------------------------------------------
| | | | |
| 123 | PIC 9(3) DISPLAY | 31 32 33 | 31 32 33 |
| | | | |
| 123 | PIC S9(3) DISPLAY | 41 32 33 | 31 32 43 |
| | | | |
| -123 | PIC S9(3) DISPLAY | 4A 32 33 | 31 32 4C |
| | | | |
---------------------------------------------------------------------------------------------
After conversion, these examples are represented as follows:
---------------------------------------------------------------------------------------------
| | | | |
| Value | Picture Clause | COBOL | COBOL |
| | | Representation(Hex) | Representation(Hex) |
| | | Leading | Trailing |
| | | | |
---------------------------------------------------------------------------------------------
| | | | |
| 123 | PIC 9(3) DISPLAY | 31 32 33 | 31 32 33 |
| | | | |
| 123 | PIC S9(3) DISPLAY | 31 32 33 | 31 32 33 |
| | | | |
| -123 | PIC S9(3) DISPLAY | 71 32 33 | 31 32 73 |
| | | | |
---------------------------------------------------------------------------------------------
MPE/iX 5.0 Documentation