Ansicht
Dokumentation

ABENTABLE_EXP_OPTIONAL_DEFAULT - TABLE EXP OPTIONAL DEFAULT

ABENTABLE_EXP_OPTIONAL_DEFAULT - TABLE EXP OPTIONAL DEFAULT

TXBHW - Original Tax Base Amount in Local Currency   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.
SAP E-Book

- default

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

Effect

Specifies a default value for table lines not found. If the type of the result of a table expression table_exp is defined using the value operator VALUE or the reference operator REF, a default value can be specified after the table expression. If the line 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 result is determined by the default value instead.

  • OPTIONAL
  • If VALUE is used, the default value is an initial data object with the data type of the table expression.

  • If REF is used, the default value is an initial reference variable with the static type of the table expression.

  • DEFAULT
  • If VALUE is used, the default value is specified using a data object def, which must be convertible to the data type of the table expression, If def is not compatible with the data type of the result of the expression, a conversion is made to this data type in accordance with the conversion rules.

  • If REF is used, the default value is specified using a reference variable def, whose static type is the data type of the table expression.

def is a general expression position.

If the argument of VALUE or REF is a single table expression, the default value applies to a single line in the corresponding table. If the argument is a chaining of table expressions, the default value applies to the result of the chaining, that is, to its right end, which can express a structure component or a table line. 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 line across the entire chaining is caught and the default value is returned as a result.

Notes

  • In addition to the functions line_exists and line_function, a characteristic default value specified for missing lines also enables the existence of lines 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.

Example

If no line of the specified key is found, the table expression returns a line in which the component carrid has the value "NUL" and all other components are initial.

Example

This example demonstrates the difference between specifying the default value for the value operator VALUE and the reference operator REF. Once this source code section is executed, var1 is an initial structure with the type SCARR and dref1 is an initial reference variable with the static type of this structure. The reference variable dref1 does not point to an initial structure. In the case of the default value specified using DEFAULT, a reference variable must be specified for REF. This is done here using the instance operator NEW, not VALUE.

Table Expressions, Default Value






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

Length: 4926 Date: 20240426 Time: 033832     sap01-206 ( 96 ms )