RM/COBOL Conversion Issues |
You might need to convert COMPUTATIONAL , COMPUTATIONAL-3 , COMPUTATIONAL-6 and DISPLAY data from RM/COBOL format to the formats used by this system. The following sections describe these data types, and how they should be converted.
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 |
You should 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. 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 |
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, Positive | B or F |
Signed, Negative | D |
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. 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 |
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. 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 Compatibility with RM/COBOL for details.
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:
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.
Consider the following examples:
Value | Picture Clause | RM Representation (Hexadecimal) | ||
---|---|---|---|---|
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 |
These examples are represented as follows:
Value | Picture Clause | This COBOL's Representation (Hexadecimal) | ||
---|---|---|---|---|
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 |
Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names
used herein are protected by international law.
RM/COBOL Conversion Issues |