‎2008 Jul 01 4:03 PM
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.
‎2008 Jul 01 4:07 PM
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
‎2008 Jul 01 4:07 PM
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
‎2008 Jul 01 4:07 PM
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.
‎2008 Jul 01 4:09 PM
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-tabixany ways:
just sort decending then fetch the first record then exit from loop.