ABAP Web Dynpro – ALV Table Button

Home / SAP / ABAP Coding / ABAP Web Dynpro – ALV Table Button

Well, after my last post, I realized, this is cool.  Now it’s time to make it better.  So the first objective is to add an ALV table button for refresh.  It turns out, it’s pretty easy to accomplish this.  Here’s what you need to do.

So, go into your WDDOINIT and add the following code (or some variation).

*** initial ALV table
data lo_cmp_usage type ref to if_wd_component_usage.
DATA lo_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
DATA lv_value TYPE ref to cl_salv_wd_config_table.
DATA: lr_btui_refresh TYPE REF TO cl_salv_wd_fe_button.
DATA: lr_bt_refresh TYPE REF TO cl_salv_wd_function.

*** instantiate the component
lo_cmp_usage =   wd_this->wd_cpuse_alv_comp( ).
if lo_cmp_usage->has_active_component( ) is initial.
lo_cmp_usage->create_component( ).
endif.
lo_INTERFACECONTROLLER =   wd_this->wd_cpifc_alv_comp( ).
*** get the ALV table
lv_value = lo_interfacecontroller->get_model( ).
*** create the button object
create OBJECT lr_btui_refresh.
*** set icon
lr_btui_refresh->set_image_source( ‘ICON_REFRESH’ ).
lr_bt_refresh = lv_value->if_salv_wd_function_settings~create_function( ID = ‘BT_REFRESH’ ).
lr_bt_refresh->set_editor( lr_btui_refresh ).

Now you can also add text to the button instead of just the image source.  If you drill into the cl_salv_wd_fe_button class to see the methods available.

I’ll have more tomorrow as I keep learning.  Thanks for reading,

As always, thanks for reading and don't forget to check out our SAP Service Management Products at my other company JaveLLin Solutions,
Mike

Leave a Reply

Your email address will not be published. Required fields are marked *