forked from brandoncaulfield/youtube-abap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aab6a9f
commit c13e082
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
CLASS lcl|_reduce_test DEFINITION CREATE PRIVATE FINAL. | ||
|
||
PUBLIC SECTION. | ||
|
||
CLASS-METHODS: create | ||
RETURNING | ||
VALUE(ro_obj) TYPE REF TO lcl|_reduce_test. | ||
METHODS: run. | ||
PROTECTED SECTION. | ||
PRIVATE SECTION. | ||
ENDCLASS. | ||
CLASS lcl|_reduce_test IMPLEMENTATION. | ||
|
||
METHOD create. | ||
ro_obj = NEW lcl|_reduce_test( ). | ||
ENDMETHOD. | ||
METHOD run. | ||
DATA lt_test TYPE TABLE OF i WITH EMPTY KEY. | ||
lt_test = VALUE #( FOR j = 1 WHILE j <= 10 ( j ) ). | ||
cl_demo_output=>new( | ||
)->next_section( |Simple Sum| )->write( | ||
REDUCE i( INIT s = 0 | ||
FOR i = 1 UNTIL i > 10 | ||
NEXT s = s + i ) | ||
)->next_section( |String concatenation| )->write( | ||
REDUCE string( INIT text = |Count down:| | ||
FOR i = 10 THEN i - 1 UNTIL i = 0 | ||
NEXT text = text && | { i }| ) | ||
)->next_section( |Table Example| )->write( | ||
lt_test | ||
)->next_section( |Table Reduction using REDUCE| )->write( | ||
REDUCE i( INIT x = 0 | ||
FOR ls_test IN lt_test | ||
NEXT x = x + ls_test ) | ||
)->display( ). | ||
ENDMETHOD. | ||
ENDCLASS. | ||