cancel
Showing results for 
Search instead for 
Did you mean: 

how to change label text at runtime

former_member196023
Active Participant
0 Kudos

Hi,

suppose I have one inuput element MATNR and one lable associated to element MATNR.

so by default it will show label text as "Material", so if I want to change it at design time i simply change it's property to whatever text I want.

But my requirement is to change it's value at runtime.

Please suggest code snippet to achieve this.

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

Make element in Context of type String .Make Default value of it as 'MATNR' . Now run time write code that will change value of element to whatever you want.

You bind this to lable's text .

Cheers

Parry

former_member196023
Active Participant
0 Kudos

Hi Parry,

Thanks. This way is achievable.

But I have already tried this.

I was expecting some other way.

Still thanks a lot.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Haresh,

You can check out following weblogs,

/people/thomas.szcs/blog/2005/12/28/dynamic-programming-in-web-dynpro-abap--introduction-and-part-i-understanding-ui-elements

/people/thomas.szcs/blog/2006/01/03/dynamic-programming-in-web-dynpro-abap--part-ii-handling-viewelements

Also there is some code snippet given.

Hope this will help you.

Cheers,

Darshna.

Former Member
0 Kudos

DATA : lr_ui_root TYPE REF TO if_wd_view_element.

lr_container TYPE REF TO cl_wd_ui_element_container.

lr_ui_root = view->get_element( EXPORTING id = 'ROOTUIELEMENTCONTAINER' ).

lr_container ?= lr_ui_root.

lr_container->get_child ( ...your label )

then modify the attributes of the label.

PS: Do this in WDDOMODIFYVIEW method ONLY.

former_member196023
Active Participant
0 Kudos

HI Shailesh,

Thanks for your reply.

I have done this much code in WDMODIFYVIEW.


  DATA :
    lr_ui_root TYPE REF TO if_wd_view_element,
    lr_container TYPE REF TO cl_wd_uielement_container.

  lr_ui_root = view->get_element( 'ROOTUIELEMENTCONTAINER' ).
  lr_container ?= lr_ui_root.

  lr_container->get_child( exporting id = 'MATNR_LABEL' ).

but couldn't figure out how to change the label value.

Will you please suggest further code?

Thanks.

graghavendra_sharma
Contributor
0 Kudos

Hi Haresh,

I'm facing similar kind of problem.

Can you please let me know how do I get the id of an View Element at runtime?

Here in your code you are passing id directly.

lr_container->get_child( exporting id = 'MATNR_LABEL' ).

but i want to get the id of an element dynamically. I found an interface IF_WD_VIEW_ELEMEN which has the method GET_ID which returns the ID of an element, but I couldn't succeed how to use that

Regards

Raghav