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
 

 

How to retain the last records among duplicates

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

Active User


Joined: 31 Mar 2010
Posts: 132
Location: India

PostPosted: Fri May 28, 2010 8:06 pm    Post subject: How to retain the last records among duplicates
Reply with quote

Hi,

I am using the below JCL to remove the duplicates on the key (1,16,PD)

Code:

//STEP1    EXEC PGM=ICETOOL                                 
//TOOLMSG  DD SYSOUT=*                                     
//DFSMSG   DD SYSOUT=*                                     
//DATA     DD DSN=ITM&ENV..P472.B472.ITEMUPC.EXTR.BSAM,     
//            DISP=SHR                                     
//FILE1    DD DSN=ITM&ENV..P472.B472.ITEMUPC.FILE1.BSAM,   
//            DISP=(NEW,CATLG,CATLG),                       
//            SPACE=(50,(11,11),RLSE),                     
//            DCB=(RECFM=FB,LRECL=50),                     
//            AVGREC=U,VOL=(,,,59)                         
//FILE2  DD   DSN=ITM&ENV..P472.B472.ITEMUPC.FILE2.BSAM,   
//            DISP=(NEW,CATLG,CATLG),                       
//            SPACE=(50,(12,12),RLSE),                     
//            DCB=(RECFM=FB,LRECL=50),                     
//            AVGREC=U,VOL=(,,,59)                         
//TOOLIN   DD *
  SELECT FROM(DATA) TO(FILE1) ON(1,16,PD) NODUPS
  SORT FROM(FILE1) USING(CTL1)
//CTL1CNTL DD *
  SORT FIELDS=(17,1,CH,D)
  OUTFIL FNAMES=(FILE2)
//SYSOUT   DD  SYSOUT=*   
                         
//SYSUDUMP DD  SYSOUT=U                             

suppose there are 5 records and all are dulicates for the key (1,16,PD). i want to reatin the fifth record. can anybody please tell me how to do this using ICETOOL?

Thanks
Gagan
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri May 28, 2010 8:13 pm    Post subject:
Reply with quote

LAST
Limits the records selected to those with ON values that occur only once (value count = 1) and the last record of those with ON values that occur more than once (value count > 1). You can use this operand to keep just the last record for each unique field value
?
Back to top
View user's profile Send private message
GaganGarg

Active User


Joined: 31 Mar 2010
Posts: 132
Location: India

PostPosted: Fri May 28, 2010 8:41 pm    Post subject:
Reply with quote

Thanks a lot. It worked fine icon_smile.gif
Back to top
View user's profile Send private message
GaganGarg

Active User


Joined: 31 Mar 2010
Posts: 132
Location: India

PostPosted: Sat May 29, 2010 8:14 am    Post subject:
Reply with quote

HI,

i am sorry to say that i put my requirement wrongly. actually i got the requirement cleary after doing the above JCL. My requirement is:

Suppose a file conntais the records like this:
0000000100000002I
0000000100000002D
0000000100000002I
0000000100000002D
0000000300000004I
0000000300000004D
0000000300000004I

in this case, for the key from 1 to 16, first 4 records are duplicates and the next 3 records are duplicates. for the first key, 0000000100000002, after insert "I' there is one delete D. so insert is balanced by Delete. so i don't want these records in the O/P file.
for the next key,0000000300000004, there is an Insert I, Delete D and again Insert I, so i want to keep the last record of this key i.e. Insert.

to summarize, we can say i want to keep the last record if a key is having odd number of record. Please help me to achieve this.

Thanks
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sat May 29, 2010 2:05 pm    Post subject:
Reply with quote

Have you thought of an approach using JOINKEYs such as hinted in New output file based on comparing a field from one file?
Back to top
View user's profile Send private message
GaganGarg

Active User


Joined: 31 Mar 2010
Posts: 132
Location: India

PostPosted: Mon May 31, 2010 6:38 pm    Post subject:
Reply with quote

Hi,

Following JCL can be used for the above requirement:

Code:

//ICETL01  EXEC PGM=ICETOOL                                           
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//SYSPRINT DD SYSOUT=*                                                 
//IN       DD DSN=OPERA12.INFILE,                   
//            DISP=SHR                                                 
//TEMP     DD DSN=&&TEMP1,UNIT=SYSDA,SPACE=(CYL,(100,100),RLSE),
//         DISP=(MOD,PASS)
//FILE     DD DSN=OPERA12.FILE1,DISP=SHR     
//TOOLIN   DD *                                                       
  SELECT FROM(IN) TO(TEMP) ON(1,16,PD) LAST USING(SEQN) 
  COPY FROM(TEMP) TO(FILE) USING(INCL)                 
/*                                                                     
//SEQNCNTL DD *                                                       
  INREC BUILD=(1,50,51:SEQNUM,10,ZD,RESTART=(1,16)) 
  SORT FIELDS=COPY                                                 
  OUTFIL FNAMES=TEMP,                                               
         BUILD=(1,60,61:51,10,ZD,MOD,+02,TO=ZD,LENGTH=10,80:X)               
/*                                                                     
//INCLCNTL DD * 
  INCLUDE COND=(61,10,ZD,NE,+0)                                       
  SORT FIELDS=(17,01,CH,D)                                             
  OUTREC BUILD=(1,50,80:X)                                                       
/*                                   



Thanks
Gagan
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Tue Jun 01, 2010 11:35 pm    Post subject:
Reply with quote

You don't need two passes to do this. You can do it in one pass with a DFSORT/ICETOOL job like the following:

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
0000000100000002I    A
0000000100000002D    B
0000000100000002I    C
0000000100000002D    D
0000000300000003I    E
0000000300000003D    F
0000000300000003I    G
0000000300000005I    H
0000000300000007I    I
0000000300000007D    J
0000000300000007I    K
0000000300000008D    L
0000000300000008I    M
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(1,16,CH) LAST USING(CTL1)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,
    OVERLAY=(81:SEQNUM,8,BI,RESTART=(1,16)))
  OUTFIL FNAMES=OUT,INCLUDE=(88,1,BI,EQ,B'.......1'),
    BUILD=(1,80)
/*


OUT would have:

Code:

0000000300000003I    G     
0000000300000005I    H     
0000000300000007I    K     
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 Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts Updating the counters after eliminati... PANDU1 DFSORT/ICETOOL 12 Mon Nov 21, 2016 9:47 am
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


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