View previous topic :: View next topic |
Author |
Message |
yadav2005 Intermediate

Joined: 10 Jan 2005 Posts: 348 Topics: 144
|
Posted: Tue Apr 17, 2007 2:28 am Post subject: Sorting help needed for sum of amounts |
|
|
I have a file with records with Packed Decimal values in columns 15 to 19 in the following:
[code:1:21bb6f61b3]
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
MABC 07107PQR....@
MABC 07107PQR..l |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Tue Apr 17, 2007 5:52 am Post subject: |
|
|
yadav2005,
You got 2 records because the summation resulted in an overflow. So you need to expand the field before summing. Try the following sort card
Code: |
INREC FIELDS=(01,14,3X'00',15,5)
SORT FORMAT=CH,FIELDS=(2,3,A,
7,5,A,
12,3,A)
SUM FIELDS=(15,8,PD)
|
Also check this link which explains in detail about SUM statement overflow(first few lines) with an example.
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA10/3.17.1?DT=20050222160456
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
yadav2005 Intermediate

Joined: 10 Jan 2005 Posts: 348 Topics: 144
|
Posted: Tue Apr 17, 2007 7:01 am Post subject: |
|
|
Thanks Kolusu for your wonderful answer. |
|
Back to top |
|
 |
yadav2005 Intermediate

Joined: 10 Jan 2005 Posts: 348 Topics: 144
|
Posted: Tue Apr 17, 2007 7:10 am Post subject: |
|
|
Kolusu,
Can you please let me know what is 3X'00' , i am unable to understand .Please help me .
Code: |
INREC FIELDS=(01,14,3X'00',15,5)
|
|
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Tue Apr 17, 2007 7:59 am Post subject: |
|
|
yadav2005,
3x'00' = 3 byte binary zeroes. Since you are having an overflow I just 3 bytes of binary zeroes to the left of the actual summing field, thus making the field to be summed as 8 bytes which takes care of the overflow
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
yadav2005 Intermediate

Joined: 10 Jan 2005 Posts: 348 Topics: 144
|
Posted: Wed Apr 18, 2007 8:07 am Post subject: |
|
|
Kolusu,
I have a question why are inserting 3 Binary Zeroes when the field is Comp-3 Packed Decimal from pos 15 - 19.Can you please explain me , Thanks. |
|
Back to top |
|
 |
expat Intermediate

Joined: 01 Mar 2007 Posts: 475 Topics: 9 Location: Welsh Wales
|
Posted: Wed Apr 18, 2007 8:10 am Post subject: |
|
|
I'd guess it's just a naming thing.
Anyway, binary zeros equate to PD zeros, so kolusu's solution was perfect. _________________ If it's true that we are here to help others,
then what exactly are the others here for ? |
|
Back to top |
|
 |
Frank Yaeger Sort Forum Moderator

Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Wed Apr 18, 2007 11:06 am Post subject: |
|
|
yadav2005,
Your 5-byte PD value looks like this in hex: X'ddddddddds'
Each d is 0-9 and s is the sign (C, D or F).
To extend this 5-byte PD value to an 8-byte PD value, you would add zeros on the left to get this: X'000000ddddddddds'
The X'000000' part of this is equivalent to 3 binary zeros, so that's why Kolusu used 3X'00'. Alternatively, you could use 3Z since Z means binary zeros. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort |
|
Back to top |
|
 |
|
|