SAP OO OBS READ 1

Get Example source ABAP code based on a different SAP table
  


ABAP Code Snippet
ARTICLE

Cannot Use Obsolete READ Variants
You cannot use the READ variant that allows you to read key values from the table header line in ABAP Objects.

In ABAP Objects, the following statement causes an error message:

READ TABLE itab.
Correct syntax:

READ TABLE itab FROM key INTO wa.

or

READ TABLE itab WITH KEY ... INTO wa.
Cause:

This variant uses an implicit key consisting of all the fields of the table header that are not of numeric type (I, DECFLOAT16, DECFLOAT34 , F, or P) and whose content is not space. Declare the key explicitly instead. You could only ever use this variant with tables with a header.
In ABAP Objects, you cannot use the READ variant that lets you characterize the table using the structure of the key.

In ABAP Objects, the following statement causes an error message:

READ TABLE itab WITH KEY key INTO wa.
Cause:

The key fields of a table must always be components of the line structure.
You cannot use the READ variant in which the whole line of the table is treated as a component and the declared key value is compared to the complete line of the table in ABAP Objects.

In ABAP Objects, the following statement causes an error message:

READ TABLE itab WITH KEY = key INTO wa.
Correct syntax:

READ TABLE itab WITH KEY table_line = key INTO wa.

Cause:

This variant is a special solution that lets you access the table with unstructured line types using a key. The introduction of the pseudo-component table_line, which can always be used instead of a key field, renders this variant superfluous.
When using an explicit search key in ABAP Objects, you can only declare a column once in the READ TABLE statement.

In ABAP Objects, the following statement causes an error message:

READ TABLE itab INTO line WITH KEY col1 = ... col1 = ...
Correct syntax:

READ TABLE itab INTO line WITH KEY col1 = ...

Cause:

Only the last declaration is evaluated. Multiple declarations are unnecessary.