cancel
Showing results for 
Search instead for 
Did you mean: 

Enable/Disable custom button on Lead Selection of ALV

Former Member
0 Kudos

Hi Experts,

I have a requrirement where I have made custom Buttons in ALV . By Default the buttons are set disabled and I want to enable buttons on Lead Selection of ALV.

I have used this code in WD Donit to make custom button and by default set it disable :

data:lr_function type ref to cl_salv_wd_function,

lr_toggle_button type ref to cl_salv_wd_fe_button.

lr_function = l_value->if_salv_wd_function_settings~create_function(

id = 'S' ).

create object lr_toggle_button.

lr_toggle_button->set_text( 'SAVE' ).

lr_toggle_button->SET_ENABLED( abap_false ).

lr_function->set_editor( value = lr_toggle_button ).

How to make this custom button enable only on Lead Selection ?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI,

Try to save this button reference global to view's attributes ie under ATTRIBUTES tab.

Now implement the LEADSEELCTION event for ALV, when you change the lead selection this gets triggered right..

Then using this refrernce you can enable/disable it using that class method.

create object lr_toggle_button.

wd_this->gr_button = lr_toggle_button.

lr_toggle_button->set_text( 'SAVE' ).

lr_toggle_button->SET_ENABLED( abap_false ).

lr_function->set_editor( value = lr_toggle_button ).

In lead selection event of ALV,

wd_this->gr_button->set_enabled( abap_true).

This will work.

Edited by: Lekha on Nov 24, 2009 3:52 PM

Former Member
0 Kudos

Hi Lekha,

I was also thinking on similar line but is this an appropriate method to do like this.

Any other Alternative on this ?

Former Member
0 Kudos

Hi,

Check out the cl_salv_wd_config_table to get the function implemented using the IF_SALV_WD_FUNCTION_SETTINGS~GET_FUNCTIONS so that it retuns the custom functions on ALV whichn inturn gets the

GET_EDITOR of CL_SALV_WD_FUNCTION.

Hope this way you can explore things.....

I guess storing it global would be fine...

Regards,

Lekha.

Former Member
0 Kudos

Thanks Lekha.

It worked with this :

data:lr_function type ref to cl_salv_wd_function .

data lr_button type ref to cl_salv_wd_fe.

data lr_button1 type ref to cl_salv_wd_fe_button.

lr_function = l_value->if_salv_wd_function_settings~get_function(

id = 'S' ).

lr_button = lr_function->get_editor( ).

lr_button1 ?= lr_button .

lr_button1->set_enabled( abap_true ).

Answers (1)

Answers (1)

Former Member
0 Kudos

Done.