Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

doubt in oops basic

Former Member
0 Kudos
59

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
39

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.

3 REPLIES 3

Former Member
0 Kudos
39

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

Former Member
0 Kudos
40

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.

Former Member
0 Kudos
39

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.