MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

COMP-3 maximum storage

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
jayram99
Beginner


Joined: 16 Aug 2004
Posts: 52
Topics: 21
Location: falls church.va,usa

PostPosted: Wed May 31, 2006 1:13 pm    Post subject: COMP-3 maximum storage Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed May 31, 2006 1:51 pm    Post subject: Reply with quote

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
Code:

DECIMAL(9,2)

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jayram99
Beginner


Joined: 16 Aug 2004
Posts: 52
Topics: 21
Location: falls church.va,usa

PostPosted: Thu Jun 01, 2006 8:14 am    Post subject: COMP-3 Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jun 01, 2006 8:25 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
jayram99
Beginner


Joined: 16 Aug 2004
Posts: 52
Topics: 21
Location: falls church.va,usa

PostPosted: Thu Jun 01, 2006 9:06 am    Post subject: COMP-3 Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
NASCAR9
Intermediate


Joined: 08 Oct 2004
Posts: 274
Topics: 52
Location: California

PostPosted: Thu Jun 01, 2006 9:38 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jun 01, 2006 9:44 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
CraigG
Intermediate


Joined: 02 May 2007
Posts: 202
Topics: 0
Location: Viginia, USA

PostPosted: Wed May 21, 2008 9:01 am    Post subject: Re: COMP-3 Reply with quote

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
View user's profile Send private message
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Wed May 21, 2008 3:10 pm    Post subject: Reply with quote

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
View user's profile Send private message
CraigG
Intermediate


Joined: 02 May 2007
Posts: 202
Topics: 0
Location: Viginia, USA

PostPosted: Wed May 21, 2008 8:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group