Skip to content

Latest commit

 

History

History
87 lines (58 loc) · 2.7 KB

MoveToRule.md

File metadata and controls

87 lines (58 loc) · 2.7 KB

<-- previous rule | overview | next rule -->

Replace obsolete MOVE ... TO with =

Replaces obsolete MOVE ... TO and MOVE ... ?TO statements with the more general assignment operators = and ?=.

This rule is part of the essential profile, as it is explicitly demanded by the Clean ABAP Styleguide.

References

Options

  • Unchain MOVE: chains (required for processing them with this rule)

Examples

  METHOD replace_obsolete_move_to.
    MOVE 1 TO ev_result.
    MOVE 'ab' TO es_result-text.
    MOVE '12' TO ev_start+4(2).

    MOVE get_next_date( iv_year   = iv_year
                        iv_period = iv_period ) TO ev_date.

    MOVE lo_source ?TO lo_dest.

    MOVE EXACT source TO dest.

    MOVE:
      " some comment
      1 TO ev_value,
      '2023' TO ev_start(4),

      " another comment
      EXACT iv_data TO ev_data,
      io_instance ?TO eo_instance.

    " with the MOVE chain, get_next_value( ) is also called 3 times,
    " but without the chain, that's much clearer:
    MOVE get_next_value( ) TO: ev_any, ev_other, ev_third.
  ENDMETHOD.

Resulting code:

  METHOD replace_obsolete_move_to.
    ev_result = 1.
    es_result-text = 'ab'.
    ev_start+4(2) = '12'.

    ev_date = get_next_date( iv_year   = iv_year
                             iv_period = iv_period ).

    lo_dest ?= lo_source.

    dest = EXACT #( source ).

    " some comment
    ev_value = 1.
    ev_start(4) = '2023'.

    " another comment
    ev_data = EXACT #( iv_data ).
    eo_instance ?= io_instance.

    " with the MOVE chain, get_next_value( ) is also called 3 times,
    " but without the chain, that's much clearer:
    ev_any = get_next_value( ).
    ev_other = get_next_value( ).
    ev_third = get_next_value( ).
  ENDMETHOD.

Related code