Get Example source ABAP code based on a different SAP table
ABAP_ITAB - Table Reduction, String Processing This example demonstrates a reduction of the columns of a character-like table to a text string.
ABAP_SOURCE_CODE DEMO CL_DEMO_REDUCE_TEXT
ABAP_DESCRIPTION A table comprehension> is used to construct a new internal table switched_words> from the content of an internal table words>, where the condition operator SWITCH>> replaces certain lines of the existing internal table with other lines. This table is specified in the FOR> expression> of the REDUCE>> expression and its lines are reduced to a text string using a concatenation after NEXT> and then assigned to the variable sentence>. Here, the helper variable sep> declared after INIT> is initial for the first read line and is filled with a blank for the evaluation of further lines. This example also demonstrates an alternative implementation in which the table comprehension is embedded directly in the table reduction. Here, the helper variable switched_words> is not required, but the source code is much harder to read. A human reader, for example, can hardly tell that the FOR> expressions are not sequential and that the table comprehension is executed first, followed by the table reduction for the result.