对at end of 的认识
at end of 要用在LOOP 里面
他是在同一个变量发生变化是运行 at end of. ... endat.里面的内容,解释代码如下:
types: begin of wa, col1 type i, col2 type i, col3 type i, end of wa. data gt type standard table of wa with header line. data sum type standard table of wa with header line. data test type standard table of wa with header line. do 6 times. gt-col1 = sy-index. gt-col2 = sy-index ** 2. gt-col3 = sy-index * 2. append gt. enddo. do 6 times. gt-col1 = sy-index. gt-col2 = sy-index ** 2. gt-col3 = sy-index * 2. append gt. enddo. sort gt by col1 ascending. loop at gt. write:/ gt-col1, gt-col2,gt-col3. endloop. skip.uline.uline. loop at gt where col1 = 1 or col1 = 3. APPEND gt to test. at end of col1. sum."把COL1 这个字段外的其他字段相加 append gt to sum. skip.uline.uline. LOOP AT test. write:/ test-col1, test-col2,test-col3. ENDLOOP. endat. endloop. skip.uline.uline. loop at sum. write:/ sum-col1, sum-col2,sum-col3. endloop.
2、当你要运行期间的内容时,如果要网表里面内容会出现星号** 则要定义表区间赋值,如下:
data: begin of gt_table occurs 0, vbeln type vbeln, posnr type posnr, end of gt_table. *data: gs_tableline like TABLE of gt_table WITH HEADER LINE, data gt_output LIKE TABLE OF gt_table WITH HEADER LINE. data: gs_tableline like line of gt_table. gt_table-vbeln = '00100'. gt_table-posnr = '10'. append gt_table. gt_table-vbeln = '00100'. gt_table-posnr = '20'. append gt_table. gt_table-vbeln = '00200'. gt_table-posnr = '10'. append gt_table. gt_table-vbeln = '00200'. gt_table-posnr = '20'. append gt_table. gt_table-vbeln = '00200'. gt_table-posnr = '30'. append gt_table. sort gt_table by vbeln. loop at gt_table. MOVE gt_table to gs_tableline. at end of vbeln. *这里要用gs_tableline结构, 因为用gt_table全都是星。... gt_output-posnr = gs_tableline-posnr. gt_output-vbeln = gs_tableline-vbeln. append gt_output. endat. endloop. LOOP AT gt_output. WRITE:/ gt_output-vbeln,gt_output-posnr. ENDLOOP.
但只能给最后一行
AT NEW 的用法差不多,,安语义就好