2012 Dec 18 2:16 PM
Hi,
I would like to find out all the lines of an internal table itab (without headline) which have some fields in common.
so I defined two field-symbols <fs1> and <fs2>, looped the itab and assigned it to <fs1> : LOOP AT itab ASSIGNING <fs1>.
Next step, I want to assign <fs2> to the following line of the current line, and compare <fs2> to <fs3> until the end of the page. I don't know how to assign a field-symbol to the specified line of a internal table.
Or if you have other propositions, please do not hesitate to tell me.
Thx a lot.
Yi
2012 Dec 18 2:46 PM
Try
LOOP AT xxx ASSIGNING <fs1>
l_tabix = sy-tabix + 1. "Next row
....
" Read Next Row
READ TABLE xxx ASSIGNING <fs2> INDEX l_tabix.
Regards,
Christian
2012 Dec 18 2:46 PM
Try
LOOP AT xxx ASSIGNING <fs1>
l_tabix = sy-tabix + 1. "Next row
....
" Read Next Row
READ TABLE xxx ASSIGNING <fs2> INDEX l_tabix.
Regards,
Christian
2012 Dec 18 2:53 PM
Hi Yi,
have you tried to implement one of the two most used searching algoritms?
- sequential/linear search
- binary search
If not, you can find lot of information and example code.
Regards,
2012 Dec 18 2:54 PM
Hi Yi
As Christian said above you can Read the table by Index while looping.
Or
You can Loop save the first line and then compare the second to the previous.
Eg.
LOOP AT itab ASSIGNING <fs1>.
IF <fs2> IS INITIAL.
<fs2> = <fs1>.
ELSE.
"Compare
ENDIF.
ENDLOOP.
Regards
Vic
2012 Dec 18 3:40 PM
Hi Yi,
See the section on control level processing in the document Processing Table Entries in Loops. Depending on what you are trying to do, you may be able to accomplish your task with the AT FIRST, AT NEW, AT LAST, AT END OF additions. Just be aware that the order of fields in the table structure and the sort order of records plays a role in control level processing.
Cheers,
Amy