Documentation View

We are hiring and constantly growing! Have a look through our vacancies to find the right role for you!

ABAPFIND_OPTIONS - FIND OPTIONS

ABAPFIND_OPTIONS - FIND OPTIONS

Vendor Master (General Section)   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.
SAP E-Book

FIND, options

Short Reference



...  $[${RESPECTING$|IGNORING$} CASE$]
     $[MATCH COUNT  mcnt$]
     ${ ${$[MATCH OFFSET moff$]
        $[MATCH LENGTH mlen$]$}
     $| $[RESULTS result_tab$|result_wa$] $}
     $[SUBMATCHES s1 s2 ...$] ...


Additions

1. ... ${RESPECTING$|IGNORING$} CASE

2. ... MATCH COUNT mcnt

3. ... MATCH OFFSET moff

4. ... MATCH LENGTH mlen

5. ... RESULTS result_tab$|result_wa

6. ... SUBMATCHES s1 s2 ...

Effect

These additions control the FIND statement and provide advanced evaluation options. The addition CASE can be used to specify whether the search is case-sensitive. The additions MATCH, SUBMATCHES, and RESULTS can be used to determine the number, position, and length of the sequences found.

Addition 1

... ${RESPECTING$|IGNORING$} CASE

Effect

This addition is only allowed for character string processing. It specifies whether the search in pattern and dobj is case-sensitive. If RESPECTING CASE is specified, the search is case-sensitive and if IGNORING CASE is used, it is not. If neither of these additions is specified, RESPECTING CASE is used implicitly. If a regular expression is passed as an object of class CL_ABAP_REGEX for pattern, this addition is not allowed. Instead, the properties of the object are respected by the search.

Example

The first search finds the letter "a", the second finds the letter "A".

Addition 2

... MATCH COUNT mcnt

Effect

If the search pattern pattern is found in the search range, the MATCH COUNT addition saves the number of occurrences in mcnt. The following can be specified for mcnt:

  • An existing variable that expects the data type i.
  • An inline declaration DATA(var). The declared variable has the data type i.

If FIRST OCCURRENCE is used, the value after a successful search is always 1. If the search is not successful, mcnt is set to 0.

Check whether the numbers of opening and closing tags in an HTML file match.

Addition 3

... MATCH OFFSET moff

Effect

If the search pattern pattern is found in the search range, the MATCH OFFSET addition saves the offset of the last occurrence with reference to the dobj operand in moff. The following can be specified for moff:

  • An existing variable that expects the data type i.
  • An inline declaration DATA(var). The declared variable has the data type i.

If FIRST OCCURRENCE is used, the result is the offset of the first occurrence. If the search is not successful, moff retains its previous value or remains initial.

Note

The system field sy-fdpos is not filled by FIND.

Addition 4

... MATCH LENGTH mlen

Effect

If the search pattern pattern is found in the search range, the MATCH LENGTH addition saves the length of the last substring found in mlen. The following can be specified for mlen:

  • An existing variable that expects the data type i.
  • An inline declaration DATA(var). The declared variable has the data type i.

If FIRST OCCURRENCE is used, the result is the length of the first occurrence. If the search is not successful, mlen retains its previous value or remains initial.

Example

Determination of the first string of digits within a string and its output.

Addition 5

... RESULTS result_tab$|result_wa

Effect

If the search pattern pattern is found in the search range, the RESULTS addition saves the offsets of the occurrences, the lengths of the substrings found, and information about the subgroup registers of regular expressions either in an internal table result_tab or in a structure result_wa. The internal table or structure can be specified as follows:

  • An existing internal table with the table type MATCH_RESULT_TAB with the line type MATCH_RESULT from the ABAP Dictionary is specified for result_tab. A structure of the type MATCH_RESULT from the ABAP Dictionary is specified for result_wa
  • An inline declaration DATA(var) is specified after RESULTS. If ALL OCCURRENCES is used, an internal table of the type MATCH_RESULT_TAB is declared. If FIRST OCCURRENCE is used, a structure of the type MATCH_RESULT is declared.

When an internal table is used, it is initialized before the search starts and a line is inserted into the internal table for each match found. If a structure is used, it is assigned the values of the last occurrence. If FIRST OCCURRENCE is used and an internal table is specified, exactly one line is inserted into this table if the search is successful.

The line type or structure type MATCH_RESULT has the following components:

  • OFFSET of type INT4 for storing the offset of the substring
  • LENGTH of type INT4 for storing the length of the substring

The lines from result_tab are sorted according to the OFFSET and LENGTH columns. An additional component LINE is only relevant for the FIND IN TABLE variant.

After an unsuccessful search, the content of the internal table result_tab is empty, whereas the structure result_wa preserves its content.

Note

The RESULTS addition is particularly useful when used with the ALL OCCURRENCES addition if an internal table is specified, and with the FIRST OCCURRENCE addition if a structure is specified.

The following search for a regular expression finds the two substrings "ab" and "ba" at offset 0 and 2 and fills the internal table result_tab accordingly with two lines. Since the regular expression contains three subgroups, the submatches component contains three lines. The first line of submatches relates to the outer parenthesis, the second line relates to the first inner parenthesis, and the third line relates to the second inner parenthesis. The first and second lines contain the offset and length of the first occurrence, and the third line remains undefined. The first and third lines contain the offset and length of the second occurrence, and the second line remains undefined.

Addition 6

... SUBMATCHES s1 s2 ...

Effect

This addition can be used only if a regular expression is used in pattern. The current content of the subgroup register of the regular expression is written to s1, s2, ... for the current occurrence. The operands can be specified as follows:

  • As existing variables that expect a character-like type.
  • As an inline declaration DATA(var), where a variable of type string is declared.

When ALL OCCURRENCES is used, the last occurrence is evaluated. If more operands s1, s2, ... than subgroups are listed, the surplus variables of fixed length are filled with blanks and strings are initialized. If fewer operands s1, s2, ... than subgroups are listed, the surplus subgroups are ignored.

The regular expression after PCRE has two subgroups. The search finds the substring at offset 0 with length 14. The content of the subgroup registers is "Hey" and "my".






TXBHW - Original Tax Base Amount in Local Currency   General Data in Customer Master  
This documentation is copyright by SAP AG.

Length: 11631 Date: 20221203 Time: 175000     sap01-206 ( 189 ms )