Sum under at end of in loop(循环中sum的用法实例)

 

DATA: BEGIN OF line,
         col1(1) TYPE c,
         col2 TYPE i,
         col3 TYPE i,
      END OF line.

DATA itab LIKE HASHED TABLE OF line
          WITH UNIQUE KEY col1 col2.

line-col1 = 'A'.
DO 3 TIMES.
  line-col2 = sy-index.
  line-col3 = sy-index ** 2.
  INSERT line INTO TABLE itab.
ENDDO.

line-col1 = 'B'.
DO 3 TIMES.
  line-col2 = 2 * sy-index.
  line-col3 = ( 2 * sy-index ) ** 2.
  INSERT line INTO TABLE itab.
ENDDO.

SORT itab.

LOOP AT itab INTO line.
  WRITE: / line-col1, line-col2, line-col3.
  AT END OF col1.
    SUM.
    ULINE.
    WRITE: / line-col1, line-col2, line-col3.
    SKIP.
  ENDAT.
  AT LAST.
    SUM.
    ULINE.
    WRITE: / line-col1, line-col2, line-col3.
  ENDAT.
ENDLOOP.

你可能感兴趣的:(c,table,insert)