IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SUM and keep current sequence


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abby.qiong.zhang

New User


Joined: 07 Jun 2012
Posts: 26
Location: China

PostPosted: Wed Jan 30, 2013 2:17 pm
Reply with quote

Please help with the SUM function, my input like this:
Code:

0400022M0000142000693         000300
0400022M1000142000693         000300
0400022M1000142000693         000030
0400022M2000142000693         
0004088M0000142000691         000100
0004088M1000142000691         000100
0004088M2000142000691
0004088M0000142000694         000400
0004088M1000142000694         000400
0004088M2000142000694

For 'M1' records, i need to summarize the amount 000300 and 000030 together, for other records, keep the same.
The output should like this:
Code:

0400022M0000142000693        000300
0400022M1000142000693        000330
0400022M2000142000693
0004088M0000142000691        000100
0004088M1000142000691        000100
0004088M2000142000691
0004088M0000142000694        000400
0004088M1000142000694        000400
0004088M2000142000694


I tried with the statements like this:
Code:

  SORT FIELDS=(1,3,CH,D,15,8,CH,A,8,2,CH,A,10,4,CH,A,4,4,CH,A)   
  SUM FIELDS=(134,6,PD)                                           
  OPTION EQUALS                                                   

But the output is not what I want, the M2 record will before the M1 record like this:
Code:

0400022M0000142000693        000300       
0400022M2000142000693
0400022M1000142000693        000330
0004088M0000142000691        000100
0004088M2000142000691
0004088M1000142000691        000100
0004088M0000142000694        000400
0004088M2000142000694
0004088M1000142000694        000400


Can anyone help? Thanks!
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jan 30, 2013 2:22 pm
Reply with quote

Try adding a sequence number before sum and after sum sort it based on sequence number
Back to top
View user's profile Send private message
abby.qiong.zhang

New User


Joined: 07 Jun 2012
Posts: 26
Location: China

PostPosted: Wed Jan 30, 2013 2:32 pm
Reply with quote

Pandora-Box wrote:
Try adding a sequence number before sum and after sum sort it based on sequence number


Thanks Pandora-Box for your quick response! Can you give me a sample about how to use SEQNUM?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jan 30, 2013 2:34 pm
Reply with quote

Your sort card does not <visually> match the input ...

15,8,ch,a sorts one <extra> char after the visible ones

Code:
position  ==>123456789012345678901
sort keys ==>1115555334444 22222222
data      ==>0400022M0000142000693         000300
                                  *
Back to top
View user's profile Send private message
abby.qiong.zhang

New User


Joined: 07 Jun 2012
Posts: 26
Location: China

PostPosted: Wed Jan 30, 2013 2:47 pm
Reply with quote

enrico-sorichetti wrote:
Your sort card does not <visually> match the input ...

15,8,ch,a sorts one <extra> char after the visible ones

Code:
position  ==>123456789012345678901
sort keys ==>1115555334444 22222222
data      ==>0400022M0000142000693         000300
                                  *

Thanks Enrico, yeah, i made a mistake, it should be
Code:
14,8,CH,A


I tried again, and get the output I want.
Code:

0400022M0000142000693        000330
0400022M1000142000693        000330
0400022M2000142000693
0004088M0000142000691        000100
0004088M1000142000691        000100
0004088M2000142000691
0004088M0000142000694        000400
0004088M1000142000694        000400
0004088M2000142000694
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jan 30, 2013 2:54 pm
Reply with quote

that confirm my ( and many other's opinion )
more than 90% of errors can be found by simple(*) VISUAL inspection icon_cool.gif

(*) just rereading, no complicate walk thru!
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jan 30, 2013 3:23 pm
Reply with quote

Now how did the M0 get "summed" to become 330?
Back to top
View user's profile Send private message
abby.qiong.zhang

New User


Joined: 07 Jun 2012
Posts: 26
Location: China

PostPosted: Wed Jan 30, 2013 3:32 pm
Reply with quote

Bill Woodger wrote:
Now how did the M0 get "summed" to become 330?


It's a typo.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts To get the the current time DFSORT/ICETOOL 13
No new posts Changeman - how can we know the curr... Compuware & Other Tools 2
No new posts Fetch data from programs execute (dat... DB2 3
No new posts replace word 'MONTH' with current mon... SYNCSORT 11
No new posts Cobol program with sequence number ra... COBOL Programming 5
Search our Forums:

Back to Top