ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Character String and Byte String Processing → Expressions and Functions for String Processing → string_exp - String Expressions → string_exp - String Templates → Examples of string templates
String Templates, asXML Format
This example demonstrates how the asXML format is specified for embedded expressions.
Other versions:
7.31 | 7.40 | 7.54
Source Code
DATA result TYPE TABLE OF string.
DATA:
i TYPE i VALUE -123,
int8 TYPE int8 VALUE -123,
p TYPE p DECIMALS 2 VALUE '-1.23',
decfloat16 TYPE decfloat16 VALUE '123E+1',
decfloat34 TYPE decfloat34 VALUE '-3.140000E+02',
f TYPE f VALUE '-3.140000E+02',
c TYPE c LENGTH 3 VALUE ' Hi',
string TYPE string VALUE ` Hello `,
n TYPE n LENGTH 6 VALUE '001234',
x TYPE x LENGTH 3 VALUE 'ABCDEF',
xstring TYPE xstring VALUE '456789AB',
d TYPE d VALUE '20020204',
t TYPE t VALUE '201501',
utclong TYPE utclong VALUE '2010-06-14T11:16:04,6358150'.
DEFINE add_line.
result = VALUE #( BASE result
( |{ &1 WIDTH = 14 }{
&2 WIDTH = 30 }{
&2 XSD = YES }| ) ).
END-OF-DEFINITION.
add_line `i` i.
add_line `int8` int8.
add_line `p` p.
add_line `decfloat16` decfloat16.
add_line `decfloat34` decfloat34.
add_line `f` f.
add_line `` ``.
add_line `c` c.
add_line `string` string.
add_line `n` n.
add_line `` ``.
add_line `x` x.
add_line `xstring` xstring.
add_line `` ``.
add_line `d` d.
add_line `t` t.
add_line `utclong` utclong.
cl_demo_output=>display( result ).
Description
This program takes data objects of different types and creates the asXML formats shown under Mapping of Elementary ABAP Types. To make it clearer, the string template is shown in a macro.