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

Record with highest sy-tabix

Former Member
0 Likes
755

Hi,

In an internal table I have 10 records for a field like

A

A

B

C

D

E

E

D

E

D

Is it possible to get the records D and E which has highest sy-index.

good solution will be rewarded.

Thanks and Regards,

Neerup.

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
635

hi,

for example:

DATA : lv_tabix TYPE sy-tabix.

LOOP AT itab WHERE field EQ 'D'.
lv_tabix = sy-tabix.
ENDLOOP.

Now lv_tabix contains then number of last line with D.

hope this helps

ec

3 REPLIES 3
Read only

JozsefSzikszai
Active Contributor
0 Likes
636

hi,

for example:

DATA : lv_tabix TYPE sy-tabix.

LOOP AT itab WHERE field EQ 'D'.
lv_tabix = sy-tabix.
ENDLOOP.

Now lv_tabix contains then number of last line with D.

hope this helps

ec

Read only

Former Member
0 Likes
635

sort itab by field.

loop at itab.

v_count = v_count + 1.

at end of field.

*populate an internal table with the values

itab1-field = itab-field.

itab1-count = v_count.

append itab1.

clear v_count.

endloop.

endloop.

itab1 has fields and the no. of times they appear in ITAB.

sort itab1 count descending.

Read only

Former Member
0 Likes
635

Neerup,

Neerup wrote:

Is it possible to get the records D and E which has highest sy-index.

but in your question you mention as :

Record with highest sy-tabix

any ways:

just sort decending then fetch the first record then exit from loop.