Ansicht
Dokumentation

ABAPSELECT_INDICATORS - SELECT INDICATORS

ABAPSELECT_INDICATORS - SELECT INDICATORS

CPI1466 during Backup   BAL Application Log Documentation  
This documentation is copyright by SAP AG.
SAP E-Book

SELECT, indicators

Short Reference



... INDICATORS ${$[NOT$] NULL STRUCTURE null_ind$}
             $| ${$[NOT$] NULL BITFIELD null_ind_bit$}
             $| (indicator_syntax) ...


Alternatives:

1. ... INDICATORS $[NOT$] NULL STRUCTURE null_ind

2. ... INDICATORS $[NOT$] NULL BITFIELD null_ind_bit

3. ... INDICATORS (indicator_syntax)

Effect

The addition INDICATORS of the INTO clause can be used to specify indicators. It is currently possible to specify a null indicator that stores information about which columns of the result set contain the null value and which do not. The addition can be specified only for importing to structured work areas wa or internal tables itab with a structured row type. It is possible to use it when existing target areas are specified, in combination with the addition NEW, and in inline declarations. There is a static variant and a dynamic variant.

Note

The addition INDICATORS is not supported by all databases. In an ABAP program, it is possible to use the method USE_FEATURES of the class CL_ABAP_DBFEATURES to check whether the current database system or a database system accessed using a secondary connection supports the use of this addition. This requires the constant INDICATORS of this class to be passed to the method in an internal table.

Alternative 1

... INDICATORS $[NOT$] NULL STRUCTURE null_ind


Effect

Specifies the substructure null_ind of a structured target area specified in the INTO clause as a null indicator.

  • After a specified existing work area wa or existing internal table itab, this must contain a substructure with the name null_ind as a component. The substructure must contain at least as many components as the number of columns in the result set defined using the SELECT list. These may also be components of other substructures. Each component must be of type x or c with length 1. The position and name of the substructure must be defined in such a way that it is not affected by the assignment of data from the result set for the query.
  • The addition INDICATORS after an inline declaration with @DATA(wa) or @DATA(itab) adds a substructure with the name null_ind to the end of the structure or row structure declared inline. For each column in the result set, this substructure contains an identically named component of type x and length 1 in the same order. If preceding components of the structure declared inline are substructures, the substructure null_ind is also structured accordingly. The name null_ind must not be used as the name of a column in the result set.

If the addition CORRESPONDING FIELDS is not specified, the names of the components of the null indicator are ignored. From left to right, they are given an ID that indicates whether or not the identically named column in the current row of the result set contains the null value. Nested structures are broken down into their elementary components. If the addition CORRESPONDING FIELDS is specified, a component with the same name must exist in the null indicator for each component of wa or itab supplied with data and this is filled with the associated ID. For components of any substructures, the entire composite name created using the structure component selector is respected. The IDs are as follows:

  • If the optional addition NOT is not specified, the component value hexadecimal 1 for type x and "X" for type c mean that the corresponding column contains the null value. For columns that do not contain the null value, the associated components are initialized.
  • If the optional addition NOT is specified, the component value hexadecimal 1 for type x and "X" for type c mean that the corresponding column does not contain the null value. For columns that contain the null value, the associated components are initialized.

Notes

  • It is recommended that the components of the null indicator have exactly the same name as the columns of the result set.
  • Work areas with null indicators can be defined with the addition INDICATORS of the TYPES statement.
  • If wa or the row structure of itab contains further substructures besides the null indicator, it does not make sense to use CORRESPONDING FIELDS and the null indicator should also be constructed accordingly.
  • When the addition NOT is not used, the entire null indicator is initial if no column of the result set contains the null value and when the addition NOT is used, the entire null indicator is initial if all columns of the result set contain the null value. This can be checked in a single logical expression.

Example

The third column of the result set of the SELECT statement contains the null value because the WHEN condition of the CASE expression is false and no ELSE is specified. Accordingly, component z of substructure wa-null_ind contains the value hexadecimal 1.

Example

The internal table itab declared inline contains an elementary column carrname, a substructure spfli, which is structured like the DDIC database table SPFLI, and a substructure nulls. The substructure nulls also contains an elementary column carrname and a substructure spfli. However, the components are all of type x with length 1.

Alternative 2

... INDICATORS $[NOT$] NULL BITFIELD null_ind_bit


Effect

Specifies the bit field null_ind_bit of a structured target area specified in the INTO clause as a null indicator. The bit field can have a greater length than 8. Excess bits are always set to 0 irrelevant of whether the indicators are selected with NULL or NOT NULL and how the state of the database is. The bits are written in a way so that GET BIT statements can be used to read the bit at the bit position. The addition can also be used with the statements INTO CORRESPONDING ..., INTO DATA ..., INTO NEW ....

Notes

Consider the following characteristics when the statement is used with the addition INTO CORRESPONDING ...:

  • null_ind_bit need not be positioned at the end of the statement. It can also be positioned in the middle of the statement.
  • null_ind_bit cannot correspond to a regular field.
  • Bits of non-corresponding fields are always set to 0 irrelevant of whether the indicators are selected with NULL or NOT NULL and how the state of the database is.
  • If a field in position i1 corresponds to a field in position i2, the bit is set in position i2, i. e. it is the bit you get with GET BIT i2 .... Note that a field in position i1 can also correspond to a field that is positioned after null_ind_bit. Then, null_ind_bit must be included in the counting of the positions.

Example

The third column of the result set of the SELECT statement contains the null value because the WHEN condition of the CASE expression is false and no ELSE is specified. Accordingly, the position of the component z in the bit field wa-null_ind_bit contains the value hexadecimal 1. The example includes multiple GET BIT statements.

Alternative 3

... INDICATORS (indicator_syntax)


Effect

Instead of the static specification, a parenthesized data object indicator_syntax can be specified after INDICATORS. This data object must contain the syntax shown for the static specification when the statement is executed. The data object indicator_syntax can be a character-like data object or a standard table with a character-like row type. The syntax in indicator_syntax is not case-sensitive. When an internal table is specified, the syntax can be distributed across multiple rows. Invalid syntax raises a catchable exception from the class CX_SY_DYNAMIC_OSQL_ERROR. If the content of indicator_syntax is initial, the addition INDICATORS is ignored. See SQL Injections Using Dynamic Tokens.

Example

Like the example for a static specification, but the null indicator is specified dynamically in this case. For this reason, inline declarations cannot be used without the addition NEW and a suitable structure must be defined. Because NOT is specified, the character-like components x and y of the null indicator are filled with "X".

Example

Like the preceding example but with the addition NEW. An inline declaration can be used here.






CL_GUI_FRONTEND_SERVICES - Frontend Services   BAL Application Log Documentation  
This documentation is copyright by SAP AG.

Length: 12299 Date: 20240425 Time: 083202     sap01-206 ( 235 ms )