|
View previous topic :: View next topic
|
| Author |
Message |
ram prasad
New User
.jpg)
Joined: 28 May 2007 Posts: 17 Location: india
|
|
|
|
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 |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
 |
ram prasad
New User
.jpg)
Joined: 28 May 2007 Posts: 17 Location: india
|
|
|
|
Thank you so much Sambhaji..
Its working perfectly.. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|