【ABAP内表】关于At first/ At last/ At new /At end of
在ABAP开发中,各种方式的操纵内表是最最基本。我们经常会用到:将内表置于一个loop循环里去一条一条的读、写内表record。本文只是一个小总结或小操作,叙述在loop时对内表的几个控制。测试代码.
loop at td_table1 into th_table1.
at first.
write:/ ‘AT First’.
write:/ sy-tabix.
write:/ th_table1-MATNR,
th_table1-SPRAS.
endat.
at new matnr.
write:/ ‘at new matnr’.
write:/ sy-tabix.
write:/ th_table1-MATNR,
th_table1-SPRAS.
endat.
at end of matnr.
write:/ ‘at end of matnr’.
write:/ sy-tabix.
write:/ th_table1-MATNR,
th_table1-SPRAS.
endat.
at last.
write:/ ‘at last’.
write:/ sy-tabix.
write:/ th_table1-MATNR,
th_table1-SPRAS.
endat.
endloop.
write:/ ‘OK’.
使用测试数据:
测试结果
测试小结At first :仅内表的第一行.
AT last:仅内表的最后一行.
AT new <field>:以该field为标记,加上前面的字段,如果是新的记录,则进行;
AT end of <field>:以该field为标记,加上前面的字段,如果它的下一行是新的记录,则进行.
http://scnblogs.techweb.com.cn/tcsapbw/archives/386.html