Start of Content Area

Replacements in Character Strings  Locate the document in its SAP Library structure

Using the following variants of the REPLACEstatement:

1. REPLACE [{FIRST OCCURRENCE}|{ALL OCCURRENCES} OF] pattern
      
IN dobj WITH new.

2. REPLACE SECTION [OFFSET off] [LENGTH len] OF dobj WITH new.

it is possible to replace characters or bytes of the dobjvariable with characters or bytes of the new  data object. Here we distinguish between sample-based (variant 1) and position-based (variant 2) replacement.

When the replacement is executed, an interim result is implicitly created, without any length limit, and this interim result is passed to the dobj data object. If the length of the interim result is longer than the length of dobj, data objects of fixed length are truncated at the right. If the length of the interim result is shorter than the length of dobj, data objects of fixed length are filled with blanks or hexadecimal 0 at the right. Data objects of variable length are adjusted accordingly. If the interim result is truncated to the right, sy-subrc is set to 2.

During string processing with dobj data objects of fixed length, the closing blank is taken into account, while with new it is not.

 

 

End of Content Area