BlogGitHub
Reference/ORK/SINGLETON/ORK/IF_SI_ABAP_STRING
Interface/ORK/IF_SI_ABAP_STRING
ABAP String Functions (Singleton)
Package
/ORK/SINGLETON
Members
44
Description

Comprehensive utility interface for string manipulation, searching, splitting, formatting and line/offset handling.

Designed to be used via a singleton implementation.

34 items
Methods
substring
MethodPublic

Returns substring using offset and length.

Parameters

NameDescriptionstrSource stringoffStart offset (0-based)lenLength, -1 = until endresultExtracted substring

Signature

METHODS substring IMPORTING str TYPE string
                              !off TYPE i DEFAULT 0
                              !len TYPE i DEFAULT -1
                    RETURNING VALUE(result) TYPE string.
split
MethodPublic

Splits string at delimiter.

Parameters

NameDescriptionstrSource stringatDelimiterresultSplit parts

Signature

METHODS split IMPORTING str TYPE string
                          !at TYPE string
                RETURNING VALUE(result) TYPE string_table.
split_extended
MethodPublic

Advanced splitting with optional behavior control.

Parameters

NameDescriptionstrSource stringatDelimiter (optional)remove_emptiesRemove empty tokenstrim_entriesTrim each tokencase_sensitiveCase sensitive delimiter matchresultSplit parts

Signature

METHODS split_extended IMPORTING str TYPE string
                                   !at TYPE string OPTIONAL
                                   remove_empties TYPE abap_bool DEFAULT abap_false
                                   trim_entries TYPE abap_bool DEFAULT abap_false
                                   case_sensitive TYPE abap_bool DEFAULT abap_false
                         RETURNING VALUE(result) TYPE string_table.
split_regex
MethodPublic

Splits string using regular expression pattern.

Parameters

NameDescriptionstrSource stringpatternRegex separatorcase_sensitiveCase sensitivityresultSplit parts

Signature

METHODS split_regex IMPORTING str TYPE string
                                !pattern TYPE string
                                case_sensitive TYPE abap_bool DEFAULT abap_true
                      RETURNING VALUE(result) TYPE string_table.
split_to_lines
MethodPublic

Splits string into lines.

Parameters

NameDescriptionstrSource stringuse_cr_lfExplicit CRLF handlingresultLines

Signature

METHODS split_to_lines IMPORTING str TYPE string
                                   use_cr_lf TYPE abap_bool DEFAULT abap_undefined
                         RETURNING VALUE(result) TYPE string_table.
trim
MethodPublic

Trims whitespace from both ends.

Parameters

NameDescriptionstrSource stringresultTrimmed string

Signature

METHODS trim IMPORTING str TYPE string
               RETURNING VALUE(result) TYPE string.
trim_start
MethodPublic

Trims characters from start.

Parameters

NameDescriptionstrSource stringcharsCharacters to remove (default whitespace)resultTrimmed string

Signature

METHODS trim_start IMPORTING str TYPE string
                               chars TYPE string OPTIONAL
                     RETURNING VALUE(result) TYPE string.
trim_end
MethodPublic

Trims characters from end.

Parameters

NameDescriptionstrSource stringcharsCharacters to remove (default whitespace)resultTrimmed string

Signature

METHODS trim_end IMPORTING str TYPE string
                             chars TYPE string OPTIONAL
                   RETURNING VALUE(result) TYPE string.
pad_left
MethodPublic

Pads string on left to total length.

Parameters

NameDescriptionstrSource stringtotal_lenTarget total lengthcharPadding characterresultPadded string

Signature

METHODS pad_left IMPORTING str TYPE string
                             total_len TYPE i
                             !char TYPE ty-char1
                   RETURNING VALUE(result) TYPE string.
pad_right
MethodPublic

Pads string on right to total length.

Parameters

NameDescriptionstrSource stringtotal_lenTarget total lengthcharPadding characterresultPadded string

Signature

METHODS pad_right IMPORTING str TYPE string
                              total_len TYPE i
                              !char TYPE ty-char1
                    RETURNING VALUE(result) TYPE string.
pad_both
MethodPublic

Pads string on both sides to total length.

Parameters

NameDescriptionstrSource stringtotal_lenTarget total lengthcharPadding characterresultPadded string

