ABAP Objects - Super/SubClass Inheritance of Interface Methods

Mike Pokraka wug at workflowconnections.com
Tue Apr 7 10:56:19 EDT 2009


Hi Florin,

Yup, and that's because the idea is that that the use of subclasses should
be kept to a minimum because interfaces are more in line with the OO
philosophy.
The easy workaround is to use individual GET_INSTANCE_* methods in the
subtypes which put in the correct call to BI_PERSISTENT~FIND_BY_LPOR; the
LPOR is stored in a protected instance attribute and BI_PERSISTENT~LPOR
will then always return the correct class type.

Not sure what you mean with static methods... you can always call them
from an instance reference:
Data: lo_widget type ref to zcl_widget.
create object lo_widget.
call method lo_widget->some_static_method.

Although there's little point to it because you cannot access instance
data in a static method. Well, you could... an ugly workaround is to make
your instance attributes public and importing them into your static
method, as in:
call method lo_widget->some_static_method( lo_widget->instance_attribute ).

But then you may as well have a separate instance method...

Cheers,
Mike

On Tue, April 7, 2009 3:14 pm, Florin Wach wrote:
> Hi Mike
>
> that beats the heck out of me, too. I planned a nice solution, which was
> far later on crossed by the error message "Static methods cannot be
> redefined". ... So I had to rework all the stuff.  Well, ... there're this
> other thing going on, that static methods can only be accessed, using the
> class type name, not the instance, ... which again is something huh
> unfamliar?
>
> I started to use instance methods as place-holders, that pass the class'
> name down to a static method, which then can work with this by using
> CREATE OBJECT is_there_another_solution TYPE you_shouldnt_do_this  ... or
> more weirder things.
>
> But yes, having Interfaces working with the workflow system could deal
> with 50% of such cases.
>
> Best wishes,
>    Florin
>
> -------- Original-Nachricht --------
>> Datum: Tue, 07 Apr 2009 15:00:03 +0100
>> Von: Mike Pokraka <wug at workflowconnections.com>
>> An: "SAP Workflow Users\' Group" <sap-wug at mit.edu>
>> Betreff: RE: ABAP Objects - Super/SubClass Inheritance of Interface
>> Methods
>
>> Yes, the lack of interfaces is a shame. It means you need to do some
>> clever
>> stuff with the LPOR methods to ensure the correct object type is
>> presented
>> in all cases since you cannot redefine static methods in subclasses.
>>
>>
>> On Tue, 7 Apr 2009 09:23:19 +0800, "Dart, Jocelyn"
>> <jocelyn.dart at sap.com>
>> wrote:
>> > Hi Mike/Florin,
>> >
>> > Please remember that Delegation only refers to BOR objects and only
>> permits
>> > one subtype to one supertype relationship.
>> >
>> > With ABAP Objects with use narrowing/widening cast e.g. by adjusting
>> the
>> > options in the bindings (by pressing the arrow head button in the
>> binding
>> > window).  This allows the use of many subtype/supertype relationships.
>> The
>> > only thing we don't use is ABAP Interfaces - you need to do class to
>> class
>> > bindings.
>> >
>> > Regards,
>> > Jocelyn
>> >
>> > ________________________________
>> >
>> > From: sap-wug-bounces at mit.edu on behalf of Florin Wach
>> > Sent: Fri 3/04/2009 1:51 AM
>> > To: SAP Workflow Users' Group
>> > Subject: Re: ABAP Objects - Super/SubClass Inheritance of Interface
>> Methods
>> >
>> >
>> >
>> > that's how it workes and why it's designed that way.
>> >
>> > To exchange one object for another at runtime you can use the
>> "Delegation",
>> > which is aliasing a subtype of an object with the supertype. (Which is
>> kind
>> > non-conform to object oriented approaches, but ...well, we're not
>> talking
>> > about object orientation with POR's anyhow :-)
>> >
>> > Best wishes,
>> >    Florin
>> >
>> > -------- Original-Nachricht --------
>> >> Datum: Thu, 2 Apr 2009 10:09:13 -0400
>> >> Von: "Michael McInerney" <michaelm at duke.edu>
>> >> An: "SAP Workflow Users\' Group" <sap-wug at mit.edu>
>> >> Betreff: ABAP Objects - Super/SubClass Inheritance of Interface
>> Methods
>> >
>> >> I have an ABAP object which is workflow enabled.
>> >>
>> >> All is good.
>> >>
>> >> I would like to create a few different flavors of this object via
>> >> subclasses/inheritance, using the original workflow enabled object as
>> the
>> >> superclass.
>> >>
>> >> The key definition will remain the same.
>> >>
>> >> I'm expecting that my interface methods and their implementation (POR
>> >> stuff) will hold up just fine, and can remain at the upper level, but
>> I
>> >> wanted
>> >> to make sure.
>> >>
>> >>
>> >>
>> >> Thanks.
>> >>
>> >>
>> >>
>> >> .Mike
>> >>
>> > _______________________________________________
>> > SAP-WUG mailing list
>> > SAP-WUG at mit.edu
>> > http://mailman.mit.edu/mailman/listinfo/sap-wug
>> >
>> >
>> >
>> > _______________________________________________
>> > SAP-WUG mailing list
>> > SAP-WUG at mit.edu
>> > http://mailman.mit.edu/mailman/listinfo/sap-wug
>> _______________________________________________
>> SAP-WUG mailing list
>> SAP-WUG at mit.edu
>> http://mailman.mit.edu/mailman/listinfo/sap-wug
> _______________________________________________
> SAP-WUG mailing list
> SAP-WUG at mit.edu
> http://mailman.mit.edu/mailman/listinfo/sap-wug
>





More information about the SAP-WUG mailing list