SAP Technical

ABAP新语法之LOOP GROUP BY

2018-11-22  本文已影响153人  df6e4e8a0635

更多内容请关注公众号:SAP Technical

TYPES:

  BEGIN OF ty_customer,

    customer TYPE char10,

    NAME    TYPE char30,

    city    TYPE char30,

    route    TYPE char10,

  END  OF ty_customer.

TYPES: tt_customers TYPE SORTED TABLE OF ty_customer

          WITH UNIQUE KEY customer.

TYPES: tt_citys TYPE STANDARD TABLE OF char30 WITH EMPTY KEY.

DATA(t_customres) =

VALUE tt_customers(

  ( customer = 'C0001' NAME = 'Test Customer 1' city = 'NY' route = 'R0001' )

  ( customer = 'C0002' NAME = 'Customer 2'      city = 'LA' route = 'R0003' )

  ( customer = 'C0003' NAME = 'Good Customer 3' city = 'DFW' route = 'R0001' )

  ( customer = 'C0004' NAME = 'Best Customer 4' city = 'CH' route = 'R0003' )

  ( customer = 'C0005' NAME = 'So So Customer 5' city = 'NY' route = 'R0001' )

).

* Simply get the unique Routes, use WITHOUT MEMBERS

LOOP AT t_customres INTO DATA(ls_cust_2)

    GROUP BY  ( route = ls_cust_2-route )

      ASCENDING

      WITHOUT MEMBERS

      REFERENCE INTO DATA(route_group_2).

  WRITE: / route_group_2->route.

ENDLOOP.

上一篇下一篇

猜你喜欢

热点阅读