Get Example source ABAP code based on a different SAP table
ID CONCATENATE • CONCATENATE ABAP Statement • LINES OF CONCATENATE • INTO CONCATENATE
CONCATENATE> Short Reference >
ABAP_SYNTAX CONCATENATE ${dobj1 dobj2 ...$}$|${LINES OF itab$}> INTO result> $[IN ${CHARACTER$|BYTE$} MODE$]> $[SEPARATED BY sep$]> $[RESPECTING BLANKS$].>
ABAP Addition 1 ... IN ${CHARACTER$|BYTE$} MODE> 2 ... SEPARATED BY sep> 3 ... RESPECTING BLANKS>
What does it do? Concatenates either the content of the data objects dobj1, dobj2, ...> or the lines of the internal table itab> in accordance with their order and assigns them to the target field result>. itab > is a functional operand position >. The following can be specified for the target field result>:
An existing character-like or byte-like variable to which the result of the concatenation can be converted.
An inline declaration with DATA(var)>> or FINAL(var)>>. If IN CHARACTER MODE> is used, the declared variable is of the type string>; if IN BYTE MODE> is used, it is of the type xstring>. If the target field result> has a fixed length and this is greater than the required length, it is padded on the right with blanks or hexadecimal 0. If the target field is too short, the concatenation is truncated on the right. If the target field is a string, its length is adjusted accordingly. In character string processing, trailing blanks are usually ignored by default for data objects dobj1, dobj2 ...> or lines in the internal table itab> of fixed length. System Fields> sy-subrc>Meaning> 0The content of all data objects dobj1, dobj2 ...> or itab > lines was passed to the target field result>. 4The content of the data objects dobj1, dobj2 ...> or itab > lines could not be passed completely, since result> is too short.
Latest notes:
Instead of CONCATENATE>, string expressions> can usually also be used for elementary fields, where concatenations are possible using either concatenation operators> > or embedded expressions > in string templates>. The built-in function concat_lines_of>> can be used to concatenate lines of an internal table.
The ABAP runtime framework performs an internal optimization to reduce the number of reassignments if new fragments are appended to an existing string> on the right within a loop. If the string or parts of the string itself are appended, no optimization takes place, which causes a squared increase in runtime in loops. This can be prevented by using helper variables. See also the Performance Note> for string expressions. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 The example shows that a concatenation with CONCATENATE> has the same result as a concatenation with the concatenation operator> >> or via embedded expressions>. ABEXA 00139 ABAP_EXAMPLE_END • IN BYTE MODE CONCATENATE • IN CHARACTER MODE CONCATENATE
ABAP Addition
What does it do? The optional addition IN ${CHARACTER$|BYTE$} MODE> determines whether character string or byte string processing> is performed. If the addition is not specified, character string processing is performed. Depending on the processing type, the data objects dobj1, dobj2 ...>, the lines of the internal table itab>, and the separator sep> must be character-like> or byte-like>.
ABAP_EXAMPLE_VX5 Concatenation of individual bytes from an internal table in a byte string. ABEXA 00140 ABAP_EXAMPLE_END • SEPARATED BY CONCATENATE
ABAP Addition
What does it do? The addition SEPARATED BY> is used to insert the content of data object sep> between the content of the consecutive data objects dobj1, dobj2 ...>. In character string processing, trailing blanks are respected for separators sep> of fixed length.
ABAP_EXAMPLE_VX5 After the first CONCATENATE> statement, result> contains Wehaveallthetimeintheworld>, and after the second it contains We have all the time in the world>. ABEXA 00141 ABAP_EXAMPLE_END • RESPECTING BLANKS CONCATENATE
ABAP Addition
What does it do? The addition RESPECTING BLANKS> is only allowed in character string processing and respects the trailing blanks for data objects dobj1, dobj2 ...> or lines of the internal table itab >. If this addition is not used, the blanks are respected for data type string> only.
Latest notes: The addition RESPECTING BLANKS> of the statement CONCATENATE > can be used to assign any character strings text > to target fields str> of type string> while respecting trailing blanks: CLEAR str.> CONCATENATE str text INTO str RESPECTING BLANKS.> NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 After the first CONCATENATE> statement, result > contains When_the_music_is_over>, and after the second it contains When______the_______music_____is________ over______>. The underscores here represent blanks. ABEXA 00142 ABAP_EXAMPLE_END