Ansicht
Dokumentation

ABAPREPLACE_ITAB - REPLACE ITAB

ABAPREPLACE_ITAB - REPLACE ITAB

ROGBILLS - Synchronize billing plans   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.
SAP E-Book

REPLACE IN TABLE itab

Short Reference



REPLACE $[${FIRST OCCURRENCE$}$|${ALL OCCURRENCES$} OF$] pattern
        IN TABLE itab $[table_range$] WITH new
        $[IN ${CHARACTER$|BYTE$} MODE$]
        $[replace_options$].

Effect

The internal table itab is searched line-by-line for the character or byte strings specified by pattern and replaces any occurrences with the content of the operand new. new is a character-like expression position.

itab expects a standard table without secondary table keys. The lines in the table must be character-like or byte-like, depending on the addition CHARACTER or BYTE MODE. Byte or character strings that cover multiple table lines are not replaced.

The addition table_range can be used to restrict the search range in the table. When searching in individual table lines, the other additions operate in the same way as in the statement REPLACE pattern IN for elementary character or byte strings, with a further addition, REPLACEMENT LINE that also returns the line number of an occurrence.

In string processing for line types of fixed length, trailing blanks are respected, whereas in new they are ignored.

If the internal table is empty, a replacement is never successful and sy-subrc is set to 4.

Notes

  • REPLACE IN TABLE can be used in tables with structured line types to replace character strings if the structure only contains flat character-like components. Every line is then handled in the same way as a field of type c.
  • Replacements using REPLACE IN TABLE give better performance than running a LOOP and using REPLACE to make replacements in individual lines.

System Fields

sy-subrc Meaning
0 The search pattern was replaced by the content of new and the full result is available in the table lines.
2 The search pattern was replaced by the content of new and the result of the replacement was truncated on the right in at least one table line.
4 The search pattern in pattern was not found in the internal table.
8 The operands pattern or new do not contain interpretable double-byte characters.

The values of sy-tabix and sy-fdpos are not changed.

A simple "DM-Euro Conversion".

Exceptions

Catchable Exceptions

CX_SY_REPLACE_INFINITE_LOOP

  • Cause: Substring of length 0 creates an endless loop when searching for all occurrences.
    Runtime Error: REPLACE_INFINITE_LOOP

CX_SY_TAB_RANGE_OUT_OF_BOUNDS

  • Cause: Illegal offset or line specification in the addition of FROM ... OFFSET ... TO OFFSET.
    Runtime Error: INVALID_TABLE_RANGE

CX_SY_INVALID_REGEX

  • Cause: Invalid expression after the addition PCRE$|REGEX.
    Runtime Error: INVALID_REGEX






ROGBILLS - Synchronize billing plans   General Data in Customer Master  
This documentation is copyright by SAP AG.

Length: 6054 Date: 20240426 Time: 042137     sap01-206 ( 65 ms )