分享

删除内表重复行.

 细想生活 2014-12-15
DELETE ADJACENT DUPLICATE ENTRIES FROM [COMPARING ].
系统从内表 中删除所有 邻近重复条 目。
完成以下比 较标准之后 ,条目就会 重复:
   如果没有 COMPARING 选项,则标 准关键字段 的内容必须 相同(参见 内表关键字)。
   如果有 COMPARING 选项
.... COMPARING ... ,
指定字段 ... 的内容必须 相同。也可 以通过写入() 代替 在运行时在 括号中指定 字段名。字 段 包含排序关 键字段的名 称。如果 在运行时为 空,则系统 将其忽略。 如果包含无 效的组件名 ,则会发生 实时错误。
   如果有 COMPARING 选项
.... COMPARING ALL FIELDS ,
所有字段的 内容必须相 同。
因此可以先将内表进行排序,然后删除相邻重复行,实现对重复数据的删除。
 REPORT  ZRTCTEST.
types: begin of str,
  col1 type i,
  col2 type i,
  col3 type i,
end of str.
data: wa1 type standard table of str with header line,
      wa2 type standard table of str with header line.
do 3 times.
  wa1-col1 = sy-index.
  wa1-col2 = sy-index * 2.
  wa1-col3 = sy-index ** 2.
  append wa1.
enddo.
do 3 times.
  wa1-col1 = sy-index.
  wa1-col2 = sy-index * 2.
  wa1-col3 = sy-index ** 2.
  append wa1.
enddo.
loop at wa1.
  write:/ wa1-col1, wa1-col2, wa1-col3.
endloop.
skip.
sort wa1 by col1 ascending.
DELETE ADJACENT DUPLICATES FROM wa1 COMPARING ALL FIELDS.
loop at wa1.
  write:/ wa1-col1, wa1-col2, wa1-col3.
endloop.
skip.
uline.
append lines of wa1 to wa2.
loop at wa2.
  write:/ wa2-col1, wa2-col2, wa2-col3.
endloop.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多