欢迎来到萧静默的博客

书山有路勤为径,学海无涯苦作舟。

LOOP AT GROUP语法熟悉

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

posted @ 2019-04-18 09:24  萧静默  阅读(736)  评论(0编辑  收藏  举报