‎2008 Jan 28 9:31 AM
hii
if i execute the below program im not gettin the value of z..can anybody tel y??or plz tel me wats wrong in the prog...
&----
*& Report ZOOPS
*&
&----
*&
*&
&----
REPORT ZOOPS.
class number1 definition.
public section .
methods : constructor importing x1 type i
y1 type i.
methods : findsum exporting z type i.
private section.
data : x type i,
y type i.
endclass.
class number1 implementation.
method constructor.
x = x1.
y = y1.
endmethod.
method findsum.
z = x + y.
write : / z.
endmethod.
endclass.
data : obj type ref to number1.
data : z1 type i.
parameters : s_x1 type i obligatory,
s_y1 type i obligatory.
start-of-selection.
create object obj exporting x1 = s_x1
y1 = s_y1.
‎2008 Jan 28 9:39 AM
Hi,
after ur code add this statement.
dont include x declaration in private section.
call method obj->findsum.
importing
z = z1.
Plzz reward points if it helps.
‎2008 Jan 28 9:36 AM
Hi asha,
Check out this code.
u have not called findsum method , so it was not printing the sum
class number1 definition.
public section .
methods : constructor importing x1 type i
y1 type i.
methods : findsum exporting z type i.
private section.
data : x type i,
y type i.
endclass. "number1 DEFINITION
----
CLASS number1 IMPLEMENTATION
----
*
----
class number1 implementation.
method constructor.
x = x1.
y = y1.
endmethod. "constructor
method findsum.
z = x + y.
write : / z.
endmethod. "findsum
endclass. "number1 IMPLEMENTATION
data : obj type ref to number1.
data : z1 type i.
parameters : s_x1 type i obligatory,
s_y1 type i obligatory.
start-of-selection.
create object obj
EXPORTING
x1 = s_x1
y1 = s_y1.
call method obj->findsum.
regards,
Santosh Thorat
‎2008 Jan 28 9:39 AM
Hi,
after ur code add this statement.
dont include x declaration in private section.
call method obj->findsum.
importing
z = z1.
Plzz reward points if it helps.
‎2008 Jan 28 9:47 AM
Hi,
You forgot to call the method findsum because of which the value of Z is not coming.
call method obj->findsum.
Add this line and you will see the value of z in the output.
Kindly rewards points if helpful.