Can't use AT NEW in a loop
Hi Sapfans,
I am newbie to ABAP class. I am trying to use ABAP class to create a simple list. It works fine.
But how can words like - AT NEW, AT END OF, AT END OF .... SUM, .... be use in a LOOP statement?
This is my code:
loop at table_profit_analysis into a_profit_analysis.
AT NEW table_profit_analysis-<a_field>.
NEW-PAGE.
ENDAT.
call method a_profit_analysis->display.
endloop.
Could you give me suggestion?
Thanks
Hi Steve,
when you use an AT statement, you don't specify the table name, just the field.
i.e.
loop at i_mara.
at new matnr.
..
endat.
endloop.
Rgds,
Tim
Thanks for you reply
My internal table is a class(so a table). So just don't know how to use AT NEW and.... as looping a class.
I can use words like AT NEW and when it is a normal internal, but now it is a class. So do you have any other suggestion?
Thanks
Hello,
I don't know about class, but I would like to emphasize that AT NEW ... AT END OF has to be according to the structure of the internal table (this is called a control structure), so that if the table consists of field1, field2, ..field N, then:
loop at itab.
at new field1.
....
endat.
at new field2.
....
endat.
at end of field2.
...
endat.
at end of field1.
.......
endat.
Note how you list at new from 1 to N, and at end of from N to 1.
Best,
isak
before loop, sort internal table.
Never Mind Fans.
Maybe I try to find out the answer myself later.
Thanks for you answer Fans