Get record count while using SUM FIELDS in SORT.

IBM's Sort Product, ICETOOL, ICEMAN and ICEGENER.
Post Reply
saeedansari
New Member
Posts: 1
Joined: Fri Sep 18, 2015 9:13 am

Get record count while using SUM FIELDS in SORT.

Post by saeedansari »

Hi.

I ned a help in a SORT. Consider the input like this:

Code: Select all

XX 100 
XX 140 
YY 500 
YY 50 
YY 50 
I need the counts of duplicates in another column. Using SUM fields gives the follwoing output:

Code: Select all

XX 240 
YY 600 
But as I said before, I also need to add count of duplicate records in output like this:

Code: Select all

XX 240 2 
YY 600 3 
Please help me, how to do it.
User avatar
Magesh_j
Registered Member
Posts: 33
Joined: Sun Sep 04, 2016 8:50 pm

Re: Get record count while using SUM FIELDS in SORT.

Post by Magesh_j »

Assuming input is in sorted order 1,2 and the value field is right aligned (4,3), in your example you are showing it as left aligned.

Here is the solution :

Code: Select all

OPTION COPY                                                         
OUTFIL REMOVECC,NODETAIL,                                           
SECTIONS=(1,2,                                                      
TRAILER3=(1,2,X,TOT=(4,3,ZD,TO=ZD,LENGTH=3),X,COUNT=(EDIT=(IT))))   
If left aligned then

Code: Select all

//SYSIN    DD *                                                     
  OPTION COPY                                                       
  INREC OVERLAY=(4:4,3,SQZ=(SHIFT=RIGHT))                           
  OUTFIL REMOVECC,NODETAIL,                                         
  SECTIONS=(1,2,                                                    
  TRAILER3=(1,2,X,TOT=(4,3,ZD,TO=ZD,LENGTH=4),X,COUNT=(EDIT=(IT)))) 
/*                                                                  
Note : the output sum value is of 4 bytes and count is of 2 bytes, you may need to adjust according to your requirements.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DFSort, ICETOOL, ICEMAN, ICEGENER.”