Application Development 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: 

How to read an internal table with duplicate key field

0 Kudos
655

When i am trying to read an internal table which has duplicate key fields it is reading the same entry again and again and not assigning anything to the second row of that internal table.
Can you please tell me how to read that second entry in that internal table.

2 REPLIES 2

0 Kudos
189

hi,

Sort the internal table by the field .

then read the internal table table with key = field .

sample code :

LT_ITAB1[] = LT_ITAB[] .

DELETE ADJACENT DUPLICATES FROM LT_ITAB1 COMPARING FIELD1.

SORT LT_ITAB1 BY FIELD1 .

READ TABLE LT_ITAB1 INTO LW_ITAB1  WITH KEY

                                                                FIELD1 = FIELD1 BINARY SEARCH .

Regards,

Amaresh

raghug
Active Contributor
0 Kudos
189

Use a LOOP AT

LOOP AT li_table INTO l_table_line [USING KEY keyname] [WHERE xyz condition].

     [...]

ENDLOOP.