SAP REPLACE - Obsolete ABAP Statements

Get Example source ABAP code based on a different SAP table
  


Standard SAP Help for REPLACE_OBSOLETE

REPLACE substring WITH

Short Reference
• REPLACE ABAP Statement
• WITH REPLACE - obsolete
• INTO REPLACE - obsolete

ABAP Syntax(Obsolete)REPLACE substring WITH new INTO dobj
[IN {BYTE|CHARACTER} MODE]
[LENGTH len].

ABAP Addition
1 ... IN {CHARACTER|BYTE} MODE
2 ... LENGTH len

What does it do? This statement scans a character string or byte chain dobj for the substring specified in substring and replaces the first character sequence or byte sequence in dobj that matches substring with the contents of the data object new .

The memory areas of substring and new must not overlap, otherwise the result is undefined. If substring is an empty string, the position before the first character or byte of the search range is found and the content of new is inserted before the first character.

If the length of the interim result is longer than the length of dobj, the object is truncated on the right in the case of data objects of fixed length. If the length of the interim result is shorter than the length of dobj, data objects of fixed length are padded on the right with blanks or hexadecimal zeroes. Data objects of variable length are adjusted accordingly.

In character string processing, the trailing blanks are not ignored for data objects dobj, substring, and new of type c, d, n, or t.

System fields sy-subrcMeaning 0The substring in substring was replaced in the target field dobj by the content of new. 4The substring in substring could not be replaced in the target field dobj by the content of new.



Latest notes:This variant of the REPLACE statement has been
replaced by the variant REPLACE.
• IN BYTE MODE REPLACE - obsolete
• IN CHARACTER MODE REPLACE - obsolete

ABAP Addition

What does it do? The optional IN {CHARACTER|BYTE} MODE addition determines whether character string or byte string processing is carried out. If the addition is not specified, character string processing is carried out. Depending on the processing type, the data objects substring, new, and dobj must be character-like or byte-like.
• LENGTH REPLACE - obsolete

ABAP Addition

What does it do? If the addition LENGTH is not specified, all the data objects involved are evaluated in their entire length. If the addition LENGTH is specified, only the first len characters or bytes of substring are used for the search. len expects a data object of the type i.



Example ABAP Coding
After the replacements, text1 contains the
complete content 'I should know that you know', while text2 has the cut-off content 'I should know that'. DATA: text1 TYPE string VALUE 'I know You know',
text2 TYPE c LENGTH 18 VALUE 'I know You know',
substring TYPE string VALUE 'know',
new TYPE string VALUE 'should know that'.

REPLACE substring WITH new INTO text1.
REPLACE substring WITH new INTO text2.

Return to menu