ABAP News for Release 7.40 – Bye, Bye MOVE and COMPUTE
With release 7.40 ABAP becomes extensively expression oriented. Besides the news I blogged about up to now, there are many new expression enabled operand positions, some new formatting options for string templates, and new built-in functions (e.g. ipow that can be used instead of **).
How do you write assignments in such an expression oriented world?
lhs = rhs.
Where rhs is
- any data object
- a functional method call
- a call of a built-in function
- an arithmetic expression
- a string expression
- a bit expression
- a constuctor expression
- a table expression
And some expression can be even lhs.
In this world there is no place for old fashioned statements MOVE and COMPUTE any more.
So it’s time to say goodbye and both are declared obsolete in the ABAP Keyword documentation
(like CALL METHOD for static method calls in Release 7.03/7.31 before).
A farewell to MOVE
You remember that one?
MOVE rhs TO lhs.
Everything you can write with MOVE you can write with the assignment operator =.
But you cannot write everything that is possible with the assignment operator with MOVE!
- You cannot MOVE constructor expressions, table expressions, arithmetic expressions, string expressions, bit expressions, and not all built-in functions.
- You cannot MOVE to LHS-expressions.
Clearly MOVE has expired …
A farewell to COMPUTE
With COMPUTE it’s another way around.
COMPUTE lhs = rhs.
You can write COMPUTE in front of each assignment with the assignment operator = and it has absolutely no effect on the statement!
You can even write
COMPUTE lhs ?= rhs.
That makes no sense!
The only assignment where COMPUTE makes sense from the literal meaning of the word is that where you have an arithmetic expression as rhs, That’s where it comes from (in stone age ABAP we had only assignments of data objects with MOVE and arithmetic calculations with COMPUTE). But nowadays it is simply superfluous to write COMPUTE in front of assignments.
Leave it away in new programs!