SELECT * FROM EKKO INTO TABLE @DATA(LT_EKKO) UP TO 100 ROWS. SORT LT_EKKO BY LIFNR ERNAM. LOOP AT LT_EKKO INTO DATA(LS_EKKO) GROUP BY LS_EKKO-LIFNR. "多个分组条件 "LOOP AT LT_EKKO INTO DATA(LS_EKKO) GROUP BY ( LIFNR = LS_EKKO-LIFNR ERNAM = LS_EKKO-ERNAM ). LOOP AT GROUP LS_EKKO INTO DATA(MEMBER). ENDLOOP. ENDLOOP.
按LIFNR分组,LS_EKKO为每一组的第一行LOOP AT LT_EKKO INTO DATA(LS_EKKO) GROUP BY LS_EKKO-LIFNR.
LOOP AT GROUP访问组成员LOOP AT GROUP LS_EKKO INTO DATA(MEMBER).
SELECT * FROM EKKO INTO TABLE @DATA(LT_EKKO) UP TO 100 ROWS. SORT LT_EKKO BY LIFNR ERNAM. LOOP AT LT_EKKO INTO DATA(LS_EKKO) GROUP BY ( KEY1 = LS_EKKO-LIFNR KEY2 = LS_EKKO-ERNAM ) INTO DATA(KEY). LOOP AT GROUP KEY INTO DATA(MEMBER). ENDLOOP. ENDLOOP.
按LIFNR,ERNAM分组,LS_EKKO为空
LOOP AT LT_EKKO INTO DATA(LS_EKKO) GROUP BY ( KEY1 = LS_EKKO-LIFNR KEY2 = LS_EKKO-ERNAM ) INTO DATA(KEY).
LOOP AT GROUP按组的分组条件访问组成员,其中KEY可以理解为工作区,包含lifnr和ername. member里面包含有KEY工作区关键字段.LOOP AT GROUP KEY INTO DATA(MEMBER).
本文转载自:https://www.jianshu.com/p/f34f59ba2c17