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

to delete a specific record when duplicates are present


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

New User


Joined: 15 Jun 2006
Posts: 13

PostPosted: Wed Jan 23, 2008 1:15 pm
Reply with quote

Hi,
I have a file with the below input

1111 2007 A
1111 2007 B
2222 2008 A
3333 2009 A

HERE IN THE ABOVE EXAMPLE THE FIRST 2 RECORDS ARE SAME WHEN WE COMPARE THE FIRST TWO FIELDS,,,I.E WE HAVE A DUPLICATE. NOW WHEN SUCH CONDITION HAPPENS I WANT TO DELETE THE RECORD WITH B. HOW CAN I ACHIEVE THE SAME. CAN SOMEONE HELP ME.....
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Jan 23, 2008 2:24 pm
Reply with quote

Assuming the thrid field(A,B) are in sorted order...
try this ICETOOL solution
Code:
//****************************************
//GETMATCH EXEC PGM=ICETOOL               
//TOOLMSG  DD SYSOUT=*                   
//DFSMSG   DD SYSOUT=*                   
//IN       DD *                           
1111 2007 A                               
1111 2007 B                               
2222 2008 A                               
3333 2009 A                               
/*                                       
//OUT      DD SYSOUT=*                   
//TOOLIN   DD *                           
  SELECT FROM(IN) TO(OUT) ON(1,9,CH) FIRST
/*                                       
Back to top
View user's profile Send private message
zacharti

New User


Joined: 15 Jun 2006
Posts: 13

PostPosted: Wed Jan 23, 2008 10:00 pm
Reply with quote

hi,
krisprem

its not in sorted order, then what can we do...?????.
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: Wed Jan 23, 2008 10:13 pm
Reply with quote

zacharti,

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

Code:

//S1    EXEC  PGM=ICETOOL                                         
//TOOLMSG DD SYSOUT=*                                             
//DFSMSG  DD SYSOUT=*                                             
//IN  DD *                                                         
1111 2007 A                                                       
1111 2007 B                                                       
2222 2008 A                                                       
3333 2009 A                                                       
4444 2009 B                                                       
4444 2009 A                                                       
/*
//OUT DD SYSOUT=*                                                 
//TOOLIN DD *                                                     
SELECT FROM(IN) TO(OUT) ON(1,4,CH) ON(6,4,CH) FIRST USING(CTL1)
/*   
//CTL1CNTL DD *                                                   
  SORT FIELDS=(1,4,CH,A,6,4,CH,A,11,1,CH,A)                       
/*


OUT would have:

Code:

1111 2007 A   
2222 2008 A   
3333 2009 A   
4444 2009 A   


Is that what you want?
Back to top
View user's profile Send private message
zacharti

New User


Joined: 15 Jun 2006
Posts: 13

PostPosted: Wed Jan 23, 2008 10:44 pm
Reply with quote

yes frank but cout you explain me these sort card
Back to top
View user's profile Send private message
zacharti

New User


Joined: 15 Jun 2006
Posts: 13

PostPosted: Wed Jan 23, 2008 11:02 pm
Reply with quote

hey frank,
THANKS A LOT I TRIED IT , IT WORKS FINE......
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: Wed Jan 23, 2008 11:42 pm
Reply with quote

Quote:
could you explain me these sort card


SELECT FROM(IN) TO(OUT) ON(1,4,CH) ON(6,4,CH) FIRST USING(CTL1)

This is an ICETOOL SELECT operator:

FROM(IN) - defines the input file
TO(OUT) - defines the output file
ON(1,4,CH) ON(6,4,CH) - defines the ON fields as in positions 1-4 and 6-9. We check for dups and nondups on these two fields.
FIRST - keeps the first record with dup on fields (e.g. for 1111 2007 A and 1111 2007 B, it keeps 1111 2007 A) as well as unique records (e.g. 2222 2008 A).
USING(CTL1) - tells DFSORT to use the DFSORT control statements in CTL1CNTL.

CTL1CNTL has:

Code:

   SORT FIELDS=(1,4,CH,A,6,4,CH,A,11,1,CH,A) 


which sorts on the field in positions 1-4 (first ON field), the field in positions 6-9 (the second ON field) and the field in position 11 (not an ON field). The SORT is performed before SELECT processing. By sorting on the field in position 11 but not using it as an ON field, we ensure that SELECT sees the A record before the B record for each dup pair (for the two on fields) and keeps the A record as the FIRST record.
Back to top
View user's profile Send private message
zacharti

New User


Joined: 15 Jun 2006
Posts: 13

PostPosted: Thu Jan 24, 2008 2:55 am
Reply with quote

Hi Frank,
Thanks a lot frank for your answers.
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 split large record length file... DFSORT/ICETOOL 10
No new posts DELETE SPUFI DB2 1
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts DSNTIAUL driven delete IBM Tools 0
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top