4

I had found this useful link for unpacked COMP-3 digit, but i need to unpack COMP digit this time, is anyone know how to unpack it? Thanks a lot!

Michael Ouyang
  • 1,767
  • 1
  • 11
  • 19

2 Answers2

1

In most Cobol compilers Comp is a big endian binary integer. For the mainframe only 2/4/8 bytes are supported. So For signed values

  03  Signed-Num     pic s9(4) comp.

if you have the value in an array of bytes you can do

BigInteger value = new BigInteger(byteArray);

Alternatively you could use the readShort(), readInt() and readLong() methods of DataInputStream

Finally JRecord will let you read Cobol files with a Cobol copybook

Bruce Martin
  • 10,358
  • 1
  • 27
  • 38
1

IBM Provides a library of Java methods to simplify interactions with z/OS services and data formats. An overview can be found here jZOS Toolkit

Here is a link to PackedDecimal Operations

Here are others for managing binary data ByteArrayUnmarshaller

Hogstrom
  • 3,581
  • 2
  • 9
  • 25