SAP ABAP获取内表中发生重复的值
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
"判断description 重复 TYPES: ty_dup_out TYPE STANDARD TABLE OF ztslm_order_head WITH EMPTY KEY. DATA lt_dup_out TYPE ty_dup_out. LOOP AT gt_out ASSIGNING FIELD-SYMBOL(<ls_out>) GROUP BY ( description = <ls_out>-description size = GROUP SIZE ) REFERENCE INTO DATA(lt_group_ref) . IF lt_group_ref->*-size > 1. LOOP AT GROUP lt_group_ref ASSIGNING FIELD-SYMBOL(<ls_ref>). lt_dup_out = VALUE ty_dup_out( BASE lt_dup_out ( description = <ls_ref>-description ) ). EXIT. ENDLOOP. ENDIF. ENDLOOP. "lt_dup_out 中是重复的描述 SORT lt_dup_out BY description. LOOP AT gt_out ASSIGNING FIELD-SYMBOL(<fs_outx>). READ TABLE lt_dup_out TRANSPORTING NO FIELDS WITH KEY description = <fs_outx>-description BINARY SEARCH. IF sy-subrc <> 0. DELETE gt_out. ENDIF. ENDLOOP. SORT GT_out by description. |
利用sap标准语法,在loop 中使用group 的条件,获取重复项
LOOP AT lt_mqs ASSIGNING FIELD-SYMBOL(
GROUP BY ( z08body =
这里只是计数,根据 size 大于1 ,可以判断当前group 是含重复值
利用loop group 可以得到相关重复的值