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

How to retain the last records among duplicates


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

Active User


Joined: 31 Mar 2010
Posts: 134
Location: India

PostPosted: Fri May 28, 2010 8:06 pm
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: 2146
Location: At my coffee table

PostPosted: Fri May 28, 2010 8:13 pm
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: 134
Location: India

PostPosted: Fri May 28, 2010 8:41 pm
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: 134
Location: India

PostPosted: Sat May 29, 2010 8:14 am
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: 2146
Location: At my coffee table

PostPosted: Sat May 29, 2010 2:05 pm
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: 134
Location: India

PostPosted: Mon May 31, 2010 6:38 pm
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 Developer


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

PostPosted: Tue Jun 01, 2010 11:35 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top