cancel
Showing results for 
Search instead for 
Did you mean: 

TextEdit element - prefill textlines

b_deterd2
Active Contributor
0 Kudos

Hi,

Probably a basic question but I'm trying to fill a TextEdit element with some hard-coded text (several lines). For some reason it is only showing the first line of text I coded. (in methode wddoinit).

Any help will be appreciated.

regards,

bert

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Can you post the coding of your WDDOINIT that does the population of the text.

b_deterd2
Active Contributor
0 Kudos

code is:


data: textnode type ref to if_wd_context_node.
data: ls_message type ig_componentcontroller=>element_textnode.
data: lt_message type ig_componentcontroller=>elements_textnode.

textnode = wd_context->get_child_node( name = 'TEXTNODE' ).
ls_message-message = 'line 1'. append ls_message to lt_message.
ls_message-message = 'line 2'. append ls_message to lt_message.
textnode->bind_table( new_items = lt_message ).

The textedit is only showing line 1.

regards,

Bert

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I think you misunderstand how a textEdit element works. It doesn't bind to an entire node using the elements as lines of the textEdit. Instead it binds to a single attribute of a single element. You should create one element of type STRING and then concatenate your text lines (separated by CL_ABAP_CHAR_UTILITIES=>CR_LF) into this one string.

b_deterd2
Active Contributor
0 Kudos

Yes you're absolutely right. I interpreted the TextEdit wrong.

It works now (why didn't I ask sooner!) but between the lines there is a blank line.

Line 1

Line 2

instead of:

Line 1

Line 2

I used the code:

data: lv_string type string.

concatenate 'line 1' cl_abap_char_utitilities=>cr_lf 'line 2' into lv_string.

wd_context->set_attribute( name = 'TESTINFO' value = lv_string ).

Any ideas?

Bert

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Then try cl_abap_char_utitilities=>newline instead of cl_abap_char_utitilities=>cr_lf.

b_deterd2
Active Contributor
0 Kudos

Thanks a lot. Problem solved !!!

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Check your context attribute size.

If your attribue size is less than your data then you will get the output with no of characters of size of your attribute.

here i have taken attribute of type char10 but i am appending more than 10 characters so i am getting output with 10 characters.

DATA:

elem_context TYPE REF TO if_wd_context_element,

stru_context TYPE if_first=>element_context ,

item_edit LIKE stru_context-edit.

  • get element via lead selection

elem_context = wd_context->get_element( ).

item_edit = 'abcdefghijklmnopqrs'.

elem_context->set_attribute(

VALUE = item_edit

name = 'EDIT'

).

Edited by: suman kumar chinnam on Sep 26, 2008 3:25 PM