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
 

 

SORT to fetch grouped records of particular count

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
N.Nirmal Raj

New User


Joined: 19 Sep 2013
Posts: 7
Location: India

PostPosted: Tue Oct 01, 2013 12:09 am    Post subject: SORT to fetch grouped records of particular count
Reply with quote

Hi ,

My requirement is to extract records based on grouping key which should be
equal to 3 records, should not pick any other records having grouping > 3
or <3.


Key Recd

a 1
a 1
a 1
a 1
a 1
b 2
b 2
b 2
c 3
c 3
c 3
d 4
d 4

Desired Output

b 2
b 2
b 2
c 3
c 3
c 3

I used the following sort card but it fetched records grouped in 1,2 & 3.
I need only records grouped in 3.
//SYSIN DD *
SORT FIELDS=(1,4,BI,A,5,10,D)
INREC=(1:31,32:SEQNUM,3,ZD,RESTART=(1,4))
OUTFIL FILES=OUT,BUILD=(1:31,32,ZD,LT,+4)
/*
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Tue Oct 01, 2013 12:42 am    Post subject: Reply to: SORT to fetch grouped records of particular count
Reply with quote

Use JOINKEYS with the same dataset for both input files. Join on your key.

In JNF2CNTL use INREC to set up a record (WHEN=INIT and BUILD containng the key and a count of one which is big enough for the greatest number of multiple keys that you can have.

Use SUM FIELDS= for the count field.

If your input is sorted, specify SORTED,NOSEQCHK on the F1 JOINKEYS.

Define a REFORMAT record which has your entire F1 record plus the summed count from F2.

Use OPTION COPY for the main task.

Use OUTFIL INCLUDE= for the summed count on the reformat being equal to three, and use BUILD= to cut the summed count off the record.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Oct 01, 2013 1:05 am    Post subject:
Reply with quote

N.Nirmal Raj,

Use SELECT operator with EQUAL(3) and you will get the desired results.

for your sample data assuming the key is the first 1 byte then use the following toolin
Code:

//TOOLIN   DD *                               
  SELECT FROM(IN) TO(OUT) ON(1,1,CH) EQUAL(3)
//*


The output from the above is keys b and c
Back to top
View user's profile Send private message
N.Nirmal Raj

New User


Joined: 19 Sep 2013
Posts: 7
Location: India

PostPosted: Tue Oct 01, 2013 10:35 pm    Post subject: Reply to: SORT to fetch grouped records of particular count
Reply with quote

Skolusu,

Thanks a lot your sort card worked good.
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
No new posts How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am


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