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 

Sorting help needed for sum of amounts

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
yadav2005
Intermediate


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Tue Apr 17, 2007 2:28 am    Post subject: Sorting help needed for sum of amounts Reply with quote

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


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

PostPosted: Tue Apr 17, 2007 5:52 am    Post subject: Reply with quote

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


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Tue Apr 17, 2007 7:01 am    Post subject: Reply with quote

Thanks Kolusu for your wonderful answer.
Back to top
View user's profile Send private message
yadav2005
Intermediate


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Tue Apr 17, 2007 7:10 am    Post subject: Reply with quote

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


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

PostPosted: Tue Apr 17, 2007 7:59 am    Post subject: Reply with quote

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


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Wed Apr 18, 2007 8:07 am    Post subject: Reply with quote

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


Joined: 01 Mar 2007
Posts: 475
Topics: 9
Location: Welsh Wales

PostPosted: Wed Apr 18, 2007 8:10 am    Post subject: Reply with quote

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
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Apr 18, 2007 11:06 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities 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