on 04-13-2011 9:34 AM
Hi ,
I added a button SAVE in my alv table. It gets dis played on my alv table also. But I dont know where to write the code for the button to make it work. Please some on help me regarding this issue.
Hi,
In the View, METHODS tab, first you need to create a method for save and under EVENT controller you need to select the ALV event on ON FUNCTION for that alv. there is a help when you click on EVENTS, select this event.
Methodname Methodtype event*
*USER_FUNCTION EVENTHANDLER ONFUNCTION
Go to the method, there is a parameter R_PARAM type IF_SALV_WD_TABLE_FUNCTION which returns the function that is called.
You need to write a case statment for each function and write the respective coding
Ex:
case r_param~name = 'SAVE'.
// coding..You can call SAVE method in this and handle your code.
endcase.
Regards,
Lekha.
Edited by: Lekha on Apr 13, 2011 2:16 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Leka,
Thank you so much for your reply. have a doubt.
DATA LR_BUTTONUI TYPE REF TO CL_SALV_WD_FE_BUTTON.
DATA BUTTON1 TYPE REF TO CL_SALV_WD_FUNCTION.
CREATE OBJECT LR_BUTTONUI.
LR_BUTTONUI->SET_TEXT( 'Update' ).
BUTTON1 = L_VALUE->IF_SALV_WD_FUNCTION_SETTINGS~CREATE_FUNCTION( ID = 'SAVE_UP' ).
BUTTON1->SET_EDITOR( LR_BUTTONUI ).
Below is my code, should i create a method with the name 'SAVE_UP' and i dont understand about the event contoller u said. i found a tab called event under method tab when i click on that it shows "Event and controller can only be maintained for event handlers". Is that wat u are meaning.
Hi,
Create a entry - METHODS TAB
USERFUNCTION(Method Name), Method type as EVENT HANDLER, EVENT as ON_FUNCTION.
Create one more method as SAVE, Method type (METHOD), code it here.
METHOD USERFUNCTION.
CASE R_PARAM~NAME = 'SAVE_UP' "Button Id
call method wd_this->SAVE.
ENDCASE.
ENDMETHOD.
Regards,
Lekha.
Hi Scafandri,
It is very simple. Follow the stepa i have given below your code will work fine.
To create a Button in the Alv table:
data lr_buttonui type ref to cl_salv_wd_fe_button.
data button1 type ref to cl_salv_wd_function.
create object lr_buttonui.
lr_buttonui->set_text( 'Update' ).
button1 = l_value->if_salv_wd_function_settings~create_function( id = 'SAVE_UP' ).
button1->set_editor( lr_buttonui ).
Then create a method name USER_FUNCTION, method Type - Event Handler, Event - ONFUNCTION. And write the below code in that method.
method user_function .
case r_param->id.
when 'SAVE_UP'.
call method wd_this->save.
endcase.
endmethod.
Then create a method SAVE and write your logic as per your requirement. The code will work fine. Get back to me in case of any queries.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.