cancel
Showing results for 
Search instead for 
Did you mean: 

Changing the text property of standard Button in SRM standard webdynpro component

Former Member
0 Kudos

Hello Guys,

Currently the text of  button in SRM standard webdynpro component is hard coded , as we know that we  cant change the property of button in standard webdynpro component , now i want to display dynamic text, can any one please help me how to set it dynamically .please find attached screen shot

Thanks

Vijaya

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hello Vijaya,

As per shravan's response,Create one attribute of type string and bind the text property of the appropriate button and in your code handle the button name dynamically by using set_attribute() method.Hope it might helpful.

Thanks

KH

Former Member
0 Kudos

Hi,

Take an attribute of type string and bind it to the text property instead of hardcoding it. Pass the value dynamically in your code

Former Member
0 Kudos

Hi Vijaya,

Thanks for the information. I work on the Travel and Expense module.

Please try the below mentioned code:

DATA: lo_search_button TYPE REF TO cl_wd_button,

            lo_text TYPE wdy_md_translatable_text.

           lo_search_button ?= view->get_element( 'ID of the UI element' ).

           IF lo_search_button IS BOUND.

               lo_text  = 'Your text here'.

               lo_search_button->set_text ( lo_text ).

           ENDIF.

Regards,

Sanjeev Kotwal.

uday_gubbala2
Active Contributor
0 Kudos

Hi Vijaya,

You can achieve that by manipulating the TextView's properties dynamically within the WDDOMODIFYVIEW method as how suggsted by Sanjeev.

But am now sure about the CL_FITV_WD_UTIL class that he had specified. Isn't this a Travel Management specifc utility class?

What you can do is within your views WDDOMODIFYVIEW method get the reference of the desired button & bind its TEXT property to a context attribute. So now you can set whatever value you want to to the context attribute & it would now reflect dynamically onto your views button.

Am giving a sample code snippet below which would help you accomplish the same. As per my snippet I intendoontrol the buttons text by using a context attribute by name "BUTTON_TEXT" which exists under my context node "NODE". You can change it to suit your views context & mention the path to the context attribute accordingly.

Regards,

Uday

data: lr_button_row type ref to CL_WD_BUTTON_ROW,
      lr_button     type ref to CL_WD_BUTTON,
      lr_container  type ref to CL_WD_UIELEMENT_CONTAINER.

check first_time = abap_true.

lr_container ?= view->get_root_element( ).

lr_button_row ?= lr_container->get_element( id = 'BUTTON_ROW' ).

lr_button ?= lr_button_row->GET_BUTTON( ID = 'SEARCH' ).

lr_button->bind_text( PATH = 'NODE.BUTTON_TEXT' ).

Former Member
0 Kudos

Hi Uday,

Thanks for your reply, you are right CL_FITV_WD_UTIL class is not available in SAP SRM 7 version

i have written the code in pre-exit of WDDOMODIFYVIEW 

see my code

DATA: lr_button_row TYPE REF TO cl_wd_button_row,

          lr_button     TYPE REF TO cl_wd_button,

          lr_container  TYPE REF TO cl_wd_uielement_container.

   CHECK first_time = abap_true.

   lr_container ?= view->get_root_element( ).

lr_button_row ?= lr_container->get_element( id = 'BUTTON_ROW'). " i am getting syntactical error here


   lr_button ?= lr_button_row->get_button( id = 'SEARCH' ).

   lr_button->set_text( '$OTR:ZSRM_TEST/ZSRM_KS_OTR_START_SEARCH').

can you please help me , which method i should use there

Thanks

Vijaya



Lukas_Weigelt
Active Contributor
0 Kudos

Hi Vijaya,

first of all you do not need cast down the UI-Tree step by step. You can cast the button directly. I.e.

DATA: lo_button TYPE REF TO cl_wd_button.

lo_button ?= view->get_element( ID = 'SEARCH' ).

IF lo_button IS NOT INITIAL.

     lo_button->set_text(<your_text_here>).

ENDIF.

Two things:

I've taken the habit to directly cast down the specific elemtn I want because I have experienced some times that SAP changes the UI-Tree (for examples renaming containers or shifting them around) and then, if you cast every level seperately, your casting is much more vulnerable to hit a null pointer at some point.

I remember setting a text with means of the path to the OTR didn't work for me once (it's some time ago already though). In case you make the same experience, read the text from OTR into a string variable first and give this variable to the set_text-method.

Cheers, Lukas

uday_gubbala2
Active Contributor
0 Kudos

Hi Vijaya,

My apologies I have quoted an invalid method name in my code... I wasn't having acess to my SAP system & so had typed from my memory.... You need to say GET_CHILD and not GET_ELEMENT... So the corect code would be:

data: lr_button_row type ref to CL_WD_BUTTON_ROW,
      lr_button     type ref to CL_WD_BUTTON,

      lv_str          type string,
      lr_container  type ref to CL_WD_UIELEMENT_CONTAINER.

check first_time = abap_true.

lr_container ?= view->get_root_element( ).

lr_button_row ?= lr_container->get_child( id = 'BUTTON_ROW' ).

lr_button ?= lr_button_row->GET_BUTTON( ID = 'SEARCH' ).

lv_str = cl_wd_utilities=>get_otr_text_by_alias(  alias = 'ZSRM_TEST/ZSRM_KS_OTR_START_SEARCH' ).

lr_button->set_text( value = lv_str ).

Regards,

Uday

Former Member
0 Kudos

Hi Vijaya,

Can you try the below mentioned code:

Use method UI_SET_TEXT of class CL_FITV_WD_UTIL in the method WDDOMODIFYVIEW.

CL_FITV_WD_UTIL=>ui_set_text( io_view    = view

                                                        iv_id         = 'ID of the UI element'

                                                        iv_text      = 'Your Text' ).

Former Member
0 Kudos

Hi Sanjeev

the class cl_fitv_wd_util is not available in SRM 7.0 version, any other solutions ?

Thanks

Vijaya