*&---------------------------------------------------------------------* *& Include ZINC_DB_PROCEDURE *&---------------------------------------------------------------------* FORM db_procedure. DATA lv_where_clause TYPE zif_zdp_order_aggregated=>where_clause. DATA t_aggregated TYPE TABLE OF zif_zdp_order_aggregated=>out_aggr_soldto. DATA ls_aggregated TYPE zif_zdp_order_aggregated=>out_aggr_soldto. DATA t_details TYPE TABLE OF zif_zdp_order_aggregated=>out_details. *--- Build the "WHERE" clause for the selection criteria p_date DATA(lv_sel_tab) = cl_lib_seltab=>new( it_sel = p_date[] ). DATA(lv_where_clause_string) = lv_sel_tab->sql_where_condition( iv_field = 'POSTING_DATE' ). lv_where_clause = lv_where_clause_string. *--- Call the DB Procedure Proxy and pass the "WHERE" clause as the input parameter CALL DATABASE PROCEDURE zdp_order_aggregated EXPORTING where_clause = lv_where_clause IMPORTING out_details = t_details out_details_alv = t_details_alv out_aggr_soldto = t_aggregated. ASSIGN t_details_alv TO . *--- Sort and read the Sold-To with highest sales SORT t_aggregated BY net_value_man DESCENDING. READ TABLE t_aggregated INTO ls_aggregated INDEX 1. gs_aggregated-net_value_man = ls_aggregated-net_value_man. gs_aggregated-name = ls_aggregated-name. ENDFORM.