Application Development and Automation 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: 
Read only

Help with OO program

Former Member
0 Likes
695

Hello. I have a base class called Property. It gets data from the program in the form of a parameter p_data. There are 2 methods getdata(gets p_data from the program) and display_area(calculate and print the area)

I have two subclasses called FootballPitch and RaceTrack which are inheriting from Property. There are two methods: Pitch_area(calculate the area using p_data) and display_pitch(this redefines display_area in the super class).

The second subclass will work in a similar way. I am new to classes in ABAP so I need some assistance. Thank you.

James

5 REPLIES 5
Read only

Former Member
0 Likes
670

Hi James,

Welcome to SDN!!

Can u tell us in what way would u need assistance..

If syntax is the problem...

refer

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/2503f09c-0801-0010-dc89-80b...

This shall help u solve your problem and is excellent tutorial for freshers.

Was of great help to me too.

Hope that helps!!

Let me know your email id and i shall mail the documents to you alonf with some good documents

Regards,

Tanveer.

Please mark answers by clicking on the star at the top

Read only

0 Likes
670

I would like to know how to use pitch_area to redefine display_area. What will the method look like? It seems to me that pitch_area is not needed.

James

Read only

0 Likes
670

Hi James,

Well, you understood that nicely.See the only important thing to do is to redefine the display_area method.Here u CANNOT CHANGE THE METHOD INTERFACE, whereas you are free to change code according to your need.

Hope this helps.

best regards,

Bharat

Read only

0 Likes
670

Hello James,

You have got it right!!

Both the methods pitch_area and display_area i suppose do the calculation of area based on parameter p_data.

So you need not override (what u termed as redefine) the method display_area.

Also a method pitch_area cannot override display_area.

It need to be so same interface.

For example,

if u declare your display_area method as follows in base class Property :

method display_area .

area = p_data * p_data.

endmethod.

Now if u use this method in the child class FootballPitch,

it will do the same work of finding area..

U can overide it here..

method display_area .

area = 2 * p_data * p_data.

endmethod.

Now when u use this method, it will give u 2 times the area .

However, for class RaceTrack,

the method display_area would still give u the area..

Hope that explains th point..

Shall mail u documents on this topic once i get back to office on tuesday...

Regards,

Tanveer.

Note: Please mark helpful answers on SDN as thats the only way to appreciate someones efforts..

Read only

0 Likes
670

I used redefined the original method in the subclasses. Pitch_area was not necessary as I thought.

Thank you all for the help. However, I don't see the radio buttons to award the points to you for helping me.

James