Exforsys
+ Reply to Thread
Results 1 to 6 of 6

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 ...

  1. #1
    dionyemah is offline Junior Member Array
    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?


  2. #2
    rachelle is offline Member Array
    Join Date
    Apr 2006
    Answers
    97
    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.


  3. #3
    caradoc is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    122
    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.


  4. #4
    Ralph is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    114
    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.


  5. #5
    eddie13 is offline Junior Member Array
    Join Date
    Jul 2007
    Answers
    8
    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]


  6. #6
    grlewycky's Avatar
    grlewycky is offline Junior Member Array
    Join Date
    Jan 2007
    Answers
    6
    if you have DFSORT latest version you dont need a cobol program

    I have a document at Index of /oracle/files


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...