Skip to Content
0
Former Member
Apr 27, 2010 at 03:24 AM

Why the combination of LOOP AT <itab> WHERE and AT event should be avoided?

149 Views

Hi Guys,

I intended to use the combination of LOOP AT <itab> WHERE and AT event in my code as the following.

SORT itab BY a b.
LOOP AT itab INTO wa WHERE a = '2'.
    AT NEW b.
    ...
    ENDAT.
ENDLOOP.

After run the code, I got what I expected(which is good). But only to find there is a explicit statement saying,

So that group level processing can be executed correctly, the following rules should be noted:

*After LOOP there should be no limiting condition cond specified.

Would you guys help explain why using "limiting condition of LOOP" will mess up with group level processing?

Thanks you so much in advance.

Kevin:)

"The statement block of a LOOP loop can contain control structures for control level processing. The respective control statement is AT. The statements AT and ENDAT define statement blocks that are executed at control breaks. Within these statement blocks, the statement SUM can be specified to total numeric components of a group level. In the case of output behavior result, the same applies as for LOOP AT.

So that group level processing can be executed correctly, the following rules should be noted:

*After LOOP there should be no limiting condition cond specified.

*The internal table must not be modified within the LOOP loop.

*The work area wa specified in the LOOP statement after the INTO addition must be compatible with the line type of the table.

*The content of a work area wa specified in the LOOP statement after the INTO addition must not be modified. "