cancel
Showing results for 
Search instead for 
Did you mean: 

FormattedTextView

Former Member
0 Kudos

Hi,

I have an internal table of type TLINE and I concatenate the lines into a string like this:

'This is the <U>first'</ >' line which contains a < (less than sign) *
 This is the <U>second</> line which contains a > (greater than sign) *'

I want to display it in a FormattedTextView so I do this replacements first:

REPLACE ALL OCCURRENCES OF '<U>' IN lv_longtext WITH '<h1>'.
REPLACE ALL OCCURRENCES OF '<H>' IN lv_longtext WITH '<h1>'.
REPLACE ALL OCCURRENCES OF '</ >' IN lv_longtext WITH '</h1>'.
REPLACE ALL OCCURRENCES OF '*' IN longtext WITH '<br/>'.

The header replacements works fine, but I get the error that the less and greater signs are not allowed.

I think this is cause these signs are a part of the HTML tags.

If I do also a replacement of these signs into HTML code then the header tag does'nt work anymore

cause the < and > of the header tag will be replaced also.

Does anybody have an idea how to solve this problem?

Thanks, Susanne

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

Have you tried with "&lt" and "&gt" for "<" and ">".

May be you can give it a try by replacing "<u>" to "&lth1&gt".

REPLACE ALL OCCURRENCES OF '<' IN lv_longtext WITH '&lt'.

REPLACE ALL OCCURRENCES OF '>' IN lv_longtext WITH '&gt'.

Because i remember , in HTML to bring the '<' or '>', we need to use a entites.

[entites|http://www.w3schools.com/HTML/html_entities.asp]

I am not sure if it will work...:)..Give it a try though.

Do let us know if it worked.

Thnks,

aditya.

Former Member
0 Kudos

Thanks Aditya, but I tried this already.

But then the "h1" tag doesn't work anymore. The header tag will not be interpreted anymore.

Any other idea?

Also how can I display a striked word in the text? The FormattedTextView doesn't know the tag "strike".

Former Member
0 Kudos

hi ,

If it the input string has the '<' or '>' (greater/lesser than symbol) symbol within " "(double quotes) then the replace statement seems to work fine.

REPLACE ALL OCCURRENCES OF ' "<" ' WITH '&lt'.

REPLACE ALL OCCURRENCES OF ' ">" ' WITH '&gt'.

In this case the replace statement does not replace the '<' symbol of your header tags.

lv_longtext = 'This is the <U> first </ > which contains a "<" * '. //your input should be somthing like this.

But I dont know if it is possible for you to get the '<' in double quotes.:(

And also once the symbols are replaced with entites , it should be rendered properly.

Thnks,

aditya.

Madhu2004
Active Contributor
0 Kudos

HI,

You can use the below code to convert the SAP script text i.e TLINE to formatted text

data formatted_text type ref to cl_wd_formatted_text.

" convert from context
formatted_text = cl_wd_formatted_text=> create_from_sapscript(
  sapscript_head  = sapscript_head
  sapscript_lines = sapscript_lines
).

" set it into the context
wd_context->set_attribute(
  name  = my_formatted_text_attr

  value = formatted_text->m_xml_text ).

cl_wd_formatted_text=>write_sapscript_tokens( ).

This code snippet is retrieved form the standard sap help file for web dynpro

[Formatted text view SAP help file|http://help.sap.com/saphelp_nw70/helpdata/en/3b/219141c1d0ae5fe10000000a1550b0/content.htm]

Regards,

Madhu

Answers (0)