I am having a one single row with text with HTML-tags. Example.
html_string = '<!DOCTYPE html><html><body> <h1> My First Heading</h1> <p> My first paragraph.</p> </body> </html> '.
I want to give the value of html_string back as a formatted HTML text like that:
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
Best would be in a popup. Anyone got any idea? Best would be a function module or so. I've been looking around for some while but I have not found anything which fits my requirements.
I just found exactly what I needed. This might help any future programmers:
https://help.sap.com/doc/abapdocu_750_index_htm/7.50/de-DE/abenstring_function_escape_abexa.htm
REPORT demo_escape_html.
CLASS demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
ENDCLASS.
CLASS demo IMPLEMENTATION.
METHOD main.
DATA: body TYPE string,
esc_body TYPE string.
body = `<table border> `
&& `<tr><td>11</td><td>12</td></tr> `
&& `<tr><td>21</td><td>22</td></tr> `
&& `</table>`.
esc_body = escape( val = body
format = cl_abap_format=>e_html_text ).
cl_demo_output=>new(
)->begin_section( 'Original text'
)->write_text( body
)->next_section( 'Original text formatted as HTML'
)->write_html( body
)->next_section( 'Escaped text'
)->write_text( esc_body
)->next_section( 'Escaped text formatted as HTML'
)->write_html( esc_body
)->display( ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
demo=>main( ).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With