IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Last 3 duplicates of each key value


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sandy0407

New User


Joined: 01 Aug 2010
Posts: 7
Location: Morley

PostPosted: Thu Apr 14, 2011 11:45 pm
Reply with quote

Hi,

I have the following requirement:

The input file is of 10 bytes (FB) as given below and the key is first 6 bytes (numeric). There are duplicate values in the file as shown below. The requirement is to write at most last 3 duplicates of each key value while keeping the order of records same. The output file is also of 10 bytes FB.

The input file is as given below:

111111AAAA
111111ABCD
111111ACVB
111111CCCC
111111BBBB
123456AAAA
123456BBBB
333333VVVV
333333BBBB
333333NNNN
333333TTTT

The output required is as shown below:

111111ACVB
111111CCCC
111111BBBB
123456AAAA
123456BBBB
333333BBBB
333333NNNN
333333TTTT

I have achieved the results using sort and icetool in multiple steps. But can it done in a single step?

Thanks and Regards.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Apr 15, 2011 1:09 am
Reply with quote

Here's a one step DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file (FB/10)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file (FB/10)
//TOOLIN DD *
SELECT FROM(IN) TO(T1) ON(1,6,CH) FIRST(3) -
  USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(11:SEQNUM,8,ZD)
  SORT FIELDS=(1,6,CH,A,11,8,ZD,D)
/*
//CTL2CNTL DD *
  SORT FIELDS=(1,6,CH,A,11,8,ZD,A)
  OUTREC BUILD=(1,10)
/*
Back to top
View user's profile Send private message
sandy0407

New User


Joined: 01 Aug 2010
Posts: 7
Location: Morley

PostPosted: Fri Apr 15, 2011 1:35 am
Reply with quote

Thanks Frank. I used the same logic but in 3 different steps.

However, I had faced problems while using temporary file as the input file was very large (about 7 million records). We increased the number of cylinders of the temp dataset but the job was still failing due to space abend.

When we hard coded the intermediate file (replaced the temporary file with an emplty file created in other step) and then passed it to the subsequent steps , the problem was resolved.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Apr 15, 2011 1:58 am
Reply with quote

Sandy,

My job uses T1 for output and then input. T1 can be a permanent file if you need it to be. So you should be able to use my one step job.
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

 


Similar Topics
Topic Forum Replies
No new posts How to remove block of duplicates DFSORT/ICETOOL 8
This topic is locked: you cannot edit posts or make replies. Compare files with duplicates in one ... DFSORT/ICETOOL 11
No new posts Merging 2 files but ignore duplicate... DFSORT/ICETOOL 1
No new posts COUNT the number of duplicates DFSORT/ICETOOL 3
This topic is locked: you cannot edit posts or make replies. SUM FIELDS=NONE in reverse - Get dupl... DFSORT/ICETOOL 9
Search our Forums:

Back to Top