REPORT YSUBDEL1 LINE-SIZE 120.
TYPES : BEGIN OF TYP_TAB ,
NAME(15) TYPE C ,
AGE TYPE I ,
END OF TYP_TAB .
DATA : num1 type i value 5 .
CLASS c1 DEFINITION .
public section.
methods : meth1 .
DATA : l_num like num1 ,
it_tab type standard table of typ_tab ,
w_tab like line of it_tab.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
method : meth1 .
data : l_cnum(2) type c.
l_num = 0.
do 5 times.
l_num = l_num + 1.
l_cnum = l_num.
concatenate 'Student-'
l_cnum
into w_tab-name.
w_tab-age = num1 * l_num .
append w_tab to it_tab.
clear w_tab.
enddo.
loop at it_tab into w_tab.
write:/5 w_tab-name ,
w_tab-age.
endloop.
endmethod.
endclass.
START-OF-SELECTION.
DATA : obj1 type ref to c1.
create object : obj1.
call method obj1->meth1.
Output
Student-1 5
Student-2 10
Student-3 15
Student-4 20
Student-5 25
TYPES : BEGIN OF TYP_TAB ,
NAME(15) TYPE C ,
AGE TYPE I ,
END OF TYP_TAB .
DATA : num1 type i value 5 .
CLASS c1 DEFINITION .
public section.
methods : meth1 .
DATA : l_num like num1 ,
it_tab type standard table of typ_tab ,
w_tab like line of it_tab.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
method : meth1 .
data : l_cnum(2) type c.
l_num = 0.
do 5 times.
l_num = l_num + 1.
l_cnum = l_num.
concatenate 'Student-'
l_cnum
into w_tab-name.
w_tab-age = num1 * l_num .
append w_tab to it_tab.
clear w_tab.
enddo.
loop at it_tab into w_tab.
write:/5 w_tab-name ,
w_tab-age.
endloop.
endmethod.
endclass.
START-OF-SELECTION.
DATA : obj1 type ref to c1.
create object : obj1.
call method obj1->meth1.
Output
Student-1 5
Student-2 10
Student-3 15
Student-4 20
Student-5 25
No comments:
Post a Comment