-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathZCL_20_COMPUTE
50 lines (41 loc) · 1.34 KB
/
ZCL_20_COMPUTE
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
CLASS zcl_20_compute DEFINITION PUBLIC FINAL CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun .
PROTECTED SECTION.
PRIVATE SECTION.ENDCLASS.
CLASS zcl_20_compute IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
* Declarations**************************
DATA number1 TYPE i.
DATA number2 TYPE i.
DATA result TYPE p LENGTH 8 DECIMALS 2.
DATA op TYPE c LENGTH 1.
data output type string.
* Input Values**************************
number1 = -8.
number2 = 2.
op = '/'.
* Calculation************************** *
if op = '/'.
try.
result = number1 / number2.
output = |{ number1 } / { number2 } = { result }|.
catch cx_sy_zerodivide.
output = 'Division by zero'.
endtry.
elseif op = '*'.
result = number1 * number2.
output = |{ number1 } * { number2 } = { result }|.
elseif op = '+'.
result = number1 + number2.
output = |{ number1 } + { number2 } = { result }|.
elseif op = '-'.
result = number1 - number2.
output = |{ number1 } - { number2 } = { result }|.
else.
output = 'Kein richtiger operator vorhanden'.
endif.
* Output**************************
out->write( output ).
ENDMETHOD.
ENDCLASS.