cancel
Showing results for 
Search instead for 
Did you mean: 

How to create multiple buttons in ALV Toolbar in Webdynpro ABAP

former_member450029
Participant
0 Kudos

Hi all,

I am trying to create multiple buttons in Webdynpro  ALV toolbar, please go through the code.

What happening is, second button is replacing the first one.

DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.

   lo_cmp_usage =   wd_this->wd_cpuse_alv_table( ).

   IF lo_cmp_usage->has_active_component( ) IS INITIAL.

     lo_cmp_usage->create_component( ).

   ENDIF.

   DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .

   lo_interfacecontroller =   wd_this->wd_cpifc_alv_table( ).

    DATA lv_value TYPE REF TO cl_salv_wd_config_table.

   lv_value = lo_interfacecontroller->get_model(

   ).

   DATA lr_buttonui1 TYPE REF TO cl_salv_wd_fe_button.

   DATA lr_buttonui2 TYPE REF TO cl_salv_wd_fe_button.

   DATA button1 TYPE REF TO cl_salv_wd_function.

   DATA button2 TYPE REF TO cl_salv_wd_function.

**First button

   CREATE OBJECT lr_buttonui1.

   lr_buttonui1->set_text('Button')."setting the text of the button on alv toolbar

   button1 = lv_value->if_salv_wd_function_settings~create_function( id = 'BUTTON')."creating the function for alv button

   button1->set_editor( lr_buttonui1 ).

**Second button

   CREATE OBJECT lr_buttonui2.

     lr_buttonui2->set_text('Button1')."setting the text of the button on alv toolbar

   button2 = lv_value->if_salv_wd_function_settings~create_function( id = 'BUTTON' )."creating the function for alv button

   button2->set_editor( lr_buttonui2 ).


How can I overcome this??


Thanks

Eshwar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

What happening is, second button is replacing the first one.

What do you mean by the above statement? Is it both the buttons Button1,Button2 triggering same actions?.

It is because of this.

  button1 = lv_value->if_salv_wd_function_settings~create_function( id = 'BUTTON')."creating the function for alv button

button2 = lv_value->if_salv_wd_function_settings~create_function( id = 'BUTTON' )."creating the function for alv button

For both the buttons, you've given same action id. Try giving different actions then it might solve your issue.

Pls revert for further queries.

Thanks

KH

Answers (3)

Answers (3)

former_member450029
Participant
0 Kudos

Thank y'all

Thanks

Eshwar

ramakrishnappa
Active Contributor
0 Kudos

Hi Eshwar,

Hope you already got the required answers.

As suggested, you need to use unique ids for each button.

Example: btn_print, btn_submit

Regards,

Rama

former_member201227
Active Participant
0 Kudos

Hi Eshwar,

The button Ids are same for both the buttons in your code. You need to change it as BUTTON1, BUTTON2.

**First button

   CREATE OBJECT lr_buttonui1.

   lr_buttonui1->set_text('Button')."setting the text of the button on alv toolbar

   button1 = lv_value->if_salv_wd_function_settings~create_function( id = 'BUTTON1')."creating the function for alv button

   button1->set_editor( lr_buttonui1 ).

**Second button

   CREATE OBJECT lr_buttonui2.

     lr_buttonui2->set_text('Button1')."setting the text of the button on alv toolbar

   button2 = lv_value->if_salv_wd_function_settings~create_function( id = 'BUTTON2' )."creating the function for alv button

   button2->set_editor( lr_buttonui2 ).