Group by example
CLASS lcl_class_name DEFINITION CREATE PRIVATE FINAL.
PUBLIC SECTION. CLASS-METHODS: create RETURNING VALUE(ro_obj) TYPE REF TO lcl_class_name. METHODS: run. PROTECTED SECTION. PRIVATE SECTION. ENDCLASS. CLASS lcl_class_name IMPLEMENTATION. METHOD create. ro_obj = NEW lcl_class_name( ). ENDMETHOD. METHOD run. SELECT * FROM spfli INTO TABLE @DATA(lt_spfli). DATA members LIKE lt_spfli. LOOP AT lt_spfli INTO DATA(ls_spfli) GROUP BY ( carrier = ls_spfli-carrid city_from = ls_spfli-cityfrom ) ASCENDING ASSIGNING FIELD-SYMBOL(<lfs_group>). CLEAR members. LOOP AT GROUP <lfs_group> ASSIGNING FIELD-SYMBOL(<lfs_spfli_group>). members = VALUE #( BASE members ( <lfs_spfli_group> ) ). ENDLOOP. cl_demo_output=>write( members ). ENDLOOP. cl_demo_output=>display( ). ENDMETHOD. ENDCLASS.
********************************ROHINI KUMAR*********************************Please support my work : sap.rohini988@gmail.comLinkedIn Link : https://www.linkedin.com/in/rohini-kumar-14647a13a/********************************************************************************
Comments
Post a Comment