sapdev logo background
sapdev logo sapdev logo
Comments

ABAP SEARCH ITAB Statement syntax, information and example SAP source code



Return to Statement index



SEARCH itab

Short Reference

ABAP Syntax(Obsolete) SEARCH itab FOR pattern [IN {CHARACTER|BYTE} MODE]
[STARTING AT idx1] [ENDING AT idx2]
[ABBREVIATED]
[AND MARK].

ABAP_ADDITIONS:
1 ... IN {CHARACTER|BYTE} MODE
2 ... [STARTING AT idx1] [ENDING AT idx2]
3 ... ABBREVIATED
4 ... AND MARK

What does it do? This statement searches the rows of the index table
itab for a pattern specified in pattern . SEARCH cannot be used for hashed tables . The statement always searches the internal table and not the header line (if it exists).
For pattern , a character-like or byte-likedata object can be specified, depending on the processing type. The pattern in pattern
can have the same forms as the statement SEARCH
has for character-like or byte-like string processing.
The search ends at the first hit and sy-tabix is set to the index of the table row found. sy-fdpos is set to the offset of the character string or byte string found or word found in the table row. If the pattern is not found, then sy-fdpos and sy-tabix
are set to 0.

ABAP_SUBRC_GENERAL
sy-subrc Meaning
0Pattern found in itab .
4Pattern not found in itab .

Latest notes: The statement SEARCH has been replaced by the statement FIND IN TABLE .

ABAP_ADDITION_1 ... IN {CHARACTER|BYTE} MODE

What does it do? The addition IN CHARACTER MODE or IN BYTE MODE
is used to determine whether
character or byte string processing is carried out. The row type of the internal table must be suitable for the chosen processing type. If no addition is specified, the search is carried out character by character.

ABAP_ADDITION_2 ... [STARTING AT idx1] [ENDING AT idx2]

What does it do? You use the additions STARTING AT and ENDING AT to restrict the search to just some of the table rows of table itab . idx1 and idx2 expect data objects of the type
i . The value in idx1 specifies from which row and to which row the value idx2 is searched for. If only one of the additions is specified, the search is carried out from the first to the last row.
The search is not carried out and sy-subrc is set to 4, if:
the value of idx1 or idx2 is less than 1

the value of idx1 is greater than the number of rows in
itab

the value of idx2 is less than the value of idx1

ABAP_ADDITION_3 ... ABBREVIATED

What does it do? When you search character by character, you can specify an abbreviated pattern in pattern for character chain processing by using the addition ABBREVIATED (just as with statement SEARCH ).

ABAP_ADDITION_4 ... AND MARK

What does it do? When searching character by character, you can convert a character string or a word found in itab to uppercase using the statement AND MARK (just as with the statement
SEARCH for character string processing ).

Example ABAP Coding The search character by character is successful and sets
sy-tabix to the index (2) of the corresponding row and
sy-fdpos to the offset (7) of the word "see" in the row. After the statement is executed, the second table row contains the content "you'll SEE the line" specified by the addition AND MARK .
DATA text_table TYPE TABLE OF string.

APPEND: 'Sweet child in time' TO text_table,
'you''ll see the line' TO text_table,
'the line between' TO text_table,
'good and bad.' TO text_table.

SEARCH text_table FOR '.see.' AND MARK.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




SEARCH-
SELECT




comments powered by Disqus