cancel
Showing results for 
Search instead for 
Did you mean: 

Change the Standard ALV Export button text

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

saravanan_narayanan
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Saravanan,

Here is a thread explaining how to change the standard text but I am not clear what he explained in this. Dont know how to implement that logic as mentioned in this thread.

Regards,

Sarathy.

Lukas_Weigelt
Active Contributor
0 Kudos

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

saravanan_narayanan
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Thank you Saravanan and Lukas. I got it.

Regards,

Sarathy.

Answers (1)

Answers (1)

Former Member
0 Kudos

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 ).