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

overloading

Former Member
0 Likes
462

hi there,

can anyone pls tell me why overloading in not possible in ABAP?? they ve asked me this quetion in an interview..

regards,

Krish

1 ACCEPTED SOLUTION
Read only

matt
Active Contributor
0 Likes
432

>

> hi there,

>

> can anyone pls tell me why overloading in not possible in ABAP?? they ve asked me this quetion in an interview..

>

> regards,

> Krish

Because that's how SAP designed the ABAP Objects language. Overloading isn't needed anyway, because you can mark parameters as optional - this allows you to do anything that you could do with overloading.

matt

2 REPLIES 2
Read only

Former Member
0 Likes
432

hi,

To test it do it this way.

First try create two methods in the same class with same name.

but there parameter should be different. mean one method contain only one import parameter another contain 2 parameter.

Now try to call them one by one by an object.

if you call them that mean overloading is possible otherwise not.

And Method OverLoading is Not possibel in ABAP Objects.

Reason: As Method overloading is done on the basis of number of parameters that you pass to the function.

but in ABAP Obejcts.

when you implement the class there is no differtiation between methods on the basis of number of parameters you want to pass.

Class xxx definition.

public section.

Method :

area importing len type i,

area importing len type c width type c.

endclass.

class xxx implementation.

Method area .

Endmethod.

endclass.

In the class implementaion ,we need to differentiate on the basis of number of parameters which we pass but we can not and only one one implemetation is possible for a function. so we can not have multiple functinalty inmplemented for a method with same name.

Regards.

Punit

Edited by: Punit Singh on Apr 7, 2009 8:33 AM

Edited by: Matt on Apr 7, 2009 9:36 AM - changed "function module" to "method"

Read only

matt
Active Contributor
0 Likes
433

>

> hi there,

>

> can anyone pls tell me why overloading in not possible in ABAP?? they ve asked me this quetion in an interview..

>

> regards,

> Krish

Because that's how SAP designed the ABAP Objects language. Overloading isn't needed anyway, because you can mark parameters as optional - this allows you to do anything that you could do with overloading.

matt