Hello experts,
I am wondering that whether the follow code is legal/safe:
CLEAR old_key.
LOOP AT itab INTO itab_wa.
IF itab_wa-key <> old_key.
old_key = itab_wa-key.
LOOP AT itab INTO itab_wa1 WHERE key = old_key.
* do some processing here.
ENDLOOP.
ENDIF.
ENDLOOP.
Thanks and best regards.
zj
If the code is unclear then the maintenance of the code will be expensive, and lead to errors.
Try:
SORT ITAB BY key.
CLEAR old_key
LOOP AT itab INTO itab_wa.
IF itab_wa-key <> old_key.
old_key = itab_wa-key.
* Do first time through processing.
ENDIF.
Do some processing here.
ENDLOOP.
If you do not have any need for first time through process then you do not need 'old_key'.
Add a comment