Ansicht
Dokumentation

ABAPREAD_TABLE_OBSOLET - READ TABLE OBSOLET

ABAPREAD_TABLE_OBSOLET - READ TABLE OBSOLET

CPI1466 during Backup   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.
SAP E-Book

READ TABLE, obsolete_key

Short Reference



READ TABLE itab ${ ${ $}
                $| ${ WITH KEY dobj $}
                $| ${ WITH KEY = dobj $} $} $[BINARY SEARCH$] result.

Alternatives:

1. ... ${ $}

2. ... WITH KEY dobj

3. ... WITH KEY = dobj

Addition:

... BINARY SEARCH

Effect

As well as the additions specified in the statement READ TABLE for specifying the individual lines to be read, outside of classes the search key can also be specified in three obsolete forms.

Alternative 1

... ${ $}


Effect

If the search key is not specified explicitly, the internal table itab must be a standard table with a header line. The first line found in the internal table is read whose values in the columns of the standard key match the values in the corresponding components of the header line. Key fields in the header line that only contain blanks are handled as if they match all values. If all the key fields in the header line only contain blanks, the first entry in the table is read. The standard key of the internal table cannot contain any byte-like components.

Notes

  • The statement READ TABLE itab ... is not the same as the explicit specification of the header line itab as a work area wa in the statement READ TABLE itab FROM wa ..., since the table key is used for the search in the latter and not the search key of the header line. This is because key fields that contain blanks do not match all fields of the internal table.
  • The search key can be omitted regardless of the additional obsolete short form (where no explicit target area is specified).

Example

Unlike the example for READ TABLE - table_key, no entry is usually found in the following READ statement, since the entire standard key is compared. In particular, the components deptime and arrtime that belong to the standard key of the internal table are of type t and contain the value "000000" instead of blanks as an initial value in the header line. Only table entries that contain exactly these values are read.

Alternative 2

... WITH KEY dobj


Effect

If a single data object is specified directly after the addition WITH KEY, the internal table itab must be a standard table. The first line found in the internal table is read whose left-aligned content matches the content of the data object dobj. The data object dobj expects only flat data types. In the search, the start of the table lines that are longer than the data object dobj is handled as if they have the same data type dobj (casting).

Example

To use the addition WITH KEY dobj for evaluating specific key fields, a structure must be created that matches the corresponding initial part of the line type. In contrast to the example for READ TABLE - table_key, the client column mandt of the table spfli_tab must be respected by the search key in the following program section.

Alternative 3

... WITH KEY = dobj


Effect

If the addition WITH KEY is followed by a single data object after an "equals" sign, the first line found in the internal table itab is read whose entire content matches the content of the data object dobj. It must be possible to convert the data object dobj to the line type of the internal table. If the data type of dobj does not match the line type of the internal table, a conversion is performed for the comparison in accordance with the conversion rules.

Note

This statement has the same function as specifying the pseudo component table_line as a free key, and is replaced by this component.

READ TABLE itab WITH KEY table_line = dobj ...

Example

Determines (obsolete) whether a line in an internal table exists with an elementary line type. The comment lines show the generally valid syntax with the pseudo-component table_line.

Addition

... BINARY SEARCH

Effect

The addition BINARY SEARCH produces a binary search of the table, not linear. The same prerequisites and restrictions apply as when using the addition with a free search key. Before the correct line can be found, the internal table must be sorted in ascending order as follows:

  • If the search key is not specified explicitly, by the components of the standard key.
  • If the search key is specified using WITH KEY dobj, by its left-aligned content in the length of the data object.
  • If the search key is specified using WITH dobj, by the entire table line.

Note

The fact that the addition BINARY SEARCH requires a different sorting for each of the obsolete variants can be confusing and produce unintended behavior. For this reason, the addition should not be used in the case of the obsolete variants and the non-obsolete variants of READ TABLE used instead.

Exceptions

Non-Catchable Exceptions

  • Cause: The key has stricter alignment requirements than the individual table lines.
    Runtime Error: READ_BAD_KEY_ALIGN
  • Cause: The key is longer than a table line and cannot be truncated.
    Runtime Error: READ_BAD_KEY_PARTIAL





General Data in Customer Master   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.

Length: 8674 Date: 20240329 Time: 124741     sap01-206 ( 143 ms )