Re: Comp-3 data type Conversion (75 Views)
Reply
Advisor
Debbie Erickson
Posts: 30
Registered: ‎02-12-2001
Message 1 of 3 (75 Views)
Accepted Solution

Comp-3 data type Conversion

Hello. I have a flat file that has a record layout that includes an amount expressed as a comp-3 datatype. I need to read this file on a PC and import into an MS-SQL server. My valid data type choices would be Integer or Integer64. Anyone know how to convert a packed-decimal into something the PC can recognize?
Please use plain text.
Frequent Advisor
Gary Tinnes
Posts: 30
Registered: ‎07-12-2000
Message 2 of 3 (75 Views)

Re: Comp-3 data type Conversion

There are several alternatives available depending on whether you have access to an e3000, are a programmer, etc.

The easiest option is to see if the creator of the file (I assume it is coming from an e3000) can do the conversion either within the extract program, if it is COBOL & they have the source code, or use a third party utility like SuprTool from Robelle (www.robelle.com). Vendors offering migration services should have extract tools too. There is a tutorial on exporting data at http://www.robelle.com/library/tutorials/pdfs/stexport.pdf/utility.

If you can program, and have access to COBOL, either on an e3000 or PC, you can write a simple COBOL program to do the conversion.

http://www.titusinformationsystems.com/MAIN/VAsoLbV.htm
describes a C++ library of functions that includes a function called char*StringFromPacked(char*Field, int Length) that converts packed to a string. You can then convert the string to a number. It should be possible to call the function from other languages like Visual Basic.

You can also right your own routine to do the conversion but you will have to understand the format and it would require testing. It's the least attractive option. You might be able to find some code samples with an Internet search.
Please use plain text.
Advisor
Debbie Erickson
Posts: 30
Registered: ‎02-12-2001
Message 3 of 3 (75 Views)

Re: Comp-3 data type Conversion

I wrote a cobol program to convert the data. I had wanted to use the file as-is from the hp as input to another pc-based application. I ended up adding a step in the job stream that re-wrote the data into a more PC-friendly format. I didn't want to take that approach, but it was the easiest method. Thanks for replying.
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation