一、代码如下
二、效果如下
*&---------------------------------------------------------------------* *& Report Z_TIANPAN_20190717_HELLO *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* REPORT z_tianpan_20190717_hello. DATA : BEGIN OF m_table, key TYPE string, "关键字段,用于用这列来统计V1、V2值(关键字段可多个) v1 TYPE i, v2 TYPE i, END OF m_table. DATA : t_data LIKE m_table OCCURS 0 WITH HEADER LINE . "定义数据内表 DO 8 TIMES . IF sy-index < 3 . t_data-key = 'A' . t_data-v1 = sy-index . t_data-v2 = sy-index + 1 . ELSEIF sy-index < 6 . t_data-key = 'B' . t_data-v1 = sy-index . t_data-v2 = sy-index - 1 . ELSE . t_data-key = 'C' . t_data-v1 = sy-index - 1 . t_data-v2 = sy-index - 2 . ENDIF . APPEND t_data. ENDDO . *按条件删除 DELETE t_data WHERE key = 'C' . *按序号删除 DELETE t_data[] INDEX 3. *删除多行 DELETE t_data[] FROM 2 TO 4. *删除重复数据 DELETE ADJACENT DUPLICATES FROM t_data. WRITE : 't_data内表数据:' . LOOP AT t_data. WRITE : / ' ' ,t_data-key ,t_data-v1, t_data-v2. ENDLOOP . WRITE : sy-uline . * 字符串拼接 WRITE: / '青青子衿' & '悠悠我心'. BREAK-POINT.