This is a test message to test the length of the message box.
New ABAP String functions
Created by Software-Heroes

ABAP - String functions (Part 2)

There are many new inline functions in New ABAP. We want to deal with those for string processing today and show you some advantages.

With the many new inline functions that were introduced and also with the change in the processing and construction of strings, many functions for the string processing have been renewed again. A call as a concatenated statement or directly in a query is now possible.

In today's article we want to go over a few of these features and show you the benefits and innovations that come with them.



As the new commands clearly state, this is a case-sensitive conversion. For example, you can convert the value for a litter without changing the contents of the variable. The comparison in the example results in the output of 'Found!'.

" Old
DATA: ld_value TYPE string VALUE 'TESTTEXT'.

" New
DATA: ld_compare TYPE string VALUE 'TESTTEXT'.
IF to_upper( |Testtext| ) = ld_compare.
  WRITE: / 'Found!'.



Finds and replaces strings within a string and returns the new value as a string. In the normal version, only one occurrence of the substring is replaced, for which the parameter "occ" must be set.

" Old
DATA(ld_text) = 'my pony is my pony and this is my house'.

" New
DATA(ld_new) = replace( 
  val  = 'my pony is my pony and this is my house' 
  sub  = 'my'
  with = 'your'
  occ  = 0



The substring function extracts a substring from a string and returns it. The function can also be linked in combination with an inline declaration or used in an if-statement.

" Old
DATA ld_text TYPE string VALUE 'My ABAP course'.
ld_text = ld_text 3(4).

" New
DATA(ld_part) = substring( val = 'My ABAP course' off = 3 len = 4 ).



The command joins the contents of the table rows and returns a new string of full length. In our example, the old method still has the disadvantage that finally a space is added. With a few more lines of code, this fact can also be corrected.

" Preparation
  lt_sstr TYPE string_table.
  ld_text TYPE string.

APPEND `This` TO lt_sstr.
APPEND `is` TO lt_sstr.
APPEND `my` TO lt_sstr.
APPEND `new` TO lt_sstr.
APPEND `house` TO lt_sstr.

" Old
LOOP AT lt_sstr INTO DATA(ld_sub).
  ld_text = ld_text && ld_sub && ` `.

" New
ld_text = concat_lines_of( table = lt_sstr sep = ` ` ).



Many of the new inline features already exist in an old way. The new features have the advantage that they can be linked together, used in if-statements and generate a new value. This makes them much more flexible than the old functions.


cadaxo - New string functions
SAP Documentation overview

Included topics:
New ABAPString functions
Comments (0)

ABAP - Text, String, Template

Category - ABAP

How do I use character strings in modern ABAP development and how do they behave together with inline declarations. We also look at errors that can happen with it.


ABAP - Predicative Method Call

Category - ABAP

Due to the OO concept, own methods are usually used for complex queries. This article is about comparing the result from such methods.


ABAP - Performance for the SELECT

Category - ABAP

In this article we will look at a few special cases with the SELECT and examine the performance of these constructs. We'll show you the current alternatives and give you little tips while reading.


ABAP - Check objects (Instances)

Category - ABAP

In this article we will show you how you can analyze instances and react to them correctly, for example if you hand them over during processing and want to react individually.


ABAP - Loops

Category - ABAP

With New ABAP, new loops and possibilities for restricting table contents were created. We'll take a closer look at these new commands in this article.