REPORT YSUBOOPS17 .
class class1 definition.
public section.
methods : method1 .
endclass.
class class2 definition.
public section.
methods : method2 .
endclass.
class class1 implementation.
method :method1.
data : i_num type i value 2.
write:/5 i_num.
endmethod.
endclass.
class class2 implementation.
method : method2.
data : obj1 type ref to class1.
create object obj1.
call method obj1->method1.
endmethod.
endclass.
start-of-selection.
data : my_obj type ref to class2.
create object : my_obj.
call method my_obj->method2.
Output 2
Welcome To My BLOG
This site is to give a brief idea for the abap learners who are looking for some real time programs .It consists of collection of programs from my side . I hope these programs are very much used for all of the learners. Please check the links for any information in ABAP.
Please vote for my Blog. And please input me on this mail addrssess.Email me
Please vote for my Blog. And please input me on this mail addrssess.Email me
Share this link with your friends
http://www.rebtel.com/u/15163104576
Monday, December 13, 2010
OOPS:sampel program with local classes
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
ABAP - Printing Selection Screen Data On The Report Output.
This is possible by using the function module PRINT_SELECTIONS .
Check this example for printing the data on the selection screen , You need to call this function module after writing the data in report .
report ztests.
types: begin of t_varinfo,
flag type c,
olength type x,
line like raldb-infoline,
end of t_varinfo.
parameters: p_test(20) type c ,
p_test1 type i,
p_test2 type i .
data:tables type TRDIR-NAME occurs 0 with header line ,
infotab type t_varinfo occurs 0 with header line.
start-of-selection .
write:/ p_test ,
p_test1,
p_test2 .
CALL FUNCTION 'PRINT_SELECTIONS'
EXPORTING
mode = tables
rname = sy-repid "program name
rvariante = 'TEST' "varient name
TABLES
infotab = infotab
.
LOOP AT infotab.
WRITE / infotab-line.
ENDLOOP.
Check this example for printing the data on the selection screen , You need to call this function module after writing the data in report .
report ztests.
types: begin of t_varinfo,
flag type c,
olength type x,
line like raldb-infoline,
end of t_varinfo.
parameters: p_test(20) type c ,
p_test1 type i,
p_test2 type i .
data:tables type TRDIR-NAME occurs 0 with header line ,
infotab type t_varinfo occurs 0 with header line.
start-of-selection .
write:/ p_test ,
p_test1,
p_test2 .
CALL FUNCTION 'PRINT_SELECTIONS'
EXPORTING
mode = tables
rname = sy-repid "program name
rvariante = 'TEST' "varient name
TABLES
infotab = infotab
.
LOOP AT infotab.
WRITE / infotab-line.
ENDLOOP.
Subscribe to:
Posts (Atom)