Ansicht
Dokumentation

ABENTABLE_EXP_ITAB_LINE - TABLE EXP ITAB LINE

ABENTABLE_EXP_ITAB_LINE - TABLE EXP ITAB LINE

RFUMSV00 - Advance Return for Tax on Sales/Purchases   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.
SAP E-Book

- itab_line

... ${ $[KEY keyname INDEX$] idx $}
 $| ${ comp1 = operand1 comp2 = operand2 ...  $}
  $| ${ KEY keyname $[COMPONENTS$] ${comp_name1$|(name1)$} = operand1
                               ${comp_name2$|(name2)$} = operand2
                                ... $} ...


Alternatives:

1. ... $[KEY keyname INDEX$] idx

2. ... comp1 = operand1 comp2 = operand2 ...

3. ... KEY keyname $[COMPONENTS$] ...

Effect

Specifies a table line in the square brackets of a table expression. The three alternatives are possible:

  • Index read
  • Read using a free key
  • Read using a table key

Table Expressions, Specified Lines

Alternative 1

... $[KEY keyname INDEX$] idx


Effect

The table expression reads the line with the line number specified in idx with respect to a table index. The line is read in exactly the same way as when specifying an index INDEX idx [USING KEY keyname] in the statement READ TABLE. Similarly, idx is a numeric expression position and the optional KEY keyname INDEX is equivalent to the USING KEY keyname specified here. If the optional addition is not used, itab must be an index table. If the addition is used, the secondary table index of a sorted secondary key can be specified statically or dynamically.

If no line exists for the specified index, the catchable exception CX_SY_ITAB_LINE_NOT_FOUND is usually raised. The attributes KEY_NAME and KEY_COMP_VALUES are not filled here. Exceptions to this rule are when a start value is specified, uses in the statement ASSIGN, in the predicate function line_exists, and in the table function line_index.

Example

Reading of the line with the line number 1 once using the secondary table key skey and twice using the primary table key. It is the third line once and the first line twice.

Alternative 2

... comp1 = operand1 comp2 = operand2 ...


Effect

The table expression reads the line in accordance with the specified free search key. The search is performed in exactly the same way as when specifying the free search key comp1 = operand1 comp2 = operand2 ... in the statement READ TABLE. Similarly, the components comp1 comp2 ... can be specified in accordance with the rules from the section Specifying Components and compatible or convertible operands operand1 operand2 ... must be specified that are general expression positions.

If no line is found for the specified free key, the catchable exception CX_SY_ITAB_LINE_NOT_FOUND is usually raised. The attributes KEY_NAME and KEY_COMP_VALUES are not filled here. Exceptions to this rule are when a start value is specified, uses in the statement ASSIGN, in the predicate function line_exists, and in the table function line_index.

Notes

  • If the free key overlaps with some or all of the primary table key, the optimizations described under READ TABLE are performed when sorted tables and hashed tables are read.
  • Unlike the statement READ TABLE with a free key specified, no binary searches can be forced for a table expression and it is not possible to specify explicit table key for optimizing searches using secondary keys.

Example

Reading of a line in an internal table using a free specified key.

Alternative 3

... KEY keyname $[COMPONENTS$] ...


Effect

The table expression reads the line in accordance with the explicitly specified table key.

  • Generally, the search is performed in exactly the same way as when specifying the table key WITH TABLE KEY $[keyname COMPONENTS$] ... in the statement READ TABLE. The table key must be covered completely by specifying components and no components can be specified that are not part of the table key.
  • If the table expression is specified as an argument of the predicate function line_exists or of the table function line_index, the search is performed as when specifying a free search key WITH KEY keyname COMPONENTS ... in the statement READ TABLE and the key is linked to a table key. A sorted table key does not have to be covered completely by specified components. For both categories of secondary keys, components can be specified that are not part of the table key.

Unlike the statement READ TABLE, a table expression must specify the name of the table key and the addition COMPONENTS can be omitted. Like here, the table key keyname and the key components can be specified statically or dynamically. The operands operand1 operand2 ... are general expression positions.

If no line is found for the specified table key, the catchable exception CX_SY_ITAB_LINE_NOT_FOUND is usually raised. The attributes KEY_NAME and, if the table is not empty, KEY_COMP_VALUES are not filled here. Exceptions to this rule are when a start value is specified, uses in the statement ASSIGN, in the predicate function line_exists, and in the table function line_index.

Notes

  • Searches using the primary table key do not have to specify it explicitly. Instead, the variant with a free search key can be used. If this covers the primary table key, it is used for optimized reads on sorted tables and hashed tables.
  • In order to use the primary table key in this variant explicitly, the key must be specified using its predefined name primary_key or an alias name.
  • The differing behavior of the specified key outside and inside the functions line_exists and line_index is explained as follows:
  • Outside the functions, the main purpose of an explicitly specified table key is to read exactly one completely specified line.

  • Within the functions, the existence of a specified line that is not necessarily specified completely or, for example, a line number as the starting point of a subsequent sequential read using LOOP ... FROM is to be determined as efficiently as possible.

Example

Reading of a line in an internal table by specifying the primary table key.






General Data in Customer Master   General Data in Customer Master  
This documentation is copyright by SAP AG.

Length: 11183 Date: 20240329 Time: 103216     sap01-206 ( 165 ms )