Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
DWrightson Absent Member.
Absent Member.
947 views

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

4 Replies
mhanson Absent Member.
Absent Member.

RE: Reading Comp-6 Data in C#

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.
0 Likes
GeorgeK Absent Member.
Absent Member.

RE: Reading Comp-6 Data in C#

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.
0 Likes
Chuck Edgin Absent Member.
Absent Member.

RE: Reading Comp-6 Data in C#

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.
0 Likes
DWrightson Absent Member.
Absent Member.

RE: Reading Comp-6 Data in C#

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?
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.