cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Button event handling

Former Member
0 Kudos

I have added a custom button on ALV toolbar of my web dynpro view. Now when user click that button, i want to implement the functionality...like onAction...How to do that...where do i need to write the code and how can i capture the button event...

pls suggest

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You can create the button with the following code



lr_user_funcopy =
l_value_comp->if_salv_wd_function_settings~create_function_right( id =
'COPYC' ).
create object lr_copy_button.

  lv_button_text = 'Copy'.

  lr_copy_button->set_text( lv_button_text ).
  lr_copy_button->SET_IMAGE_SOURCE( 'ICON_COPY_OBJECT' ).

  lr_user_funcopy->set_editor( lr_copy_button ).

Then create a method of type event handler and event will be ON_FUNCTION.

in this method you can check for the function code 'COPYC' in this case

if r_param->id = 'COPYC.



Former Member
0 Kudos

Can you please right the code for event handling..thanks

Former Member
0 Kudos

Hi ,

write following to create button:

DATA: ui_btn1 TYPE REF TO cl_salv_wd_fe_button.

DATA: ui_sepa1 TYPE REF TO cl_salv_wd_fe_separator.

DATA: sepa1 TYPE REF TO cl_salv_wd_function.

DATA: btn1 TYPE REF TO cl_salv_wd_function.

data: lr_disp_button type ref to cl_salv_wd_fe_button.

data: lv_button_text type string.

CREATE OBJECT ui_btn1.

CREATE OBJECT ui_sepa1.

create object lr_disp_button.

      • /to create new buttons...

lv_button_text = 'Refresh Selection'.

lr_disp_button->set_text( lv_button_text ).

  • lr_disp_button->SET_IMAGE_SOURCE( 'ICON_DISPLAY' ).

btn1 = l_value->if_salv_wd_function_settings~create_function( id = 'LSBUTTON' ).

btn1->set_editor( lr_disp_button ).

IN methods tab of view declare:

ON_REFRESH Event Handler On refresh function pf ALV ON_FUNCTION INTERFACECONTROLLER ALV

in method ON_REFRESH write below code:

DATA: temp TYPE string.

temp = r_param->id.

IF temp = 'LSBUTTON'.

    • custom functional;ity

endif.

where :

R_PARAM Importing 1 IF_SALV_WD_TABLE_FUNCTION

This woudl solve ur purpose.

Regards,

Vishal.

Former Member
0 Kudos

Ok, i have created the event handler on_action...but where i need to call. How this event will be triggered on button click, where i need to set the link between button click and this event.

I have debugged the program and put a breakpoint on

if r_param->id = 'SAVE.

ENDIF.

and when i click on the button, it's not stopping me here. Its not coming here.

Pls suggest.

Thanks

Edited by: Abap WD on Aug 7, 2008 5:04 PM

Former Member
0 Kudos

IN methods tab of view declare:

ON_REFRESH Event Handler on refresh function pf ALV ON_FUNCTION INTERFACECONTROLLER ALV

IN the above line :

u have mapped ON_REFRESH method with ON_FUNCTION. ON_FUNCTION is event of ALV. Which will be triggered when you click on the button in ALV. Which will than trigger ON_REFRESH.

now double click on ON_REFRESH and write the code.

Regards,

Vishal.

Former Member
0 Kudos

Yes, i have created like this, i know it's simple, but not working for me:) I could not understand the purpose of this statement

ON_REFRESH Event Handler on refresh function pf ALV ON_FUNCTION INTERFACECONTROLLER ALV

Where do i need to write this? How this statement is doing mapping?

I appreciate ur effort, i think i'm quite near to the solution...

thanks

Former Member
0 Kudos

go to view controller.

than go to methods tab where we have WDINIT and other methods.

than in method column wrote : ON_REFRESH

than in EVENT column press F4. you will see a list. in that look in EVENT column and select ON_function.

this would write this line.

Former Member
0 Kudos

Thanks Vishal, Its solved.

Answers (0)