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 remove duplicates on some conditions

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

New User


Joined: 28 May 2007
Posts: 17
Location: india

PostPosted: Wed Jan 27, 2010 10:28 pm    Post subject: How to remove duplicates on some conditions
Reply with quote

I have a requirement to remove duplicates from the input file.

The input file has 2 variables, Account and Action.
The sample input is as follows:

Acct1 Action1
Acct1 spaces
Acct1 Action1
Acct2 spaces -- For account 2
Acct2 spaces -- 2 records with no action
Acct3 Action3a -- For account 3
Acct3 Action3b -- 2 records with different actions
Acct4 Action4
Acct5 spaces

Conditions are:

1)If there is a duplicate account in the file (one with Action info and another without Action info), the record with Action info is extracted. (Acct1 in the above example)

2)If there is a duplicate account, and both record do not have Action info, then only one record is extracted.(Acct 2 in the above example)

3) If there are duplicate records on account key and they have diffrerent actions, then both the records should be extracted. (Acct 3 in the above example)


The expected output is:
Acct1 Action1
Acct2 spaces
Acct3 Action3a
Acct3 Action3b
Acct4 Action4
Acct5 spaces

There is a possibility of more records for each account with same or different Action.
Back to top
View user's profile Send private message

Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Jan 27, 2010 11:27 pm    Post subject:
Reply with quote

Hi Ram Prasad,
if sequence of actions within account is not a matter then below solution will work for you.
Code:

//STEP0010 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
ACCT1 ACTION1                                                       
ACCT1                                                               
ACCT1 ACTION1                                                       
ACCT2                                                               
ACCT2                                                               
ACCT3 ACTION3A                                                     
ACCT3 ACTION3B                                                     
ACCT4 ACTION4                                                       
ACCT5                                                               
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  SORT FIELDS=(1,5,CH,A,7,8,CH,D)                                   
  SUM FIELDS=NONE                                                   
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,5))) 
  OUTFIL OMIT=(81,8,ZD,GT,1,AND,7,8,CH,EQ,C' ')             
/*                                                         


Output will be
Code:

ACCT1 ACTION1
ACCT2         
ACCT3 ACTION3B
ACCT3 ACTION3A
ACCT4 ACTION4
ACCT5         
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Jan 27, 2010 11:43 pm    Post subject:
Reply with quote

Sorry no need of ifthen actually
Code:

//SYSIN    DD *                                       
  SORT FIELDS=(1,5,CH,A,7,8,CH,D)                     
  SUM FIELDS=NONE                                     
  OUTREC OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,5))       
  OUTFIL OMIT=(81,8,ZD,GT,1,AND,7,8,CH,EQ,C' ')       
/*                                                     
Back to top
View user's profile Send private message
ram prasad

New User


Joined: 28 May 2007
Posts: 17
Location: india

PostPosted: Thu Jan 28, 2010 12:26 am    Post subject: Reply to: How to remove duplicates on some conditions
Reply with quote

Thank you so much Sambhaji..
Its working perfectly..
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 Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm
No new posts Remove junk values in a file and rite... KP1125 DFSORT/ICETOOL 2 Wed Jan 25, 2017 9:58 pm
No new posts Sort Card to Remove Duplicate records... raj4neo SYNCSORT 2 Wed Jan 25, 2017 4:44 am
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am


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