ABAP Keyword Documentation → ABAP - Reference → Processing Internal Data → Character String and Byte String Processing → Expressions and Functions for String Processing → String Functions → Examples of String Functions
String Functions, escape for HTML
This example demonstrates the string function escape
for HTML.
Other versions: 7.31 | 7.40 | 7.54
Source Code
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( ).
Description
The program applies the function escape
to a string used as the body of a HTML file. The string is displayed as a text and in the HTML file both before and after the function is executed.