Signature

METHODS pad_both IMPORTING str TYPE string
                             total_len TYPE i
                             !char TYPE ty-char1
                   RETURNING VALUE(result) TYPE string.
join
MethodPublic

Joins string table using separator.

Parameters

NameDescriptionstrsStrings to joinsepSeparator stringresultJoined string

Signature

METHODS join IMPORTING strs TYPE string_table
                         sep TYPE string
               RETURNING VALUE(result) TYPE string.
any_to_string
MethodPublic

Converts any value to string representation.

Parameters

NameDescriptionanyValue to convertformatFormatting maskformat_providerExternal formattertypeExplicit type descriptorresultString representation

Signature

METHODS any_to_string IMPORTING !any TYPE any
                                  !format TYPE csequence OPTIONAL
                                  format_provider TYPE REF TO /ork/if_format_provider OPTIONAL
                                  !type TYPE REF TO cl_abap_datadescr OPTIONAL
                        RETURNING VALUE(result) TYPE string.
find
MethodPublic

Finds all occurrences of pattern.

Parameters

NameDescriptionstrSource stringpatternSearch patterncase_sensitiveCase sensitive searchresultMatch positions

Signature

METHODS find IMPORTING str TYPE string
                         !pattern TYPE string
                         case_sensitive TYPE abap_bool DEFAULT abap_true
               RETURNING VALUE(result) TYPE match_result_tab.
find_contains_any_gapless
MethodPublic

Finds occurrences of any specified characters with gapless position handling.

Searches the source string for characters contained in the provided set. Match positions are normalized to a gapless coordinate system. Positions that fall into logical gaps are marked using the specified gap indicator.

Parameters

NameDescriptionstrSource string to searchcharsSet of characters to matchgap_indicatorValue used to mark gap positionsresultMatch positions in gapless representation

Signature

METHODS find_contains_any_gapless IMPORTING str TYPE string
                                              chars TYPE string
                                              gap_indicator TYPE i DEFAULT /ork/if_si_abap_string=>cm_default_gap_indicator
                                    RETURNING VALUE(result) TYPE match_result_tab.
find_contains_any
MethodPublic

Finds occurrences of any specified characters.

Searches the source string for characters contained in the provided set. Each occurrence of any matching character is returned as a match position.

Parameters

NameDescriptionstrSource string to searchcharsSet of characters to matchresultMatch positions

Signature

METHODS find_contains_any IMPORTING str TYPE string
                                      chars TYPE string
                            RETURNING VALUE(result) TYPE match_result_tab.
find_first
MethodPublic

Finds first occurrence of pattern.

Parameters

NameDescriptionstrSource stringpatternSearch patterncase_sensitiveCase sensitive searchresultFirst match position

Signature

METHODS find_first IMPORTING str TYPE string
                               !pattern TYPE string
                               case_sensitive TYPE abap_bool DEFAULT abap_true
                     RETURNING VALUE(result) TYPE match_result.
find_gapless
MethodPublic

Finds all occurrences of pattern with gapless position handling.

Searches the source string for the specified pattern. Match positions are normalized to a gapless coordinate system. Positions that fall into logical gaps are marked using the specified gap indicator.

Parameters

NameDescriptionstrSource string to searchpatternSearch patterngap_indicatorValue used to mark gap positionscase_sensitiveCase sensitive searchresultMatch positions in gapless representation

Signature

METHODS find_gapless IMPORTING str TYPE string
                                 !pattern TYPE string
                                 gap_indicator TYPE i DEFAULT /ork/if_si_abap_string=>cm_default_gap_indicator
                                 case_sensitive TYPE abap_bool DEFAULT abap_true
                       RETURNING VALUE(result) TYPE match_result_tab.
find_regex
MethodPublic

Regex search returning match positions.

Parameters

NameDescriptionstrSource stringpatternRegular expressioncase_sensitiveCase sensitive matchingresultMatch positions

Signature

METHODS find_regex IMPORTING str TYPE string
                               !pattern TYPE string
                               case_sensitive TYPE abap_bool DEFAULT abap_true
                     RETURNING VALUE(result) TYPE match_result_tab.
find_regex_first
MethodPublic

Regex search returning first match.

Parameters

