This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Kubernetes in Action and have Marko Luksa on-line!
See this thread for details.
Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

insertion of Packed decimal data into Db2 table from Java  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Need help on storing packed decimal data into Db2 table from Java.

Our requirement is we need to store packed decimal data into Db2 table, which can be read successfully from Cobol program.

The structure of Db2 table is

01 Misc_info CHAR(256)
02 Drive_UpPACK(5,2)3 bytes
02 Tax_AmountPACK(7,2)4 bytes
02 Adj_DriveUpPACK(5,2)3 bytes

We are following the below specified steps to insert data into this table.

MainframeWriter mf = new MainframeWriter();

BigDecimal strDriveUp=new BigDecimal(strValue1);

BigDecimal strTaxAmount=new BigDecimal(strValue2);

BigDecimal strAdjDriveUp=new BigDecimal(strValue3);

byte[] buffer = mf.toByteArray();

ByteArrayOutputStream bos = new ByteArrayOutputStream();
bos.write(buffer, 0, buffer.length);
strMiscInfo = bos.toString(�Cp1047�);

And inserting the value of �strMiscInfo� in the Misc_Info field of DB2 table.

The value was inserted successfully, but when we are trying to read the same record and assigning the value of Misc_Info field to the working storage section fields as specified above. Sometimes it is giving errors and sometimes it is giving wrong values and some times it is correct values.

Could anyone guide us to resolve this problem?
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!