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

How to access the objects from multiple classes in ABAP Objects

Former Member
0 Likes
2,135

<b> Give me The scenario and solution to the above problem </b>

8 REPLIES 8
Read only

Former Member
0 Likes
1,451

Welcome to Forum!

to access an object from a class you must create an instance of that class using

data: inst type ref to class.

and using CREATE OBJECT .

then you can access the attributes and methods of that class(Public only)

it will be more helpfull for us to solve your problem if you can put more light to your problem

cheers

Message was edited by: Hemendra Singh Manral

Read only

0 Likes
1,451

Hi Singh,

pl can u send me one program which is solve multiple inheritance by interfaces to my mail-id as follows.

mn_kumar_2000@yahoo.com

Read only

0 Likes
1,451

at present i dont have any ready program.

for global classes go like this--

goto se80 select class/interface and write name of interface press enter

this will create a global interface, where you can define attributes and methods.

from here you can also create class. or through tx:se24.

this will create global class.

inside a class you can define attributes,interfaces, methods etc as well in properties you can assign a super class also.

for local classes---

local classes/interfaces are defined inside a abap program, their visibility is only within program while global classes are visible throughout the system.

check this link also it will provide a fast way to learn about abap onjects its short too.

http://www.intelligententerprise.com/channels/applications/feature/archive/heymann.jhtml

read the link already provided it has sample code also.

regards.

Read only

Former Member
0 Likes
1,451

Hi Take a look in this c1 class i am using c2 objects.

CLASS C2 DEFINITION DEFERRED.

 CLASS C1 DEFINITION.

PUBLIC SECTION.

DATA O2 TYPE REF TO C2.

ENDCLASS.

 CLASS C2 DEFINITION.

public section.

data : num type i value 5.

ENDCLASS.

start-of-selection.

data : obj1 type ref to C1.

CREATE OBJECT obj1.

create object obj1->o2.

write:/5 obj1->o2->num .

regards

vijay

Read only

0 Likes
1,451

The thing is how to solve the MULTIPLE-INHERITANCE in ABAP OBJECTS.

C is a subclass want to access the different methods of 2 different super classes A and B.

Read only

0 Likes
1,451

then in that case use Interface.

multiple inheritance is not possible

regards

vijay

Read only

0 Likes
1,451

In abap OO you can have only one super class.

multiple inheritence can be acheived by inheriting multiple interfaces.

abap OO is similler to that of JAVA in inheritence.

so you can not have classes a and b both as super at same time for a class.

however if still you want to acheive your perpose then you can do it using heirarchical inheritance where b inherits a and c inhrites b. so this way public methods will be accesible in c

do revert back if any other doubt.

check this link for more clear picture:

http://help.sap.com/saphelp_erp2004/helpdata/en/9f/dba81635c111d1829f0000e829fbfe/frameset.htm

regards.

kindly close the thread if problem by awarding points on left side.

Message was edited by: Hemendra Singh Manral

Read only

0 Likes
1,451

Use two interfaces and implement them in your class which u are going to access.

regards

vijay