Ansicht
Dokumentation

ABAPREPLACE_INTO - REPLACE INTO

ABAPREPLACE_INTO - REPLACE INTO

Fill RESBD Structure from EBP Component Structure   PERFORM Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

REPLACE Syntax Diagramm

REPLACE ... WITH ... INTO ...

Syntax

REPLACE f WITH g INTO h.

Additions


1. ... LENGTH len



2. ... IN BYTE MODE



3. ... IN CHARACTER MODE


Notes



See Only character-like fields in character string processing.

You should no longer use the second variant in Unicode programs. For details on this, see Character String Processing.

Effect

The first occurrence of the contents of field f in field h is replaced with the contents of field g. All fields involved are always evaluated in their defined length, including C fields in which blanks at the end are normally ignored.

System values

Return Code indicates whether the search character string f was found in h and could be replaced with g:

sy-subrc = 0
Character string could be replaced.
sy-subrc <> 0
Character string could not be replaced.

Example

DATA field(10) TYPE C.
MOVE 'ABCB' TO field.
REPLACE 'B' WITH 'string' INTO field.

returns: field = 'AstringCB', SY-SUBRC = 0

Note

The fields f and g of the REPLACE statement must not overlap since the result is undefined then.

Addition 1

... LENGTH len

Effect

The search pattern f is not searched for in field h in its defined field length but in the length len.

Example

DATA: pattern(6)     TYPE C VALUE 'ABC',
      len            TYPE I,
      repl_string(6) TYPE C VALUE '123456',
      field(12)      TYPE C VALUE 'abcdeABCDE'.

REPLACE pattern WITH repl_string INTO field.

Does not change field since 'ABC   ' does not occur in 'abcdeABCDE  '.

len = STRLEN( pattern ).
REPLACE pattern LENGTH len
                WITH repl_string
                INTO field.

Changes field to 'abcde123456D'.



Addition 2

... IN BYTE MODE

Effect

If you use this addition, all fields must be of the type X or XSTRING.



Addition 3

... IN CHARACTER MODE

Effect

This addition is optional and corresponds to the default setting.



Related

SEARCH, TRANSLATE, OVERLAY

Additional help

Replacing Field Contents






CPI1466 during Backup   BAL Application Log Documentation  
This documentation is copyright by SAP AG.

Length: 4624 Date: 20240424 Time: 140424     sap01-206 ( 79 ms )