AT NEW....END AT 1. Can only be used inside the LOOP...ENDLOOP statements. 2. Cannot be used with WHERE expression. 3. ELSE clause cannot be used between AT NEW...ENDAT | ON CHANGE OF....ENDON 1. Can be used in any kind of loop constructing statements like LOOP..ENDLOOP, SELECT...ENDSELECT,CASE...ENDCASE, DO...ENDDO,WHILE...ENDWHILE. Can be used outside the loop also. 2. Can be used with WHERE expression. 3. ELSE clause can be used between ON CHANGE OF...ENDON. |
Behaviour during execution :
These statements execution can be explained with an example in the following way
Consider an internal table itab,with fields f1,f2 and f3.
SORT itab BY f2.
LOOP AT itab.
AT NEW f2.
...
ENDAT.
ON CHANGE OF itab-f2.
...
ENDON.
ENDLOOP.
AT NEW statement triggers when concerned field changes and also when the fields left to the concerned field changes,in this case if f1 or f2 changes to a new value.
The right side fields,in this case field f3 will be considered as.... * if it is character type(non-numeric) field
0 if it is numeric type field
ON CHANGE OF statement triggers ony if the concerned field changes, in this case f2.
These statements execution can be explained with an example in the following way
Consider an internal table itab,with fields f1,f2 and f3.
SORT itab BY f2.
LOOP AT itab.
AT NEW f2.
...
ENDAT.
ON CHANGE OF itab-f2.
...
ENDON.
ENDLOOP.
AT NEW statement triggers when concerned field changes and also when the fields left to the concerned field changes,in this case if f1 or f2 changes to a new value.
The right side fields,in this case field f3 will be considered as.... * if it is character type(non-numeric) field
0 if it is numeric type field
ON CHANGE OF statement triggers ony if the concerned field changes, in this case f2.