Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SUM and keep current sequence

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: SUM and keep current sequence
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

Moderator


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

PostPosted: Wed Jan 30, 2013 2:22 pm    Post subject:
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Jan 30, 2013 2:34 pm    Post subject: Reply to: SUM and keep current sequence
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    Post subject: Re: Reply to: SUM and keep current sequence
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed Jan 30, 2013 2:54 pm    Post subject: Reply to: SUM and keep current sequence
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Wed Jan 30, 2013 3:23 pm    Post subject: Reply to: SUM and keep current sequence
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    Post subject: Re: Reply to: SUM and keep current sequence
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Get correct date and time when curren... balaji81_k DB2 24 Fri Oct 14, 2016 10:40 pm
No new posts Sequence number add in SORT pshongal SYNCSORT 3 Fri Sep 02, 2016 3:32 pm
No new posts alphanumeric sequence generation sivaprasad.gadhi COBOL Programming 6 Wed Mar 30, 2016 3:03 am
No new posts alphanumeric sequence generation sivaprasad.gadhi DFSORT/ICETOOL 8 Mon Mar 21, 2016 1:09 am
No new posts Retrieve current year or month using ... vnktrrd DFSORT/ICETOOL 15 Tue Mar 15, 2016 4:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us