Page 1 of 1

Change function text on cl_salv_table

PostPosted: Wed Jul 23, 2014 10:01 am
by q4u
Hi,
I'm adding a function to my SALV grid using the following common coding, and it appears as expected:

Code: Select all
o_functions = go_grid->get_functions( ).
    TRY.
        o_functions->add_function( name = 'RUN'
                                    icon = '@01@'
                                    text = v_text
                                    tooltip = v_text
      position = if_salv_c_function_position=>right_of_salv_functions ).
      CATCH cx_salv_wrong_call cx_salv_existing.
    ENDTRY.

I would like to change the text when the button is clicked - is that possible? I don't see a "Change_function" method.

Thanks
Q4U

Re: Change function text on cl_salv_table

PostPosted: Wed Jul 23, 2014 10:20 am
by Gothmog
Can't you use o_functions->get_functions( ) to get the tables of functions, read the right line to get the reference of the function you want (type CL_SALV_FUNCTION), then use its methods SET_TEXT and/or SET_TOOLTIP to change the texts?

Re: Change function text on cl_salv_table

PostPosted: Wed Jul 23, 2014 10:51 am
by q4u
Gothmog wrote:Can't you use o_functions->get_functions( ) to get the tables of functions, read the right line to get the reference of the function you want (type CL_SALV_FUNCTION), then use its methods SET_TEXT and/or SET_TOOLTIP to change the texts?

Yes I could, and yes I did. Thank-you!

Re: Change function text on cl_salv_table

PostPosted: Wed Jul 23, 2014 11:06 am
by Gothmog
Great! :)

This class is structured in such a way that you often have to use a method to get a "collection" (of functions, or columns, for example) object, then a method of this "collection" object to get to the specific object you want to modify, and then use methods of this object to get/set its properties.

So, get use to double-click a lot on method parameter types to find what you're looking for. ;)