report demo_class_counter .
class counter definition.
public section.
methods: set importing value(set_value) type i,
increment,
get exporting value(get_value) type i.
private section.
data count type i.
endclass.
class counter implementation.
method set.
count = set_value.
endmethod.
method increment.
add 1 to count.
endmethod.
method get.
get_value = count.
endmethod.
endclass.
data number type i value 5.
data cnt type ref to counter.
start-of-selection.
create object cnt.
call method cnt->set exporting set_value = number.
do 3 times.
call method cnt->increment.
enddo.
call method cnt->get importing get_value = number.
write number.