Packed Data(Comp-3, etc) Conversion


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Packed Data(Comp-3, etc) Conversion

  1. #1
    Marcos Guest

    Packed Data(Comp-3, etc) Conversion


    Does anyone know of any dll's/procedures that will convert Packed Data- comp-3
    and so forth into ascii so that it can be fed into SQL Server.

    The scene:
    We have some AS400 flatfiles that have data that is stored in packed comp-3
    format. I need some help in converting these to readable format used by SQL
    Server, VB, etc.

    Any help would be much appreciated.

    Thanks,

    Marcos

  2. #2
    Patrick Ireland Guest

    Re: Packed Data(Comp-3, etc) Conversion


    Marcos,

    Ah, back to my old COBOL days. The algorithm to convert from COMP-3
    to ASCII is pretty straight forward. Take each character of the
    COMP-3 (as a BYTE). Division by 16 gives the 1st digit while mod by
    16 gives the second. From this you can ascertain that a COMP-3 digit
    is just a nibble. Be careful of the sign. Typically is it stored as
    a separate nibble. I can't recall if negative is indicates by 0x1 or
    0xF. For example:

    123 base 10 (unsigned) = 0x0123
    123 base 10 (signed) = 0x123z where z is the sign
    1234 base 10 (unsigned) = 0x1234
    1234 base 10 (signed) = 0x12340z or 1234z0 not sure which

    Hope that helps

    Pat


    "Marcos" <newcastleluvr@yahoo.com> wrote:
    >
    >Does anyone know of any dll's/procedures that will convert Packed Data-

    comp-3
    >and so forth into ascii so that it can be fed into SQL Server.
    >
    >The scene:
    >We have some AS400 flatfiles that have data that is stored in packed comp-3
    >format. I need some help in converting these to readable format used by

    SQL
    >Server, VB, etc.
    >
    >Any help would be much appreciated.
    >
    >Thanks,
    >
    >Marcos



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center