按客户组,开票凭证和物料组将内部表分组

时间:2018-08-13 08:04:19

标签: sap abap

嗨,专家们。我只想问一下您在ABAP中如何解决此问题的逻辑。我只是ABAP的新手,我需要此作为我的报告的要求。 ``例如,我有一个由ff结构组成的内部表。

 SO   Customer  Materialno  Materialgroup2  Liters
 001  James     1           GroupA          5
 001  James     2           GroupA          10
 001  James     3           GroupB          20
 002  John      2           GroupA          10
 002  John      3           GroupA          10
 002  John      4           GroupB          20
 002  John      5           GroupB          5

我需要按客户,开票凭证及其物料组2添加它。现在内部表的最终输出应该是这样的。

SO   Customer  MaterialGroup2  Liters
001  James     GroupA          15
001  James     GroupB          20
002  John      GroupA          20
002  John      GroupB          25

2 个答案:

答案 0 :(得分:2)

rt_result = VALUE #( FOR GROUPS group OF ls_source IN it_source
                     GROUP BY ( so             = ls_source-so
                                customer       = ls_source-customer
                                material_group = ls_source-material_group )
                     ( so             = group-so
                       customer       = group-customer
                       material_group = group-material_group
                       liters         = REDUCE #( INIT lv_liters = 0
                                                  FOR ls_member IN GROUP group
                                                  NEXT lv_liters = lv_liters + ls_member-liters ) ) ).

答案 1 :(得分:1)

RuntimeError: Graph is finalized and cannot be modified.