on 08-22-2011 2:43 PM
Hi Expert,
I want to change the standard button ( Export Button ) text in ALV table. I had gone through some threads already but still i am not getting a clear idea on this. Could you please any one give me a clear structure on this.
Regards,
Sarathy.
Hello Sarathy,
I doubt whether we can change the text of the standard buttons. the SET_TEXT method of the CL_SALV_WD_FUNCTION_STD class is protected.
If you didnt get any positive response from others then you can create a custom button and assign the standard EXPORT function to it.
BR, Saravanan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sarathy,
quoting from the thread you referred to:
Lazlo,
>
> TEXT attribute in CL_SALV_WD_FUNCTION_STD is NOT read only and is public. That mean u can directly change it using <b>lr_function->text</b>.
>
> If u wanna use the SET_TEXT method heres how -
>
> Yes thats a protected method, means only Subclass can access it.
>
> Heres a round about way....
>
> CL_SALV_WD_A_FUNCTION_STD is the Superclass for CL_SALV_WD_FUNCTION_STD .
>
> Create a Subclass ZCL_SALV_WD_A_FUNCTION_STD that inherits from CL_SALV_WD_A_FUNCTION_STD. In this class define a method CHANGE_TEXT that has a CHANGING parameter TYPE REF TO CL_SALV_WD_A_FUNCTION_STD
>
> So:
>
> data <b>m_a_func_std</b> type ref to CL_SALV_WD_A_FUNCTION_STD.
> m_a_func_std ?= m_alv_model->IF_SALV_WD_FUNCTION_SETTINGS~ GET_FUNCTION_STD ( 'button function' )
>
> data <b>m_sub_a_func_std</b> type ref to ZCL_SALV_WD_A_FUNCTION_STD .
> m_sub_a_func_std->CHANGE_TEXT( m_a_func_std ).
>
> CHANGE_TEXT method...
>
> m_a_std_func->SET_TEXT ( 'your text' ).
>
> Thanks
> Anand
Anand is describing a work-around for using a protected method outside of the class and its subclasses. He does that because:
Protected Section
All of the components declared in the protected section are accessible to all methods of the class and of classes that inherit from it. Protected components form a special interface between a class and its subclasses.
In SE24, when you create a class, you have a button in Tab Properties "Superclass" where you can enter the said Superclass. Then you have the same Interface available as the standard class. Then you create a custom method within your custom class which implements the standard method from the superclass so by doing this, encapsulation is provided for the protected method and you can still access it because you call it with another public method providing a changing parameter TEXT.
In fact, all I did now was repeating what Anand already stated step by step. Did this help you in any way? If not, where exactly are your problems understanding what to do?
best regards, Lukas
Hello Sarathy,
Its workaround but I'm not sure whether this is ok. this is what is explained in the thread mentioned by you
Since CL_SALV_WD_FUNCTION_STD->SET_TEXT method is protected, they have inherited the CL_SALV_WD_A_FUNCTION_STD class and in that the sub class they are changing the text. If you are okay with this work around the do the following
1. Create a class ZCL_SALV_WD_A_FUNCTION_STD and in this add CL_SALV_WD_A_FUNCTION_STD as the super class
2. in the class create a method CHANGE_TEXT with the following importing parameters
ir_function_std type ref to CL_SALV_WD_A_FUNCTION_STD
iv_text type string
And in the method implementation write the following code
ir_function_std->set_text( value = iv_text ).
3. in your webdynpro INIT method write the following code
data m_a_func_std type ref to cl_salv_wd_a_function_std.
m_a_func_std ?= lo_alv_model->if_salv_wd_function_settings~get_function_std( if_salv_wd_c_std_functions=>export ).
data m_sub_a_func_std type ref to zcl_salv_wd_a_function_std .
create object m_sub_a_func_std
exporting
id = 'SAM' "dummy id
* type_std = if_salv_wd_c_function_settings=>type_std
* group =
.
m_sub_a_func_std->change_text( m_a_func_std ).
This will solve the problem. But keep in mind that SAP would have made this method protected might be because of some reason. So I wont encourage this workaround.
BR, Saravanan
Here is the new solution with out creating ZCLASS.
DATA: lo_function_dpwty TYPE REF TO cl_prs_std_alv_funct,
lr_functions TYPE REF TO if_salv_wd_function_settings,
lr_function_std TYPE REF TO cl_salv_wd_a_function_std.
CREATE OBJECT lo_function_dpwty
EXPORTING
id = 'X'.
lr_functions = l_ref_interfacecontroller->get_model( ).
" append row rename
lr_function_std = lr_functions->get_function_std( if_salv_wd_c_std_functions=>edit_append_row ).
lv_button_text = 'Add Item'.
lo_function_dpwty->change_text( EXPORTING text = lv_button_text
CHANGING std_function = lr_function_std ).
"Delete row item rename
lr_function_std = lr_functions->get_function_std( if_salv_wd_c_std_functions=>edit_delete_row ).
lv_button_text = 'Delete Item'.
lo_function_dpwty->change_text( EXPORTING text = lv_button_text
CHANGING std_function = lr_function_std ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.