‎2007 Jul 03 9:14 AM
Is there any phenomenon by name method overloading in abap like java.If it was there can any body explain it in detail,or if it was not there ,then is there any other phenomenon which have a similar functionality like method overloading.
‎2007 Jul 03 11:45 AM
‎2007 Jul 03 12:23 PM
Hi Sandeep,
There is no method overloading in ABAP./ But there is something called a redefinition.
When you inherit a class from a super class, you can redifne a method. You cannot chnage the signature( Interface) of the method. It will remain the same as that of the super class.You must redefine a method in the same visibility section in which it appears in the superclass.
Eg.
CLASS C_SUPER_CLASS DEFINITION .
PUBLIC SECTION.
METHODS: DRIVE ,
STOP.
PROTECTED SECTION.
DATA SPEED TYPE I.
ENDCLASS.
CLASS C_SUPER_CLASS IMPLEMENTATION.
METHOD DRIVE.
SPEED = 0.
WRITE: / 'Bike speed =', SPEED.
ENDMETHOD.
ENDCLASS.
CLASS C_SUB_CLASS DEFINITION INHERITING FROM C_SUPER_CLASS.
PUBLIC SECTION.
METHODS DRIVE REDEFINITION.
ENDCLASS
CLASS C_SUB_CLASS IMPLEMENTATION.
METHOD DRIVE.
SPEED = SPEED + 10.
WRITE: / 'Bicycle speed =', SPEED.
ENDMETHOD.
ENDCLASS.