Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

@AbapCatalog.

sqlViewName: 'ZCDSIDEOPEN'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'open invocies'
define view zcds_ide_open_inv as select from snwd_so_inv_item as item
association [1] to snwd_so_inv_head as _Header
on item.parent_key = _Header.node_key {
//item
node_key as ItemId,
parent_key as SOId,
quantity as Qty,
quantity_unit as QUnit,
gross_amount as GrossAmount,
currency_code as CurrencyCode,
product_guid as ProductId,
_Header.buyer_guid as BuyerId
} where _Header.payment_status = ''

@AbapCatalog.sqlViewName: 'ZCDSIDACOINV'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Join with Master tables'
define view ZCDS_IDA_CO_MASTER as select from zcds_ide_open_inv as invoices
association [1] to ZAUG_I_BUPA as _BusinessPartner
on invoices.BuyerId = _BusinessPartner.node_key {
//invoices
key ItemId,
key SOId,
_BusinessPartner.company_name,
_BusinessPartner.bp_id as BPNo,
Qty,
QUnit,
GrossAmount,
CurrencyCode,
ProductId,
BuyerId
/* Associations */
//ZAUG_I_BUPA

*&---------------------------------------------------------------------*
*& Report zconsume_cds_via_ida_alv
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
report zconsume_cds_via_ida_alv.

tables: snwd_bp.
*select-options : s_bupa for snwd_bp-bp_id.

data(lo_alv) = cl_salv_gui_table_ida=>create_for_cds_view(
exporting
iv_cds_view_name = 'ZCDS_IDA_CO_MASTER'
).

*Field Catalog: Hide certain Columns


lo_alv->field_catalog( )->get_all_fields(
importing
ets_field_names = data(lt_fieldcat)
).

delete lt_fieldcat where table_line cp '*ID'.

lo_alv->field_catalog( )->set_available_fields( its_field_names = lt_fieldcat ).

*Selections can be considered at runtime with code-push-down


*data(lo_collector) = new cl_salv_range_tab_collector( ).
*lo_collector->add_ranges_for_name(
* exporting
* iv_name = 'BPNO'
* it_ranges = s_bupa[]
*).
*lo_collector->get_collected_ranges(
* importing
* et_named_ranges = data(lt_selections)
*).
*lo_alv->set_select_options(
* exporting
* it_ranges = lt_selections
** io_condition =
*).

*Change the column label


lo_alv->field_catalog( )->set_field_header_texts(
exporting
iv_field_name = 'BPNO'
iv_header_text = 'Anubhav BP'
iv_tooltip_text = 'Business Partner No'
).

*Hide standard Function


lo_alv->field_catalog( )->disable_aggregation( iv_field_name = 'QTY' ).
lo_alv->field_catalog( )->disable_sort( iv_field_name = 'GROSSAMOUNT' ).

*Killer features
lo_alv->display_options( )->set_title( iv_title = 'Anubhav demo on ALV with IDA' ).
lo_alv->display_options( )->enable_alternating_row_pattern( ).

*Hide standard function


lo_alv->toolbar( )->set_visibility_std_functions(
* exporting
* iv_details = ABAP_UNDEFINED
* iv_sort = ABAP_UNDEFINED
* iv_group = ABAP_UNDEFINED
iv_filter = ABAP_false
* iv_aggregation = ABAP_UNDEFINED
* iv_print = ABAP_UNDEFINED
* iv_export = ABAP_UNDEFINED
* iv_settings_dialog = ABAP_UNDEFINED
).

*Allow row selection


lo_alv->selection( )->set_selection_mode(
iv_mode = if_salv_gui_selection_ida=>cs_selection_mode-single
).
*custom logic with selection, custom button in toolbar
lo_alv->toolbar( )->add_button(
exporting
iv_fcode = 'DETAIL_SCREEN'
iv_icon = 'ICON_MESSAGE_INFORMATION' " Name of an
Icon
* iv_is_disabled =
iv_text = 'Details'
* iv_quickinfo =
* iv_is_checked =
* iv_before_standard_functions = ABAP_FALSE
).

perform set_event_handler.

lo_alv->add_authorization_for_object(
exporting
iv_authorization_object = 'ZBUPA_ID'
it_activities = value #( ( auth_field = 'ACTVT' value = '03' )
)
it_field_mapping = value #( ( auth_field = 'BUPA_ID' VIEW_FIELD =
'BPNO' ) )
).
* catch cx_salv_function_not_supported. "

lo_alv->fullscreen( )->display( ).

class lcl_event_handler definition create private.


public section.
class-methods toolbar_selected for event function_selected of
if_salv_gui_toolbar_ida importing ev_fcode.

endclass.
class lcl_event_handler implementation.
method toolbar_selected.
data: ls_row type ZCDS_IDA_CO_MASTER.
case ev_fcode.
when 'DETAIL_SCREEN'.
if lo_alv->selection( )->is_row_selected( ) = abap_true.
lo_alv->selection( )->get_selected_row(
importing
es_row = ls_row
).
cl_salv_ida_show_data_row=>display(
exporting
* iv_text =
is_data = ls_row
).
endif.
endcase.
endmethod.
endclass.

form set_event_handler.

set handler lcl_event_handler=>toolbar_selected for lo_alv->toolbar( ).


endform.

You might also like