Ansicht
Dokumentation

ABENSUBSTRING_FUNCTIONS - SUBSTRING FUNCTIONS

ABENSUBSTRING_FUNCTIONS - SUBSTRING FUNCTIONS

General Material Data   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.
SAP E-Book

- substring, substring_...

1. ... substring( val = text $[ off = off$] $[len = len$] ) ...

2. ... substring_from( val = text ${ sub = substring$}$|${pcre = regex$}
                     $[case = case$] $[ occ = occ$] $[len = len$]  ) ...

3. ... substring_after( val = text ${ sub = substring$}$|${pcre = regex$}
                      $[case = case$] $[ occ = occ$] $[len = len$]  ) ...

4. ... substring_before( val = text ${ sub = substring$}$|${pcre = regex$}
                       $[case = case$] $[ occ = occ$] $[len = len$]  ) ...

5. ... substring_to( val = text ${ sub = substring$}$|${pcre = regex$}
                   $[ case = case$] $[ occ = occ$] $[len = len$]  ) ...


Effect

The built-in substring functions determine a substring in the argument text and return it.

The substring is determined as follows:

  • The function substring uses the offset off and the length len to return a certain substring. At least one of the arguments off or len must be specified.
  • The function substring_from searches text for the match specified in occ with the character string specified in substring or with the regular expression specified in regex and returns the subarea of the length len from the offset of the occurrence.
If the argument pcre is used, regex must contain a PCRE regular expression. A regular expression in PCRE syntax is compiled in an extended mode: Most unescaped whitespace (blanks and line breaks) of the pattern are ignored outside character classes and comments can be placed behind #. In order to include whitespace and # into a pattern, they must be escaped or the extended mode must be switched of with (?-x) in the regular expression.
If len is not specified, the substring is returned to the end of the character string. If substring is empty, an exception of the class CX_SY_STRG_PAR_VAL is raised. The search is case-sensitive by default, but this can be overridden using the parameter case. If no substring is found, the return value is empty.
  • The function substring_after works in the same way as substring_from, but the subarea plus the length of the substring found is returned, from the offset of the occurrence.
  • The function substring_before works in the same way as substring_from, but the subarea of the length len is returned before the offset of the occurrence. If len is not specified, the subarea is formed from the start of the character string.
  • The function substring_to works in the same way as substring_before, but the subarea before the offset of the occurrence plus the length of the substring found is returned.

The return value has the type string accordingly.

Notes

  • The performance of the substring functions is not as good as a direct substring access. They do, however, make it possible to use expressions in all operand positions and they allow searches for substrings that match regular expressions.

The return values of the following function calls are: "CD", "CDEFGH", "EFGH", "AB", and "ABCD".

Exceptions

Catchable Exceptions

CX_SY_RANGE_OUT_OF_BOUNDS

  • Cause: Illegal offset or length specified in off and len.
    Runtime Error: STRING_OFFSET_TOO_LARGE

CX_SY_REGEX_TOO_COMPLEX

CX_SY_STRG_PAR_VAL

  • Cause: Substring in sub or regular expression in regex is empty or occurrence in occ is 0.
    Runtime Error: STRG_ILLEGAL_PAR





ROGBILLS - Synchronize billing plans   RFUMSV00 - Advance Return for Tax on Sales/Purchases  
This documentation is copyright by SAP AG.

Length: 9219 Date: 20240425 Time: 034538     sap01-206 ( 102 ms )