Skip to Content
author's profile photo Former Member
Former Member

doubt in oops basic

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 09: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 09: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 09: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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.