Display CDS Data with restrictions
Step – 1 Data Declarations and Selection Screen
Step 2 – Create ALV IDA for CDS View
Step 3 – Create IDA Ranges for Select Options and Selection Parameters
Step 4 – Set CDS View Parameters
Step 5 – Get Reference of Full-screen API
Step 6 – Display
Output
Selection Screen
Execution result
Displaying ALV IDA in Custom Container
Refer Demo Program SALV_IDA_DISPLAY_DATA by SAP
ALV IDA Display Options, Event Handling
Refer Demo Programs by SAP
– SALV_IDA_DISPLAY_OPTIONS
– SALV_IDA_DISPLAY_OPTIONS_FS
Useful Links
Sample Code
*&---------------------------------------------------------------------*
*& Report Z2812_CDS_RESTRICTION
*&---------------------------------------------------------------------*
REPORT z2812_cds_restriction.
DATA: gv_sdate TYPE sbook-order_date.
PARAMETERS: p_aircod TYPE sbook-carrid,
p_fldat TYPE sbook-fldate,
p_connid TYPE sbook-connid.
SELECT-OPTIONS: s_bdate FOR gv_sdate.
DATA: go_alv_ida TYPE REF TO if_salv_gui_table_ida,
go_fullscreen TYPE REF TO if_salv_gui_fullscreen_ida,
go_range TYPE REF TO cl_salv_range_tab_collector,
gr_connid TYPE RANGE OF sbook-connid.
START-OF-SELECTION.
TRY.
" Create 'ALV with IDA' for Core Data Services(CDS)
go_alv_ida = cl_salv_gui_table_ida=>create_for_cds_view(
iv_cds_view_name = 'Z2812_CUSTBOOK_PARAMETER'
).
" Create Instance of Range Collector
go_range = NEW #( ).
" Add Ranges for Field( Booking Date - Select-Optiion )
go_range->add_ranges_for_name(
EXPORTING
iv_name = 'ORDER_DATE'
it_ranges = s_bdate[] ).
" Add Ranges for Field( Connection ID - Slection Parameter )
gr_connid = VALUE #( ( sign = 'I' option = 'EQ' low = p_connid ) ).
go_range->add_ranges_for_name(
EXPORTING
iv_name = 'CONNID'
it_ranges = gr_connid[]
).
" Get All Ranges
go_range->get_collected_ranges(
IMPORTING
et_named_ranges = DATA(lt_named_ranges) ).
" Set Select Options for IDA
go_alv_ida->set_select_options(
EXPORTING
it_ranges = lt_named_ranges
).
" Set View Parameters ( Defined in CDS View )
go_alv_ida->set_view_parameters(
it_parameters = VALUE #(
( name = 'P_CARRID' value = p_aircod )
( name = 'P_FLIGHTBEFOREDATE' value = p_fldat )
)
).
CATCH cx_root INTO DATA(lo_root).
DATA(lv_text) = lo_root->get_text( ).
WRITE:/ lv_text.
LEAVE TO LIST-PROCESSING.
ENDTRY.
END-OF-SELECTION.
TRY.
" Activate Fullscreen modus (interface)
go_fullscreen = go_alv_ida->fullscreen( ).
CATCH cx_salv_ida_contract_violation INTO DATA(lo_error).
lv_text = lo_error->get_text( ).
WRITE:/ lv_text.
LEAVE TO LIST-PROCESSING.
ENDTRY.
" Display Data
go_fullscreen->display( ).