Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Internal Table

Former Member
0 Likes
543

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."

5 REPLIES 5
Read only

Former Member
0 Likes
518

This ll do.........

sort itab by fld.

loop at itab.
at new fld.
continue.
endat.
delete itab.
endloop.

Cheers,

jose.

Read only

former_member156446
Active Contributor
0 Likes
518

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

Read only

Former Member
0 Likes
518

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

Read only

Former Member
0 Likes
518

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

Read only

Former Member
0 Likes
518

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.