Reading Comp-6 Data in C#

Hello,

Does anyone have any experience converting a COMP-6 data field to a readable value? I'm trying to read a Vision Version 3 file in C#, and I can see the uncompressed data just fine, but not the COMP fields. What type of encoding should I use to get these out of the data?

 

Thanks


Dave

  • The AcuCOBOL data formats are described in the documentation. Start with ACUCOBOL-GT Reference Manual; Data Division; Record Description Entry; Data Description Entry; USAGE Clause. General Rule 10 describes COMP-6 and General Rule 7 describes COMP-3 which is related.
  • It depends on what you have access to. Do you have access to the XFD's (if they were created), the original source, etc.
    If no xfd's were created, then you'll have to create a cobol program to dump the file in edited format. Typically, we'll move a comp-3 field or even just a PIC 99V99 field to edited numeric format to send to microsoft side. When we receive it from microsoft side we use the convert command at end of move statement. With an XFD, you can read it via odbc connection.
  • It depends on what you have access to. Do you have access to the XFD's (if they were created), the original source, etc.
    If no xfd's were created, then you'll have to create a cobol program to dump the file in edited format. Typically, we'll move a comp-3 field or even just a PIC 99V99 field to edited numeric format to send to microsoft side. When we receive it from microsoft side we use the convert command at end of move statement. With an XFD, you can read it via odbc connection.
  • It depends on what you have access to. Do you have access to the XFD's (if they were created), the original source, etc.
    If no xfd's were created, then you'll have to create a cobol program to dump the file in edited format. Typically, we'll move a comp-3 field or even just a PIC 99V99 field to edited numeric format to send to microsoft side. When we receive it from microsoft side we use the convert command at end of move statement. With an XFD, you can read it via odbc connection.
  • COMP-6 is unsigned Packed-Decimal, which is also known as BCD (Binary Coded Decimal) in the broader non-COBOL world. If you google something like "c# bcd to int conversion" you'll get plenty of examples.
  • Thanks, I managed to figure this out, though there are plenty of resources for converting the BCD data to readable data, there are not very many resources to convert a C# decimal to a BCD. Has anyone tried to write COMP-3/COMP-6 data from C# data types?