‎2008 Feb 22 4:30 AM
Hello abap gurus,,
1. How to delete duplicate elements from an internal table without using any query??with command..
Ex: 1, 2, 1 ,3 ,1 ,4 ,1 ,5 ,1 , 6, 1, 7, 8, 8,9 1 ,1 ,1 ,1.
output: 1 2 3 4 5 6 7 8 9.
note don't use :"delete adjucent duplicates from itab comparing field."
‎2008 Feb 22 4:35 AM
This ll do.........
sort itab by fld.
loop at itab.
at new fld.
continue.
endat.
delete itab.
endloop.Cheers,
jose.
‎2008 Feb 22 4:35 AM
assuming you have the records in horizontal fashion.. as said in ur question.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs_record> TO <fs_comp>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
lf_buf = <fs_comp>.
if lf_line cs lf_buf.
exit.
endif.
CONCATENATE lf_line lf_buf INTO lf_line .
ENDIF.
CLEAR lf_buf.
ENDDO.<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Feb 22, 2008 5:57 PM
‎2008 Feb 22 4:35 AM
Hi
Do the follwoing:
SORT <itab> by <field>.
DELETE ADJACENT DUPLICATES from <itab> COMPARING <field>.
You will have to use delete adj dupl only after sorting.
Thanks
Vijay
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Feb 22, 2008 5:57 PM
‎2008 Feb 22 4:41 AM
declare itab2 like itab1
sort the itab
loop itab
*use control break
at end of fld1.
itab2 = itab1
append itab2
endat
endloop.
free itab1.
now, ur itab2 contains rows without duplicates
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Feb 22, 2008 5:58 PM
‎2008 Feb 22 6:47 AM
Hi,
firsst you sort the internal table by field.
then use control break statements(at new field) to fulfil your wish. Dont forget to use control break statement in a loop.