View previous topic :: View next topic |
Author |
Message |
jayram99 Beginner
Joined: 16 Aug 2004 Posts: 52 Topics: 21 Location: falls church.va,usa
|
Posted: Wed May 31, 2006 1:13 pm Post subject: COMP-3 maximum storage |
|
|
Hi,
I have defined a field AMT-TRAN S9(6)V9(2) comp-3. It is having value of
3742966.00 .
What is the maximum value can be stored in S9(6)V9(2) comp-3 ?
When that value(3742966.00) is inserted into a DB2 Table for a column defined as DECIMAL(6,2). I am getting errror with the data is truncating.
When i define S9(6)V9(2) comp-3 , what is the corresponing data type and size in DB2 Table.
Please suggest me .
Thanks & Regards,
jayaram |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed May 31, 2006 1:51 pm Post subject: |
|
|
jayram99,
You need to get your basics right. In Cobol for a comp-3 packed field specifies the number of digits after unpacking. The actual number of bytes occupied in the file is about half that. To calculate the number of bytes from the PIC, add 1 (for the sign) to the total number of digits, divide by 2, and round up if necessary. For example:
Code: |
PIC S9(7) COMP-3. Byte size = (7 + 1) / 2 = 4
PIC S9(5)V99 COMP-3. Byte size = (5 + 2 + 1) / 2 = 4
PIC S9(6) COMP-3. Byte size = (6 + 1) / 2 = 3.5, rounded to 4
|
In DB2 a Column defined as DECIMAL is equivalent to
Code: |
DECIMAL(p,s) = PIC S9(p-s)V9(s) COMP-3
|
In your case Decimal (6,2) = PIC S9(4)V9(2) Comp-3 is only 4 bytes.
Define your cobol variable as
Code: |
PIC S9(7)V99 COMP-3.
|
And Your Db2 table should be defined as
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
jayram99 Beginner
Joined: 16 Aug 2004 Posts: 52 Topics: 21 Location: falls church.va,usa
|
Posted: Thu Jun 01, 2006 8:14 am Post subject: COMP-3 |
|
|
Kolusu,
Sorry, there was typo error in the earlier mail.
I have defined AMT-TRN as S9(6)V9(2) COMP-3 in cobol program. For DB2 the column is defined as DEC(8,2). which satisfies as per below condition.
DECIMAL(p,s) = PIC S9(p-s)V9(s) COMP-3
We can view data in AMT-TRN as 3742966.00 but while loading into table, the job is failing for data truncation.
S9(6)V9(2) is 5 bytes and stores 3742966.00 value.
DEC(8,2) is 5 bytes and could not store the same value.
Pls. let me know if i am missing something.
Jayaram |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu Jun 01, 2006 8:25 am Post subject: |
|
|
Quote: |
S9(6)V9(2) is 5 bytes and stores 3742966.00 value.
|
Jayaram,
I don't think so. If you have defined 6 bytes for integer portion , it can never store 3742966.00 value.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
jayram99 Beginner
Joined: 16 Aug 2004 Posts: 52 Topics: 21 Location: falls church.va,usa
|
Posted: Thu Jun 01, 2006 9:06 am Post subject: COMP-3 |
|
|
Thanks Kolusu.
The DATA is coming from source and we could see the data with FILE-AID.
This is a Data Qualtiy Issue. I will put forward the same to Business Team.
jayaram |
|
Back to top |
|
 |
NASCAR9 Intermediate
Joined: 08 Oct 2004 Posts: 274 Topics: 52 Location: California
|
Posted: Thu Jun 01, 2006 9:38 am Post subject: |
|
|
kolusu,
Quote: | PIC S9(5)V99 COMP-3. Byte size = (6 + 2 + 1) / 2 = 4.5 rounded to 5 |
I think this will also pack to 4.
Here is an example of S9(07) packs to 4
& S9(07)v99 packs to 5
.........
004105023
516C0822C
NumberX PIC S9(07) COMP-3
AMOUNT PIC S9(07)V99 COMP-3 _________________ Thanks,
NASCAR9 |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu Jun 01, 2006 9:44 am Post subject: |
|
|
NASCAR9,
I made a mistake in the declaration. I showed s9(5) but in when adding I used 6 which is wrong. I corrected it now. Thanks for bringing it to my attention.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
CraigG Intermediate
Joined: 02 May 2007 Posts: 202 Topics: 0 Location: Viginia, USA
|
Posted: Wed May 21, 2008 9:01 am Post subject: Re: COMP-3 |
|
|
jayram99 wrote: | Kolusu,
We can view data in AMT-TRN as 3742966.00 but while loading into table, the job is failing for data truncation.
S9(6)V9(2) is 5 bytes and stores 3742966.00 value.
DEC(8,2) is 5 bytes and could not store the same value.
Pls. let me know if i am missing something.
Jayaram |
S9(7)V9(2) is also 5 bytes and would store 3742966.00! |
|
Back to top |
|
 |
slade Intermediate
Joined: 07 Feb 2003 Posts: 266 Topics: 1 Location: Edison, NJ USA
|
Posted: Wed May 21, 2008 3:10 pm Post subject: |
|
|
I think you can "store" 3742966.00 into a S9(6)V9(2) COMP-3 field if is's part of a group move, but it will get truncated when refed as an elementary item.
Why doesn't th OP change the declaration to S9(7)V9(2)/DEC(9,2)? that should solve the problem. _________________ Regards, Jack.
"A problem well stated is a problem half solved" -- Charles F. Kettering |
|
Back to top |
|
 |
CraigG Intermediate
Joined: 02 May 2007 Posts: 202 Topics: 0 Location: Viginia, USA
|
Posted: Wed May 21, 2008 8:21 pm Post subject: |
|
|
slade wrote: | I think you can "store" 3742966.00 into a S9(6)V9(2) COMP-3 field if is's part of a group move, but it will get truncated when refed as an elementary item.
Why doesn't th OP change the declaration to S9(7)V9(2)/DEC(9,2)? that should solve the problem. |
It's a two year old subject, I'm not even sure how I ended reading & replying to it. |
|
Back to top |
|
 |
|
|