SAP ABAP collect 函数

 

如下代码,


typesbegin of ty_aa,
  ebeln type eket-ebeln ,  "采购凭证
*  ebelp type eket-ebelp ,  "项目
  wemng type eket-wemng "已交货数量
  end of ty_aa.

data: gt_aa type table of ty_aa with header line,
      gs_aa type ty_aa.

data: gt_collect type table of ty_aa with header line,
      gs_collect type ty_aa.

gs_aa-ebeln '0045282828'.
gs_aa-wemng '100'.
APPEND gs_aa to gt_aa.

gs_aa-ebeln '0045282828'.
gs_aa-wemng '100'.
APPEND gs_aa to gt_aa.


gs_aa-ebeln '0045282828'.
gs_aa-wemng '100'.
APPEND gs_aa to gt_aa.

SORt gt_aa by ebeln.


CLEAR gt_collect.
  loop at gt_aa into gs_aa.
    move-corresponding gs_aa to gs_collect.
    collect gs_collect into gt_collect.
    clear gs_collect.
    clear gs_aa.
  endloop.

效果如下:

 

posted @ 2025-02-10 16:36  轻烟随风  阅读(59)  评论(0)    收藏  举报