Use value assignments to change the value of variables.

In ABAP, the operator for value assignments is a simple equals sign ( = ). The variable on the left-hand side is filled with the value of the expression on the right-hand side.

The simplest possible expression is a single data object, for example, a literal or another variable. However, ABAP supports more sophisticated expressions like the arithmetic expression in the example above.

### Resetting Variables

The CLEAR statement resets the content of a data object to the type-related initial value. For detailed information about the initial values for a particular type, refer to the keyword documentation for the CLEAR statement.

### Arithmetic Calculations

Arithmetic expressions are ABAP expressions with a combination of value, operators, and functions that the runtime system processes to calculate a result. For arithmetic expressions the result type depends on the type of the operands used as input to the expression.

You can use an arithmetic expression in any reading operand position, for example, the right-hand side of the value assignment.

The first example is a simple addition. The contents of amount1 and amount2 are added together and the results placed in variable total.

The second example is a bit more sophisticated. Before adding them, the contents of amoun1 and amount2 are weighed with factors 2 and 3. The result of this addition is then divided by 5 to calculate a weighted average.

The basic arithmetic ABAP provides the operators + for addition, - for subtraction * for multiplication and / for division. Additionally, you can use the operators DIV for whole-number division and MOD for the whole-number remainder of a division. Thus, 6 DIV 4 is 1 and 6 MOD 4 is 2.

ABAP has a range of built-in functions for various tasks. Many of these are used for string processing, but here you can see some examples for numeric functions. You use sqrt( ) function to pull the square root and ipow( ) function to raise a number to a whole-numbered power.

In complex expressions involving more than one operator, multiplication and division take precedence over addition and subtraction. Expressions with identical precedence are processed left to right.

ABAP syntax requires at least one blank between operators and operands. 1 + 1 is correct. 1+1 leads to a syntax error.

Blanks are also needed after opening brackets and before closing brackets.