IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search Log in to check your private messages Log in
 

SORT to fetch grouped records of particular count


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Tue Oct 01, 2013 12:42 am
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 

Search our Forum:

Similar Topics
Topic Forum Replies
No new posts Inserting records into the empty segm... IMS DB/DC 0
No new posts COBOL VS SORT Utility for file format... COBOL Programming 6
No new posts Copying data from prev record using SORT SYNCSORT 19
No new posts how to get total count from numeric d... SYNCSORT 9
No new posts Combining more 4 files with sorted or... DFSORT/ICETOOL 3

Back to Top