SAP code:
*&---------------------------------------------------------------------*
*& Report ZIDA_PROGRAM
*&---------------------------------------------------------------------*
REPORT zida_program.
DATA: lv_carrid TYPE sflight-carrid.
SELECT-OPTIONS: s_carrid FOR lv_carrid.
PARAMETERS: p_connid TYPE sflight-connid.
CLASS lcl_ida_program DEFINITION.
PUBLIC SECTION.
METHODS display_cds_data.
PROTECTED SECTION.
METHODS set_selection EXPORTING et_selection TYPE if_salv_service_types=>yt_named_ranges.
ENDCLASS.
CLASS lcl_ida_program IMPLEMENTATION.
METHOD display_cds_data.
*&... Get the reference of IDA ALV Object
TRY.
DATA(lo_alv_ida_cds) = cl_salv_gui_table_ida=>create_for_cds_view( iv_cds_view_name = 'DEMO_SFLIGHT' ).
CATCH cx_salv_db_connection INTO FINAL(lx_salv_db_connection).
CATCH cx_salv_db_table_not_supported INTO FINAL(lx_salv_not_supported).
CATCH cx_salv_ida_contract_violation INTO DATA(lx_salv_cont_violation).
CATCH cx_salv_function_not_supported INTO FINAL(lx_salv_fun_not_supported).
ENDTRY.
IF lo_alv_ida_cds IS BOUND.
*&... Set filter records using Parameter
DATA(lo_cond_factory) = lo_alv_ida_cds->condition_factory( ).
IF lo_cond_factory IS BOUND.
TRY.
DATA(lo_condition) = lo_cond_factory->equals( name = 'CONNID' "Same Field name as mansion in CDS Field name
value = p_connid ).
CATCH cx_salv_ida_unknown_name INTO DATA(lx_unknown_name).
ENDTRY.
*&... Get the select-option Filtering condition
set_selection( IMPORTING et_selection = FINAL(lt_selection) ).
*&.... Set Parameter and Select-option filtration
TRY.
lo_alv_ida_cds->set_select_options( it_ranges = lt_selection
io_condition = lo_condition ).
CATCH cx_salv_ida_associate_invalid INTO FINAL(lx_associate_invalid).
CATCH cx_salv_db_connection INTO FINAL(lx_db_connection).
CATCH cx_salv_ida_condition_invalid INTO FINAL(lx_condition_invalid).
CATCH cx_salv_ida_unknown_name INTO lx_unknown_name.
ENDTRY.
ENDIF.
*&... Get the reference of ALV Full Screen mode
TRY.
DATA(lo_fullscreen_cds) = lo_alv_ida_cds->fullscreen( ).
CATCH cx_salv_ida_contract_violation INTO lx_salv_cont_violation. " IDA API contract violated by caller
ENDTRY.
*&... Display data on UI
IF lo_alv_ida_cds IS BOUND.
lo_fullscreen_cds->display( ).
ENDIF.
ENDIF.
ENDMETHOD.
METHOD set_selection.
*&... Create Reference for range table
DATA(lo_select) = NEW cl_salv_range_tab_collector( ).
IF lo_select IS BOUND.
lo_select->add_ranges_for_name( iv_name = 'CARRID' "CDS Field name (always fill in capital letter)
it_ranges = s_carrid[] ).
lo_select->get_collected_ranges( IMPORTING et_named_ranges = et_selection ).
ENDIF.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA(lo_ida_class) = NEW lcl_ida_program( ).
lo_ida_class->display_cds_data( ).
Output:
Key Concept: