09-22-2010 10:09 AM
Hi All,
Requirement is that we have a database table tab1 like this
id name address
1 AA1 X
1 AA1 X
2 AA2 Y
2 AA2 Y
and we have to insert this data of tab1 into tab2 in this form
id name address
1 AA1 X
AA1 X
2 AA2 Y
AA2 Y
all the duplicate ids are removed .
How an we do this . Please suggest.
thanks
ABAP Developer1
09-22-2010 10:14 AM
Hi ,
try this way.
in the Id field remove the Initial check.
and whem u tr to Insert the first value.. do this..
Select Max(Id) from <table> into w_maxid where name = 'XXX".
if sy-subrc eq 0.
Id = w_maxid + 1.
name = 'XXX'."dfrom above condition
Insert above value to table
else.
Id = 0.
name = 'XXX'."dfrom above condition
Insert above value to table
Endif.
Prabhudas
Edited by: Prabhu Das on Sep 22, 2010 2:45 PM
09-22-2010 10:18 AM
Hi,
Are you using the query "SELECT FOR ALL ENTRIES........."
Then use the statement "SORT <itab> WITH KEY...." And then "DELETE ADJACENT DUPLICATES FROM................"
Hope it will solve your problem.
Thanks&Regards
09-22-2010 10:36 AM
>
> Requirement is that we have a database table tab1 like this
> id name address
> 1 AA1 X
> 1 AA1 X
> 2 AA2 Y
> 2 AA2 Y
If your table has these 3 fields only, then i don't think you can have this situation.
DDIC tables can store records with unique keys only. What are the key fields of your DB table ?
BR,
Suhas
09-22-2010 10:38 AM
Hi,
Change the database table using SE11. put id field as key.
then try to activate using transaction SE14.
Amitava.
09-22-2010 11:06 AM
If it is database table -
Make the ID as Primary key - It will not allow then duplicate values.
If it is for Internal table calculations in program .
Follow - ITAB[] = ITAB1[]. "Copy the internal tabel values
sort ITAB by key. "Sort by key
Delete adjacent duplicates from ITAB comparing KEY ." Delete the adjacent duplicates using the sorted key