Post

Enhancements in ABAP SQL Functions

Learn about ABAP SQL enhancements in S/4HANA 2025: STRING_AGG and LTRIM/RTRIM now accept host variables as separator or trim character.

STRING_AGG: The separator can now be passed as a host variable instead of a constant. If you’re not familiar with this function, check out this earlier post.

LTRIM / RTRIM: The trim character can now come from a host variable or SQL expression (not limited to a single character).

Example: You can join values with a dynamic separator or remove leading/trailing characters by passing them as variables.

1
2
3
4
5
6
7
DATA lv_separator TYPE string VALUE ', '.
DATA lv_trim_char TYPE string VALUE '0'.

SELECT STRING_AGG( field, @lv_separator )
       LTRIM( another_field, @lv_trim_char )
  FROM my_table
  INTO ...

Note: Available from S/4HANA 2025+ (Private / On-Premise) and latest versions in the Public Cloud.

ABAP SQL Function Enhancements

This post is licensed under CC BY 4.0 by the author.