NameDescriptionstrSource stringpatternRegular expressioncase_sensitiveCase sensitive matchingresultFirst match position

Signature

METHODS find_regex_first IMPORTING str TYPE string
                                     !pattern TYPE string
                                     case_sensitive TYPE abap_bool DEFAULT abap_true
                           RETURNING VALUE(result) TYPE match_result.
find_regex_gapless
MethodPublic

Performs regular expression search with gapless position handling.

Matches are determined using the specified regular expression. The resulting match positions are normalized to a gapless coordinate system. Positions that correspond to logical gaps are marked using the specified gap indicator.

Parameters

NameDescriptionstrSource string to searchpatternRegular expression patterngap_indicatorValue used to mark gap positionscase_sensitiveCase sensitive matchingresultMatch positions in gapless representation

Signature

METHODS find_regex_gapless IMPORTING str TYPE string
                                       !pattern TYPE string
                                       gap_indicator TYPE i DEFAULT /ork/if_si_abap_string=>cm_default_gap_indicator
                                       case_sensitive TYPE abap_bool DEFAULT abap_true
                             RETURNING VALUE(result) TYPE match_result_tab.
find_begin_of_line
MethodPublic

Returns offset of line start for given offset.

Parameters

NameDescriptionstrMultiline textoffsetAbsolute offsetresultOffset of line start

Signature

METHODS find_begin_of_line IMPORTING str TYPE string
                                       !offset TYPE i
                             RETURNING VALUE(result) TYPE i.
match_result_to_gapless
MethodPublic

Converts match positions into gapless representation.

Transforms match results so that their offsets refer to a logical gapless coordinate system. Positions that fall into gaps or cannot be mapped are marked using the specified gap indicator.

This method is typically used after performing searches on text that contains removed or ignored segments which must not contribute to positional indexing.

Parameters

NameDescriptionmatch_tabOriginal match result tabletext_lenLength of the original text used as positional referencegap_indicatorValue used to mark gap positionsresultMatch results normalized to gapless representation

Signature

METHODS match_result_to_gapless IMPORTING match_tab TYPE match_result_tab
                                            text_len TYPE i
                                            gap_indicator TYPE i DEFAULT /ork/if_si_abap_string=>cm_default_gap_indicator
                                  RETURNING VALUE(result) TYPE match_result_tab.
match_regex
MethodPublic

Returns substrings matching regex.

Parameters

NameDescriptionstrSource stringpatternRegular expressioncase_sensitiveCase sensitive matchingresultMatched substrings

Signature

METHODS match_regex IMPORTING str TYPE string
                                !pattern TYPE string
                                case_sensitive TYPE abap_bool DEFAULT abap_true
                      RETURNING VALUE(result) TYPE string_table.
index_of
MethodPublic

Finds index of substring.

Parameters

NameDescriptionstrSource stringsearch_strSubstring to searchignore_caseCase insensitive searchstart_indexStart search indexlengthSearch length (-1 = full string)find_lastSearch from endresultFound index or negative if not found

Signature

METHODS index_of IMPORTING str TYPE string
                             search_str TYPE string
                             ignore_case TYPE abap_bool DEFAULT abap_false
                             start_index TYPE i DEFAULT 0
                             !length TYPE i DEFAULT -1
                             find_last TYPE abap_bool DEFAULT abap_false
                   RETURNING VALUE(result) TYPE i.
replace
MethodPublic

Replaces first occurrence of substring.

Parameters

NameDescriptionstrSource stringsearch_strSubstring to replacereplace_strReplacement textignore_caseCase insensitive replacementresultModified string

Signature

METHODS replace IMPORTING str TYPE string
                            search_str TYPE string
                            replace_str TYPE string
                            ignore_case TYPE abap_bool DEFAULT abap_false
                  RETURNING VALUE(result) TYPE string.
replace_all
MethodPublic

Replaces all occurrences of substring.

Parameters

NameDescriptionstrSource stringsearch_strSubstring to replacereplace_strReplacement textignore_caseCase insensitive replacementresultModified string

Signature

METHODS replace_all IMPORTING str TYPE string
                                search_str TYPE string
                                replace_str TYPE string
                                ignore_case TYPE abap_bool DEFAULT abap_false
                      RETURNING VALUE(result) TYPE string.
