04-08-2008 10:00 AM
Hello Friends,
I have a internal table link this:
NAME AGE
RAJ 26
RAVI 32
RAJ 26
SOM 29
SOM 29
How can I display only unique name from this internal table?
My o/p should look like this:
NAME AGE
RAJ 26
RAVI 32
SOM 29
Thanks,
Shreekant
04-08-2008 10:03 AM
Hi,
sort itab by name.
delete adjacent duplicates from itab comparing name.
loop at itab.
write itab-name, itab-age.
endloop.
Thanks,
Arun
04-08-2008 10:03 AM
Very simple
Delete duplicate entries from your internal table
Syntax
Delete adjacent duplicate entries from itab comapring
field1 and field2
after this display the o/p
It will work fine
Thnkx
04-08-2008 10:06 AM
The code would be like this:
SORT <internaltable> BY name.
DELETE ADJACENT DUPLICATES FROM <internaltable> COMPARING ALL FIELDS.
Then..
LOOP AT <internaltable> INTO <workarea>.
WRITE: / <workarea>-name, <workarea>-age.
ENDLOOP.
04-08-2008 10:19 AM
Hi sreekant,
One way is doing is as my friends above said sorting and deleting
and the the option is manually doing it by putting some logic
like this..................
data : v_name(30),
v_age(30).
sort itab by name age.
loop at itab.
if v_name = itab-name and v_age = itab-age.
delete itab.
else.
v_name = itab-name.
v_age = itab-age.
write : itab.
endif.
endloop.
Hope this will be helpful.
Regards,
Karthik
04-08-2008 10:33 AM
Hi,
Sort internal table by name.
delete adjacent duplicates from internal table.
loop at internal table.
write: / internal table.
endloop.
04-08-2008 10:38 AM
Hi,
While selecting data from database table use SELECT DISTINCT otherwise
sort itab by name.
DELETE ADJACENT DUPLICATES
from itab copmaring name.
then display it
Regards,
Prashant