Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Character String and Byte String Processing →  Expressions and Functions for String Processing →  String Functions →  Common Parameters of Character String Functions 

occ - Occurrence

Other versions: 7.31 | 7.40 | 7.54

Syntax


... ( ... occ = occ ...  ) ...

Effect

In string functions that are being searched, the parameter occ specifies the occurrence of a match. occ is a numeric expression position of type i.

If occ is positive, the occurrences are counted from the left; if occ is negative, the they are counted from the right. The values 1, 2, .... indicate the first, second, ... occurrences. The values -1, -2, .... indicate the last, last but one, ... occurrences.

The default value of occ is 1. Except in the case of the replacement function replace, the value 0 raises an exception from the class CX_SY_STRG_PAR_VAL. If replace has the value 0, all occurrences are replaced.


Note

The sign of occ also modifies the default values of off and len.


Example

The result of the following function calls is UX and XU.

DATA(result1) = replace( val = `XX` sub  = `X` with = `U` occ =  1 ). 
DATA(result2) = replace( val = `XX` sub  = `X` with = `U` occ = -1 ).