starts_with
MethodPublic

Checks whether string starts with substring.

Parameters

NameDescriptionstrSource stringsubPrefix to testignore_caseCase insensitive comparisonresultabap_true if prefix matches

Signature

METHODS starts_with IMPORTING str TYPE string
                                sub TYPE string
                                ignore_case TYPE abap_bool DEFAULT abap_false
                      RETURNING VALUE(result) TYPE abap_bool.
ends_with
MethodPublic

Checks whether string ends with substring.

Parameters

NameDescriptionstrSource stringsubSuffix to testignore_caseCase insensitive comparisonresultabap_true if suffix matches

Signature

METHODS ends_with
    IMPORTING str TYPE string
              sub TYPE string
              ignore_case TYPE abap_bool DEFAULT abap_false
    RETURNING VALUE(result) TYPE abap_bool.
get_line_offset
MethodPublic

Returns offset within current line.

Parameters

NameDescriptiontextMultiline textoffsetAbsolute offsetresultOffset within line

Signature

METHODS get_line_offset IMPORTING !text TYPE string
                                    !offset TYPE i
                          RETURNING VALUE(result) TYPE i.
get_line_number
MethodPublic

Returns line number for offset.

Parameters

NameDescriptiontextMultiline textoffsetAbsolute offsetresultLine number (1-based)

Signature

METHODS get_line_number IMPORTING !text TYPE string
                                    !offset TYPE i
                          RETURNING VALUE(result) TYPE i.
get_line_pos
MethodPublic

Provides information about the line number and position in the respective line for a position in the text

Parameters

NameDescriptiontextMultiline textoffsetAbsolute offsetresultLine and position information

Signature

METHODS get_line_pos IMPORTING !text TYPE string
                                 !offset TYPE i
                       RETURNING VALUE(result) TYPE /ork/if_si_abap_string=>ty_s_line_pos.
char_from_unicode
MethodPublic

Returns character for Unicode code point.

Parameters

NameDescriptionuccpUnicode code pointresultCharacter string

Signature

METHODS char_from_unicode IMPORTING uccp TYPE i
                            RETURNING VALUE(result) TYPE string.
char_to_unicode
MethodPublic

Returns Unicode code point for character.

Parameters

NameDescriptioncharCharacter stringlengthCharacter lengthresultUnicode code point

Signature

METHODS char_to_unicode
    IMPORTING !char TYPE csequence
    EXPORTING !length TYPE i
    RETURNING VALUE(result) TYPE i.
8 items
Types
ty_ta
TypePublic

Generic table types for string collections.

Signature

TYPES ty_ta TYPE ANY TABLE OF string.
ty_tt
TypePublic

Signature

TYPES ty_tt TYPE STANDARD TABLE OF string WITH EMPTY KEY.
ty_th
TypePublic

Signature

TYPES ty_th TYPE HASHED TABLE OF string WITH UNIQUE KEY table_line.
ty_ts
TypePublic

Signature

TYPES ty_ts TYPE SORTED TABLE OF string WITH NON-UNIQUE KEY table_line.
ty_t_range
TypePublic

Range types for string values.

Signature

TYPES ty_t_range TYPE RANGE OF string.
ty_s_range
TypePublic

Signature

TYPES ty_s_range TYPE LINE OF ty_t_range.
ty
TypePublic

Signature

TYPES: BEGIN OF ty,
           char1 TYPE c LENGTH 1,
           char2 TYPE c LENGTH 2,
           char3 TYPE c LENGTH 3,
         END OF ty.
ty_s_line_pos
TypePublic
Information about the line number and position

... in the respective line

Signature

BEGIN OF ty_s_line_pos,
      "! Line number, 1-based
      line TYPE i,
      "! Position within the line, 0-based
      pos TYPE i,
    END OF ty_s_line_pos.
1 item
Constants
cm_default_gap_indicator
ConstantPublic

Default indicator for gap positions used by gapless matching.

Signature

CONSTANTS cm_default_gap_indicator TYPE i VALUE -999999 ##NO_TEXT.
1 item
Data
is
DataPublic

Predicate helper interface providing classification checks.

Signature

DATA is TYPE REF TO /ork/if_si_abap_string_is READ-ONLY.
Repository11 packages · 113 objects
124 items