Get Example source ABAP code based on a different SAP table
• segment ABAP_FUNCTION • index segment function • sep segment function • space segment function
ABAP_STRINGFUNC > - segment>
ABAP_SYNTAX ... segment( val = text> index = idx $[sep$|space = delim$] ) ...>
What does it do? This built-in function> returns the occurrence of a segment of the argument text> specified by index>>. A segment is defined by limits. The start and end of the string in text> are the outer limits. Inner limits delim> can be passed to sep> or space> as follows:
If the argument sep> is filled, the substring specified in delim> is searched for (case-sensitive) in text> and used as a limit. If a substring specified in delim> occurs directly one after another in text>, an empty segment is created, and an empty string is returned for this segment.
If the argument space> is filled, each individual character is searched for in delim> (case-sensitive) and this is used as a limit. If the individual characters specified in delim> occur directly one after another in text>, no empty segment is created, and no result is returned. The limits are not part of the segments. If sep> or space > are not specified, the argument sep> is filled implicitly a single blank. In both cases, specifying an empty string raises an exception of the class CX_SY_STRG_PAR_VAL>. If index> is positive, the occurrences are counted from the left and if index> is negative from the right. The values 1, 2, .... indicate the first, second, ... occurrence. The values -1, -2, .... indicate the last, last but one, ... occurrences. If the value of index> is 0, or the specified segment does not exist, an exception of the class CX_SY_STRG_PAR_VAL> is raised. delim> is a character-like expression position> and index> is a numeric expression position> with type i>. If delim> has a fixed length, any trailing blanks are ignored. The return value has the type string>.
Latest notes: If the substring specified in delim> is not found, the entire character string forms a single segment, which can only be addressed by using the values 1 or -1 for index>. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 The following function calls return AB>, CD>, EF >, and GH> respectively, and raise an exception at the end. ABEXA 01236 ABAP_EXAMPLE_END
ABAP_EXAMPLE_ABEXA String Functions, cmax>, cmin>, and segment>> ABAP_EXAMPLE_END
Runtime Exceptions
Catchable Exceptions CX_SY_STRG_PAR_VAL>>
Reason for error:
limit in sep> is empty or the occurrence in index> is 0 or was not found.