REPORT ZBC400_00_COMPUTE PARAMETER pa_int1 TYPE pa_int2 TYPE pa_op TYP

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
REPORT ZBC400_00_COMPUTE.
PARAMETER:
pa_int1 TYPE i,
pa_int2 TYPE i,
pa_op TYPE c.
DATA result TYPE P DECIMALS 2.
DATA lv_has_error TYPE BOOLEAN VALUE abap_false.
CASE pa_op.
WHEN '+'.
result = pa_int1 + pa_int2.
WHEN '-'.
result = pa_int1 - pa_int2.
WHEN '*'.
result = pa_int1 * pa_int2.
WHEN '/'.
if NOT pa_int2 = 0.
result = pa_int1 / pa_int2.
ELSE.
WRITE 'Деление на ноль'.
result = 0.
EXIT.
ENDIF.
WHEN OTHERS.
WRITE 'Не корректная операция'.
result = 0.
EXIT.
ENDCASE.
WRITE : pa_int1, pa_op, pa_int2, '=', result.