SAP TYPES INDICATORS ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• WITH INDICATORS TYPES
• AS BITFIELD WITH INDICATORS

TYPES, INDICATORS
Short Reference

ABAP_SYNTAX
TYPES dtype TYPE struct WITH INDICATORS ind $[${TYPE type$}
$| ${AS BITFIELD$}$].

ABAP Addition
1 ... TYPE type
2 ... AS BITFIELD

What does it do?
Derivation of a structured data type with an indicator structure with the name ind. For struct, an existing local or global structured type must be specified. For ind, a name must be specified that follows the naming conventions.
This variant of the statement TYPES defines a structured data type that has the same components as the structured type struct specified behind TYPE, as well as an additional last component named ind as an indicator structure. The last component ind is one of the following:
An actual indicator structure realized by a substructure that contains the same number of first-level components as struct, in the same order as in struct and with the same names as in struct. The data type of each component is x of length 1 by default and can be defined explicitly with the optional addition TYPE.
A condensed indicator structure realized by a byte field of type x with enough bits for each component of struct. A condensed indicator structure is defined with the addition AS BITFIELD.



Latest notes:

The main purpose of an indicator structure is to serve as an ABAP SQL indicator. The addition WITH INDICATORS facilitates the definition of null indicators or set indicators for ABAP SQL statements. This is especially important for the UPDATE statement with the addition INDICATORS, since no inline declarations can be used there. Only actual indicator structures can be used with UPDATE and no condensed indicator structures.
The components of an actual indicator structure are created for each first-level component of struct independent of its type. This means that substructures, reference variables or tabular components of struct are handled in the same way as elementary components and are mirrored by one indicator of type x or the type defined with addition TYPE. Likewise, each component of struct is represented by a single bit of a condensed indicator structure independent from its type.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The structured type ind_struct has the same components with the same types as struct plus an additional substructure named ind. The substructure ind has the same components col1 to col11 as struct but all of them have type x of length 1.
ABEXA 01561
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
An internal table that has a line structure with an indicator structure is partly filled with today's flight data for a given flight connection from the DDIC database table SFLIGHT. In the internal table, the price is reduced by 80 %. The modified table is used to update the respective date in the database table. While the lines that are to be updated are selected by the content of key fields in the internal table, the column to be updated is indicated by marking the column PRICE of the indicator structure. Without using the INDICATORS addition of the UPDATE statement, all other non-key columns of the database table would be initialized since their values are initial in the internal table.
ABEXA 01461
ABAP_EXAMPLE_END

ABAP Addition

What does it do?
Definition of the data type of each component of an actual indicator structure ind. The same applies to type as to TYPES ... TYPE abap_type and TYPES ... TYPE. Each non-generic local or global data type that is visible at the current position can be specified. The generic built-in ABAP types c, n, p, and x can also be specified and their standard length is used implicitly then,.



Latest notes:

For ABAP SQL indicators, only the types c and x of length 1 are relevant.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The structured type ind_struct has the same components with the same types as struct plus an additional substructure named ind. The substructure ind has the same components col1 to col11 as struct but all of them have type itab that is a table type with line type i.
ABEXA 01753
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
See examples for UPDATE ... FROM ... INDICATORS.
ABAP_EXAMPLE_END

ABAP Addition

What does it do?
Defines ind as a condensed indicator structure that is a byte field of type x . The length of the byte field is calculated from the number of components n in struct as with ( n + 7 ) DIV 8.



Latest notes:

The length of ind is derived in such a way that it contains enough bits to serve as indicators for the components of struct. The first bit should serve as indicator for the first component, the second bit should serve as indicator for the second component and so on.
The bits can be set by function bit-set , statement SET BIT or more commonly by ABAP ABAP Alternative 2@2@> INDICATORS BITFIELD. For evaluating indicators represented by bits, the statement GET BIT or bit operators can be used.
A condensed indicator structure needs less space than an actual indicator structure, while the latter can be handled more comfortably.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The structured type ind_struct has the same components with the same types as struct plus an additional component ind of type x with length 2. The first 11 bits of that byte field can serve as indicators for the components col1 to col11 of struct.
ABEXA 01754
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
The structure wa_ind has a condensed indicator structure null_ind that is used as a null indicator in a SELECT statement. It has length of 6 and thus consists of 48 bits that cover the 44 fields of database table DEMO_EXPRESSIONS used for declaring wa_ind. The three columns num1, fltp1, and char1 of the result set of the SELECT statement contain the null value because the WHEN conditions of the CASE expressions are false and no ELSE is specified. Since the addition INTO CORRESPONDING is used, the positions of the bits of the null indicator correspond to the positions of the components of the target area that correspond to the columns of the result set. Accordingly, the third, the tenth and the sixteenth bit of the byte field wa_ind-null_ind have the value 1. While its hexadecimal value 204100000000 is not too informative, the GET BIT statement can be used to extract the positions of the columns that contain the null value.
ABEXA 01653
ABAP_EXAMPLE_END

Return to menu