Joke Collection Website - Bulletin headlines - SAP ABAP operator

SAP ABAP operator

ABAP provides manipulated variable with a rich set of operators. All ABAP operators fall into four categories:

0 1- arithmetic operator

02- Comparison Operator

03- Bitwise Operator

04 string operator

Arithmetic operators are used in mathematical expressions in the same way as in algebra. The following table describes arithmetic operators. Suppose the integer variable A holds 20 and the variable B holds 40.

Examples of arithmetic operators:

Various types of comparison operators with different operands

Note-If the data types or lengths of variables do not match, automatic conversion will be performed. When comparing two values of different data types, automatic type adjustment is performed on one or both values. The conversion type is determined by the data type and the preferred order of data types.

The following is the order of automatic conversion:

? If one field belongs to type I, the other field will be converted to type I.

? If one field is of type P, the other field will be converted to type P..

? If the type of one field is D, the other field will be converted to D. However, the types of C and N will not be converted, but will be compared directly. Similar to the t-type situation.

? If one field is of type n and the other is of type c or x, both fields are converted to type p.

? If one field is of type C and the other is of type X, then type X will be converted to type C..

Example of comparison operator 1:

Example of comparison operator 1:

ABAP also provides a series of bitwise logical operators that can be used to construct Boolean algebraic expressions. Use parentheses to combine bitwise operators in complex expressions.

For example, the following is a truth table that shows the values generated when boolean AND, or, or XOR operators are applied to the two-bit values contained in field A and field B. ..

Description:

1. (Bit NOT) NOT gate: inverts the high and low states of the input. The logical function is expressed as F = A'.

2. Bit and AND gate: When all inputs are high, there will be a high output. The logical function is expressed as f = a * b.

3. Bit or gate: Only when all inputs are low, the output will be low. The logical function is expressed as f = a+b.

4. XOR (bit XOR) NOR gate: When all inputs are low, there will be output high. The logical function is expressed as F =(A+B).

Example: