DFSORT: SORT and GROUP



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

DFSORT: SORT and GROUP

Postby New2MF » Tue Jan 11, 2011 11:57 am

Hi,

Below is the sample input file -
Input File:

ACCOUNT AMONUT
111111 100.00
999999 200.00
888888 500.00
999999 50.00
111111 150.00
999999 600.00
888888 750.00
999999 999.00
111111 200.00
999999 250.00
888888 300.00

I want to create a file in which the records will be as follows -

Required Output:
ACCOUNT AMONUT
999999 999.00
999999 600.00
999999 250.00
999999 200.00
999999 50.00
888888 750.00
888888 500.00
888888 300.00
111111 200.00
111111 150.00
111111 100.00

The sorting needs to be done on the amount field but the grouping should be on the Account # field in such a way that the records corresponding to the account # having the highest amount should be listed in descending order in the output file. Then the records corresponding to the account of 2nd highest amount and so on.

I'm not good at DFSORT/SYNCSORT. And not sure if this kind or sorting+grouping would be possible. But thought of exploring the possibilities before having to write a program to create the required output file.[code][/code]
New2MF
 
Posts: 1
Joined: Tue Jan 11, 2011 11:27 am
Has thanked: 0 time
Been thanked: 0 time

Re: DFSORT: SORT and GROUP

Postby NicC » Tue Jan 11, 2011 3:28 pm

sort on the account field descending and then the amount field descending.
  SORT FIELDS=(p1,p2,CH,D,p3,p4,CH,D)

where p1 and p2 are the start and end positions of Account and p3, p4 the start and end positions of Amount. Check with the manual (numerous links within the DFSORT section of the forum) for the correct data type - I have put CH because I cut and pasted but ZD may be more to the point.

Also, when posting sort questions you should specify in your post the following
LRECL, RECFM, start position of all relevant fields and end position of all relevant fields - remember to add 4 bytes to these positions if the file has variable length records. Also include sample input data including duplicates if such are allowed and sample output data and the rules for getting from input to output.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: DFSORT: SORT and GROUP

Postby Frank Yaeger » Tue Jan 11, 2011 11:59 pm

I have put CH because I cut and pasted but ZD may be more to the point.


Actually, UFF would probably be the correct format to use for the numbers.

New2MF,

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss? ... g3T7000080
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post