<-- previous rule | overview | next rule -->
Aligns assignments to the same object, e.g. to various components of the same structure.
This rule is part of the essential profile, as it is explicitly demanded by the Clean ABAP Styleguide.
- Align across empty lines
- Align across comment lines
METHOD align_assignments_to_same_obj.
ro_instance->mv_name = iv_name.
ro_instance->mv_id = iv_id.
ro_instance->mv_price = iv_price.
ls_struc-component = 1.
ls_struc-comp2 = 'a'.
ls_struc-start_date+6(2) = 31.
ls_struc-c3 = VALUE #( ).
<ls_field_symbol>-component = 1.
<ls_field_symbol>-comp2 = 'a'.
<ls_field_symbol>-c3 = VALUE #( ).
" alignment across comments and empty lines (depending on configuration):
ls_struc-component += 1.
"comment
ls_struc-comp2 = 'a'.
ls_struc-c3 = VALUE #( ).
" comment
ls_struc-comp4 -= 1.
ENDMETHOD.
Resulting code:
METHOD align_assignments_to_same_obj.
ro_instance->mv_name = iv_name.
ro_instance->mv_id = iv_id.
ro_instance->mv_price = iv_price.
ls_struc-component = 1.
ls_struc-comp2 = 'a'.
ls_struc-start_date+6(2) = 31.
ls_struc-c3 = VALUE #( ).
<ls_field_symbol>-component = 1.
<ls_field_symbol>-comp2 = 'a'.
<ls_field_symbol>-c3 = VALUE #( ).
" alignment across comments and empty lines (depending on configuration):
ls_struc-component += 1.
"comment
ls_struc-comp2 = 'a'.
ls_struc-c3 = VALUE #( ).
" comment
ls_struc-comp4 -= 1.
ENDMETHOD.