SAP classes CL_SALV_IDA_* and SAP programs SALV_IDA_* as of 7.5 SP03. With all this functionality provided by SAP, HANA / CDS is powerful development tool saving time and making possible the code pushdown to HANA database.
Create CDS view from ADT using folder Core Data Services, right-click to create New -> DDL Source
Create program (full source code below) which leverages standard SAP classes CL_SALV_*IDA*
Create CDS view from ADT using folder Core Data Services, right-click to create New -> DDL Source
Create program (full source code below) which leverages standard SAP classes CL_SALV_*IDA*
From SE80, right-click program, click “Create GUI Status” called STATUS (see line 84)
See selection criteria made possible by SAP class CL_SALV_IDA_QUERY_ENGINE
See selection limitation made possible by SAP class CL_SALV_GUI_GRID_MODEL_IDA
CDS view on HANA DB quickly displays records according to selection criteria, in less than 1 second, including the custom ABAP CDS annotations.
REPORT z_fi_header_cds_alv_select.
DATA: go_alv_gui_table_ida TYPE REF TO if_salv_gui_table_ida ##NEEDED.
TABLES: bkpf.
SELECT-OPTIONS: s_belnr FOR bkpf-belnr,
s_bukrs FOR bkpf-bukrs,
s_gjahr FOR bkpf-gjahr,
s_budat FOR bkpf-budat.
PARAMETERS: p_limit TYPE syst_tabix DEFAULT 2000000.
CLASS lcl_salv_cds DEFINITION ##CLASS_FINAL.
PUBLIC SECTION.
CLASS-METHODS:
display,
status_function_selected
FOR EVENT function_selected OF if_salv_gui_fullscreen_ida
IMPORTING ev_fcode.
PRIVATE SECTION.
ENDCLASS. "lcl_salv_alv DEFINITION
CLASS lcl_salv_cds IMPLEMENTATION.
METHOD display.
DATA: lt_excluding_fcode TYPE if_salv_gui_types_ida=>yt_excluding_fcode.
DATA: lt_ranges TYPE if_salv_service_types=>yt_named_ranges.
FIELD-SYMBOLS: <fs_r> LIKE LINE OF lt_ranges.
FIELD-SYMBOLS: <fs_s> LIKE LINE OF s_belnr,
<fs_bukrs> LIKE LINE OF s_bukrs,
<fs_gjahr> LIKE LINE OF s_gjahr,
<fs_budat> LIKE LINE OF s_budat.
cl_salv_ida_services=>create_entity_and_abqi(
EXPORTING iv_entity_id = CONV #( 'Z_FI_HEADER2' )
iv_entity_type = 'CDS'
IMPORTING eo_entity = DATA(lo_entity)
eo_fetch = DATA(lo_fetch) ).
DATA(lo_ida_structdescr) = cl_salv_ida_structdescr=>create_for_sadl_entity( io_entity = lo_entity ).
cl_salv_ida_text_search_prov=>get_search_attributes( EXPORTING io_salv_ida_structdescr = lo_ida_structdescr
IMPORTING ets_search_attribute = DATA(lt_search_attribute) ).
DATA(lo_sti_text_search) = cl_salv_ida_text_search_prov=>create_4_sti( lt_search_attribute ).
DATA(lo_sadl_entity) = lo_ida_structdescr->get_sadl_entity( ).
DATA(lo_text_search) = cl_salv_ida_text_search_prov=>create_4_ida_api( lo_ida_structdescr ).
DATA(lo_query_engine) = NEW cl_salv_ida_query_engine( io_sadl_entity = lo_sadl_entity
io_sadl_fetch = lo_fetch
io_salv_ida_text_search = lo_text_search ).
DATA(lo_idas) = cl_salv_ida_services=>create( io_structdescr_prov = lo_ida_structdescr
io_sti_text_search_prov = lo_sti_text_search
io_query_engine = lo_query_engine ).
* begin Z_FI_HEADER_CDS_ALV_SELECT selection screen data to CL_SALV_IDA_QUERY_ENGINE range table
REFRESH: lt_ranges.
LOOP AT s_belnr ASSIGNING <fs_s>.
APPEND INITIAL LINE TO lt_ranges ASSIGNING <fs_r>.
MOVE-CORRESPONDING <fs_s> TO <fs_r>. <fs_r>-name = 'BELNR'.
ENDLOOP.
LOOP AT s_bukrs ASSIGNING <fs_bukrs>.
APPEND INITIAL LINE TO lt_ranges ASSIGNING <fs_r>.
MOVE-CORRESPONDING <fs_bukrs> TO <fs_r>. <fs_r>-name = 'BUKRS'.
ENDLOOP.
LOOP AT s_gjahr ASSIGNING <fs_gjahr>.
APPEND INITIAL LINE TO lt_ranges ASSIGNING <fs_r>.
MOVE-CORRESPONDING <fs_gjahr> TO <fs_r>. <fs_r>-name = 'GJAHR'.
ENDLOOP.
LOOP AT s_budat ASSIGNING <fs_budat>.
APPEND INITIAL LINE TO lt_ranges ASSIGNING <fs_r>.
MOVE-CORRESPONDING <fs_budat> TO <fs_r>. <fs_r>-name = 'BUDAT'.
ENDLOOP.
lo_idas->get_query_engine( )->set_selection_range_tab( it_ranges = lt_ranges ).
* end Z_FI_HEADER_CDS_ALV_SELECT selection screen data to CL_SALV_IDA_QUERY_ENGINE range table
DATA(lo_observer_manager) = cl_salv_gui_observer_manager=>create_observer_manager( ).
DATA(lo_user_action) = NEW cl_salv_gui_user_action( ).
DATA(lo_standard_functions) = NEW cl_salv_gui_std_functions_ida( ).
DATA(lo_field_catalog) = NEW cl_salv_gui_field_catalog_ida( io_structdescr_provider = lo_ida_structdescr ).
DATA(lo_layout) = NEW cl_salv_gui_layout_ida( io_standard_functions = lo_standard_functions
io_text_search = lo_sti_text_search
io_field_catalog = lo_field_catalog ).
DATA(lo_model_ida) = NEW cl_salv_gui_grid_model_ida( io_idas = lo_idas
io_field_catalog = lo_field_catalog
io_layout = lo_layout
io_user_action = lo_user_action ).
* begin set selection limitation
lo_model_ida->if_salv_gui_table_ida~set_maximum_number_of_rows( iv_number_of_rows = p_limit ).
* begin set selection limitation
go_alv_gui_table_ida = cl_salv_gui_grid_controler_ida=>create_for_fullscreen(
EXPORTING io_user_action = lo_user_action
io_gui_grid_model = lo_model_ida
io_observer_manager = lo_observer_manager ).
go_alv_gui_table_ida->fullscreen( )->set_pf_status(
iv_pf_status_name = 'STATUS'
iv_program_name = sy-repid
it_excluding_fcode = lt_excluding_fcode ).
SET HANDLER status_function_selected FOR go_alv_gui_table_ida->fullscreen( ).
go_alv_gui_table_ida->fullscreen( )->display( ).
ENDMETHOD.
METHOD status_function_selected.
CASE ev_fcode.
WHEN OTHERS.
go_alv_gui_table_ida->fullscreen( )->exit( ).
ENDCASE.
ENDMETHOD.
ENDCLASS. "lcl_salv_cds IMPLEMENTATION
END-OF-SELECTION.
CALL METHOD lcl_salv_cds=>display.
No comments:
Post a Comment