
- Forum
- Programming Talk
- COBOL
- Packed-decimal conversion or unpacked
Packed-decimal conversion or unpacked
This is a discussion on Packed-decimal conversion or unpacked within the COBOL forums, part of the Programming Talk category; I need to unpack a packed-decimal field such as : PACKED-FIELD PIC S9(8)V99 USAGE COMP-3. What will be the layout ...
-
12-12-2006, 09:27 PM #1
- Join Date
- Dec 2006
- Location
- New Freedom, PA
- Answers
- 1
Packed-decimal conversion or unpacked
I need to unpack a packed-decimal field such as :
PACKED-FIELD PIC S9(8)V99 USAGE COMP-3.
What will be the layout for it to be unpacked?
-
COBOL Comp-3 is a binary field type that puts ("packs") two digits into each byte, using a notation called Binary Coded Decimal, or BCD. This halves the storage requirements compared to a character, or COBOL "display", field.
-
Comp-3 fields are denoted in COBOL with the "usage is" clause after the PIC, like this:
PIC S9(5) usage is computational-3.
In the above the clause usage is optional and can be omitted and used also as
PIC S9(5) comp-3.
The COBOL PIC, or picture, for a comp-3 packed field specifies the number of digits after unpacking.
Hope the above explanation would help you.
-
It was a good explanation on Packed-decimal representation in COBOL. But I am curious to know how this Comp-3 packed fields are stored internally in COBOL and how many bytes are stored for these Comp-3 packed fields. Could you give idea on these concepts.
-
Ralp and dionyemah,
COBOL compilers do the conversions for you. Just define the packed field and the unpacked field, and move one to the other.
PIC S9(8)V99 COMP-3 would be moved to a PIC S9(8)V99. The actual storage of the comp-3 would be 6 bytes. comp-3 storage is more effecient for odd length fields. .. s9(9)v99 also uses 6 bytes. if you could see each byte for number 1234-, it would be [00][00][00][01][23][4B] a positive 1234 would be [00][00][00][01][23][4C] 12345 ... [00][00][00][12][34][5C]
-
if you have DFSORT latest version you dont need a cobol program
I have a document at Index of /oracle/files
-
Sponsored Ads

Reply With Quote





