Get Example source ABAP code based on a different SAP table
• SEARCH itab ABAP Statement • FOR SEARCH itab (obsolete)
SEARCH itab> Short Reference >
ABAP_SYNTAX_OBS SEARCH itab FOR pattern $[IN ${CHARACTER$|BYTE$} MODE$]> $[STARTING AT idx1$] $[ENDING AT idx2$]> $[ABBREVIATED$]> $[AND MARK$].>
ABAP Addition 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 lines of the index table> itab> for a pattern specified in pattern>. SEARCH> cannot be used for hashed tables> and not for tables with secondary table keys>. The statement always searches the internal table and does not search any header line> that might exist. For pattern>, a character-like or byte-like data 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 is terminated at the first hit and sy-tabix> is set to the index of the table line found. sy-fdpos> is set to the offset of the character string or byte string found or word found in the table line. If the pattern is not found, 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:
Instead of the statement SEARCH>, the statement FIND IN TABLE>> should be used whenever possible.
While SEARCH> supports all index tables>, FIND IN TABLE> supports only standard tables>.
See also Migrating SEARCH> to FIND>>. ABAP_HINT_END • IN BYTE MODE SEARCH itab (obsolete) • IN CHARACTER MODE SEARCH itab (obsolete)
ABAP Addition
What does it do? The addition IN CHARACTER MODE> or IN BYTE MODE > is used to determine whether character or byte string processing> is performed. The line type of the internal table must be suitable for the selected processing type. If no addition is specified, the search is performed character by character. • STARTING AT SEARCH itab (obsolete) • ENDING AT SEARCH itab (obsolete)
ABAP Addition
What does it do? The additions STARTING AT> and ENDING AT> can be used to restrict the search to just some of the table lines of table itab >. idx1> and idx2> expect data objects of the type i >. The value in idx1> specifies from which line and to which line the value idx2> is searched for. If only one of the additions is specified, the search is performed from the first to the last line. The search is not performed 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 lines in itab >
the value of idx2> is less than the value of idx1> • ABBREVIATED SEARCH itab (obsolete)
ABAP Addition
What does it do? In character-like searches, it is possible to specify an abbreviated pattern in pattern> for character string processing by using the addition ABBREVIATED>, like in the statement SEARCH>>. • AND MARK SEARCH itab (obsolete)
ABAP Addition
What does it do? When searching character by character, it is possible to transform 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 line and sy-fdpos> to the offset (7) of the word see> in the line. After the statement is executed, the second table line contains the content you'll SEE the line> specified by the addition AND MARK>. ABEXA 00567 ABAP_EXAMPLE_END