SAP SELECT INDICATORS ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• INDICATORS STRUCTURE SELECT INTO
• NULL INDICATORS STRUCTURE
• NOT NULL INDICATORS STRUCTURE
• INDICATORS BITFIELD SELECT INTO
• NULL INDICATORS BITFIELD
• NOT NULL INDICATORS BITFIELD

SELECT, indicators
Short Reference

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

ABAP_ALTERNATIVES:
1 ... INDICATORS $[NOT$] NULL STRUCTURE null_ind
2 ... INDICATORS $[NOT$] NULL BITFIELD null_ind
3 ... INDICATORS (indicator_syntax)

What does it do?
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 line type. It is possible to use it when existing target areas are specified, in combination with the additions CORRESPONDING FIELDS, NEW, and with inline declarations . There are two static variants that specify one of the following:
A structured indicator that is a substructure of the structured target area.
A byte field indicator that is a byte field type component of the structured target area.
A dynamic variant allows the syntax of the static variants to be specified as a dynamic token.



Latest notes:

NON_V5_HINTS
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.
ABAP_HINT_END

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

What does it do?
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 of the query.
If the addition CORRESPONDING FIELDS is not specified, the substructure must be the last component of wa or itab but can have the same name as a column of the result set.
If the addition CORRESPONDING FIELDS is specified, the substructure can be any component of wa or itab but must not have the same name as a column of the result set.
The addition INDICATORS ... STRUCTURE after an inline declaration with @DATA$|@FINAL(wa) or @DATA$|@FINAL(wa) adds a indicator structure with the name null_ind to the end of the structure or line 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.
The substructure is filled as follows:
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 set to a value that indicates whether or not the identically positioned 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 corresponding indicator value. For components of any substructures, the full name composed by the structure component selector is considered.
The indicator values are set 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 respective 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 respective components are initialized.



Latest notes:

It is recommended that the components of the null indicator have exactly the same name as the columns of the result set and that the null indicator is placed as an indicator structure behind all other components.
Work areas with indicator structures for the 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.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
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.
ABEXA 00612
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
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.
ABEXA 00613
ABAP_EXAMPLE_END

ABAP Alternative 2 ... INDICATORS $[NOT$] NULL BITFIELD null_ind

What does it do?
Specifies the byte field type component 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 component null_ind of type x. The length of null_ind must be sufficient to comprise as much bits as the number n of columns in the result set defined using the using the SELECT list. The length must be at least as calculated with ( n + 7 ) DIV 8. The position and name of the byte field must be defined in such a way that it is not affected by the assignment of data from the result set of the query.
If the addition CORRESPONDING FIELDS is not specified, the byte field must be the last component of wa or itab but can have the same name as a column of the result set.
If the addition CORRESPONDING FIELDS is specified, the byte field can be any component of wa or itab but must not have the same name as a column of the result set..
The addition INDICATORS ... BITFIELD after an inline declaration with @DATA$|@FINAL(wa) or @DATA$|@FINAL(wa) adds a condensed indicator structure with the name null_ind to the end of the structure or line structure declared inline. null_ind has type x and a length that can be calculated as with ( n + 7 ) DIV 8, where n is the number of columns in the result set.
The byte field is filled as follows:
If the addition CORRESPONDING FIELDS is not specified, the bits of the null indicator are set from left to right to a value that indicates whether or not the identically positioned column in the current row of the result set contains the null value.
If the addition CORRESPONDING FIELDS is specified, the positions of the indicator bits are mapped from left to right to the structure of the target area instead of the result set: If a a column of the result set corresponds to a component at position n of the target area, the bit at position n of the byte field is set. Only bits for components of the target area that correspond to a column of the result set are set to a indicator value. Bits for components of the target area that do not correspond to a column of the result set are always set to 0.
The indicator values are set as follows:
If the optional addition NOT is not specified, a bit value 1 means that the corresponding column contains the null value. For columns that do not contain the null value, the corresponding bits are set to 0.
If the optional addition NOT is specified, a bit value 1 means that the corresponding column does not contain the null value. For columns that contain the null value, the corresponding bits are set to 0.
Trailing excess bits of the byte field that are not covered by the above rules are always set to 0.



Latest notes:

It is recommended that the null indicator is placed as a condensed indicator structure behind all other components.
Target areas with condensed indicator structures for the null indicators can be defined with the addition ABAP Addition BITFIELD of the TYPES statement.
Bits that are always set to 0 (non-corresponding columns, excess bits) are independent from NULL or NOT NULL and how the state of the database is.
If the null indicator is not placed behind all other components, it must be included in the counting of the positions of the target area. Since the null indicator does not correspond to a column of the result set, the respective bit is set to 0.
The statement GET BIT or bit operators can be used to evaluate null indicators represented by bits.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
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. The first two columns do not contain the null value. By using NOT NULL BITFIELD, the first two bits of the condensed indicator structure null_ind are set to 1 and all other bits are 0. While its hexadecimal value C0 is not too informative, the GET BIT statement can be used to extract the positions of the columns that do not contain the null value.
ABEXA 01652
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
The executable example SELECT, Byte Field Indicators shows the difference between position-based and name-based assignments without and with CORRESPONDING FIELDS.
ABAP_EXAMPLE_END

ABAP Alternative 3 ... INDICATORS (indicator_syntax)

What does it do?
Instead of the static specifications above, 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.