cancel
Showing results for 
Search instead for 
Did you mean: 

Overwrite Label Text

former_member1287623
Participant
0 Kudos

Hi,

I want to overwrite a Label Text.

The Text I want to overwrite comes from a bound Context Node.

Before I want to overwrite it I need the current Text, because I want to change Labels dynamically - however to get the actual Text I use Method GET_TEXT of Class CL_WD_LABEL but this Method sets some Attributes (which seems to be an error for my understanding of OO Concepts) anyway it seems not possible to overwrite the Text with Method SET_TEXT after calling GET_TEXT method (GET_TEXT will call the Bound Attribute after 1st call).

Any ideas?

TIA,

Sebastian

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sebastian.

Why don't you just create a context attribute of type string and bind this to the labels text property.

Then you just have to set this attribute each time the text should change.

Cheers,

Sascha

former_member1287623
Participant
0 Kudos

doesn't work... I want to do it dynamically, and I don't want to create n-context-string-fields only for setting a new label text

and I even don't want to create a context field at runtime for a simple text change

thanks for your idea but there must be an option with less effort

Former Member
0 Kudos

Hi Sebasdian.

Maybe I do not get you .... how many lables do you wanna change?

If you just want to set one label you only need one context attribute. And you do not have to create it at runtime. You can create it at design time ... and setting this context attribute at runtime with the current text it should display is quiet easy and dynamic -> internally it does nothing else then call set_text I guess..

But if you do not know how much labels you want to change at design time you are right ... then you need something more dynamic

Cheers,

Sascha

former_member1287623
Participant
0 Kudos

Hi,

I want to change n-Lables

And I want to do it like that: Loop at every Labels of a View and Replace every Occurance of "Oracle" with "SAP" (for example)

But if the Label I want to change the text for is bound to a Context Element with an DDIC-Type the GET_TEXT Method (which I need for dynamic text changes) will set Parameters in the Label class which will always will get the old text (on next GET_TEXT call) never mind what text I assigned with SET_TEXT.

But without a GET_TEXT I will not get all "Oracle" lables and so I can't replace the Texts I want to.

Hope I could explain my Prob

Regards,

Sebastian

Former Member
0 Kudos

Hi Sebastian.

Now I got you, sorry.

When you remove the DDIC binding the new text will be displayed:

lo_label->remove__ddic_binding( 'TEXT' ).

lo_label->set_text( 'BLA' ).

Cheers,

Sascha

former_member1287623
Participant
0 Kudos

That's it!

I didn't check this method becuase the where used list does't work for concatenated Attributes -.-

Thanks & Regards,

Sebastian

Answers (0)