Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing Internal Data →  Internal Tables →  Expressions and Functions for Internal Tables →  table_exp - Table Expressions 

table_exp - default

Other versions: 7.31 | 7.40 | 7.54

Syntax


... OPTIONAL|{DEFAULT def} ... 

Effect

Specifies a default value for table rows not found. if the type of the result of a table expression table_exp is controlled using the value operator VALUE or the reference operator REF, a default value can be specified after the table expression:

  • OPTIONAL is used to specify a data object with the data type of the expression with initial content.
  • DEFAULT def is used to specify a data object def that must be convertible to the data type of the expression. def is a general expression position.

If the row itab_line specified in the table expression is not found, an exception of the class CX_SY_ITAB_LINE_NOT_FOUND is not raised if a default value is specified and the table expression returns the default value instead. A data object def that is not compatible with the data type of the result of the expression is converted to this data type in accordance with the conversion rules.

If the argument of VALUE or REF is a single table expression, the default value applies to a single row in the table in question. If the argument is a chaining of table expressions, the default value applies to the result of the chaining (namely how it ends on the right, expressing either a structure component or a table row). A default value specified explicitly must match the result of the chaining accordingly. When a default value is specified for a chaining, the first exception for a missing row across the entire chaining is caught and the default value is returned as a result.


Notes

  • Alongside the functions line_exists and line_function, a characteristic default value specified for missing rows also enables the existence of rows to be checked without catching an exception or checking the return value after the statement ASSIGN.

  • A default value def specified after DEFAULT can itself be a table expression with default value. This enables alternative searches to be performed within an expression.

  • There is no operator for the default behavior of a table expression in which the result is usually a temporary field symbol, which means that no default value can be specified here.

Continue

Table Expressions, Default Value - Example