This post talks about an interesting addition to the way structures are declared.
Indicator Structures
The new addition INDICATORS is available while a type is defined using the statement TYPES. The indicator structure is a substructure of a given type. The indicator structure has the same components as the original structure but all of the fields have type x of length 1.
If this sounds confusing, let us look at a code sample.

"Code in text format
CLASS zcl_abap740_samples DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
ENDCLASS.
CLASS zcl_abap740_samples IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
TYPES:
BEGIN OF demo_type,
field1 TYPE i,
field2 TYPE zjp_char2,
field3 TYPE string,
field4 TYPE REF TO i,
BEGIN OF field5,
col1 TYPE i,
col2 TYPE zjp_char2,
END OF field5,
END OF demo_type.
TYPES demo_ind_type TYPE demo_type WITH INDICATORS ind.
DATA demo_ind TYPE demo_ind_type.
out->write( demo_ind ).
ENDMETHOD.
ENDCLASS.
Execute the class and the console will show the below output. The part enclosed in red is coming from the addition WITH INDICATORS
.

For comparison, if we remove the addition from the code the console shows the below output.

Let us also look at simplified and clean view with debug mode.

How to use the INDICATORS statement?
An indicator structure can be used as an ‘ABAP SQL indicator’ in ABAP SQL read and write statements. The code below shows an example of updating only one field i.e. price
TYPES wa TYPE sflight WITH INDICATORS ind.
DATA itab TYPE TABLE OF wa WITH EMPTY KEY.
SELECT carrid, connid, fldate, price
FROM sflight
WHERE carrid = char`LH` AND
connid = numc`0400` AND
fldate = @( cl_demo_date_time=>get_user_date( ) )
INTO CORRESPONDING FIELDS OF TABLE @itab.
IF sy-subrc = 0.
LOOP AT itab ASSIGNING FIELD-SYMBOL(<wa>).
<wa>-price *= '0.8'.
<wa>-ind-price = '01'. "Set up the indicator
ENDLOOP.
UPDATE sflight FROM TABLE @itab INDICATORS SET STRUCTURE ind.
ENDIF.
Credit: https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/abaptypes_indicators.htm
TYPE addition for INDICATORS
If you prefer, Boolean type instead of type X, then code similar to below can be used.
TYPES ind_wa TYPE demo_update WITH INDICATORS col_ind
TYPE abap_bool.
DATA ind_tab TYPE TABLE OF ind_wa.
ind_tab = VALUE #(
( id = 'D' col4 = 4000 col_ind-col4 = abap_true )
( id = 'E' col4 = 5000 col_ind-col4 = abap_true ) ).
UPDATE demo_update FROM TABLE @ind_tab
INDICATORS SET STRUCTURE col_ind.
Alternative with dynamic programming
FINAL(indicator_syntax) = 'SET STRUCTURE col_ind'.
UPDATE demo_update FROM @ind_wa INDICATORS (indicator_syntax).
Even though this alternative is available, it is not recommended as if may cause a security risk.
Read about more such ABAP expressions and exciting new syntaxes: ABAP Expressions (7.4+)
If you like the content, please subscribe…
Hey Man,
It’s great to have you back. We missed your great posts.
Regards from México..
LikeLike