-
Notifications
You must be signed in to change notification settings - Fork 1
/
ZCL_20_ITERATE
40 lines (32 loc) · 1.08 KB
/
ZCL_20_ITERATE
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
CLASS zcl_20_iterate DEFINITION PUBLIC FINAL CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun .
PROTECTED SECTION.
PRIVATE SECTION.ENDCLASS.
CLASS zcl_20_iterate IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
CONSTANTS max_count TYPE i VALUE 20.
DATA numbers TYPE TABLE OF i.
DATA output TYPE TABLE OF string.
DO max_count TIMES.
CASE sy-index.
WHEN 1.
APPEND 0 TO numbers.
WHEN 2.
APPEND 1 TO numbers.
WHEN OTHERS.
APPEND numbers[ sy-index - 2 ]
+ numbers[ sy-index - 1 ]
TO numbers.
ENDCASE.
ENDDO.
DATA(counter) = 0.
LOOP AT numbers INTO DATA(number).
counter = counter + 1.
APPEND |{ counter WIDTH = 4 }: { number WIDTH = 10 ALIGN = RIGHT }|
TO output.
ENDLOOP.
out->write( data = output
name = |The first { max_count } Fibonacci Numbers| ) .
ENDMETHOD.
ENDCLASS.