Sunday, March 13, 2011

Internal Table control level processing

PREREQUISITE: Sort your internal table by the fields used in the control command

This is very useful when dealing reports! 

NOTE: Don't put any condition in the LOOP AT statement. The control level processing logic will be destroyed. But, you can still put a condition as long as you put your code after the ENDAT with the necessary conditions.

Syntax

LOOP AT itab result ...
  [AT FIRST.
     ...
   ENDAT.]
    [AT NEW comp1.
       ...
     ENDAT.
       [AT NEW comp2.
         ...
       ENDAT.
         [...]]]
           [ ... ]
       [[[...]
       AT END OF comp2.
         ...
       ENDAT.]
     AT END OF comp1.
       ...
     ENDAT.]
  [AT LAST.
     ...
  ENDAT.]
ENDLOOP.

No comments:

Post a Comment