Application Development 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: 

ABAP OO modeling

Former Member
0 Kudos

Hello everyone,

I want to create an UML for the topic invoices and documents. My question is it, how to model it? I have the class invoice with the attribute structure RBKP(table). This class inherite from the class document. So what happens when I make an upcast from the object invoice to the object document? What happens with the attribute structure RBKP? Some fields of this attribute structure are general and can be used in the object document like "time of recording" or "document date".  The problem is, its a part of this structure RBKP in the object invoice and cant be cast to the object document.

Thank you for help!

4 REPLIES 4

Former Member
0 Kudos

Hi Patrick,

As far as I understand you want to access some fields from a subclass. Probably you want to make some generic actions for documents like RBKP and BKPF.

Obviously you cannot access attributes from subclass directly, but there are some ways to achieve that, but the simplest:

Add some (the best would be protected) attributes in a superclass ( mv_cpudt, mv_bldat etc.. )
In subclass during filling in attribute with structure rbkp fill in other attributes from superclass

Regards,

Radek

0 Kudos

Hi Radek,

greate, you understand my problem. Your suggestion is ok but the benefit of OO is it to define things one time. In your case I have the information 2 times and I have to manage it twice. When I have a big inheritance hierarchy and many attributes, the effort will increase too much.

Thanks for help.

0 Kudos

Of course ideally you have one variable for one single piece of information, but somethimes you are forced for some trade-offs

If you need to access one particular field in the superclass maybe you can define references to data ?

DATA: ls_rbkp TYPE rbkp,                   "Attribute in subclass

           lr_cpudt TYPE REF TO DATA.  "Attribute in superclass.

** In constructor of subclass - define which fields are common

GET REFERENCE OF ls_rbkp-cpudt INTO lr_cpudt.

** when accessed in the superclass (unfortunately ABAP does not have convenient way of accessing pointers, so every time following piece of code is needed):

ASSIGN lr_cpudt TO FIELD-SYMBOL(<lv_cpudt>).

Former Member
0 Kudos

I dont think its the aim to define types of attributes from a super class in a Sub class. I mean you can then define everything as long as you inherite it.

For example: I want use generic actions and have 3 classes( Document, Invoice and Car ). Invoice and Car Inherite from Document and now I define the types in the constructors. The Invoice have the same Attribute( ls_rbkp-cpudt, ls_rbkp-budat ) , but the car defines for the super class other information like bla-engine, bla-electronic.

Now its impossible to make generic actions because the types of the same based class are different. At all you can nothing do with the class document if you instantiate it because the type of the attribute is not defined.