Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Determine Class and Subclass

Hi all,

I have the following 'issue': I want to create / update / retrieve BP relationships. My idea is to create a superclass with all general data for a relationship like Partner 1 & 2, type of relationship (employer-employee, husband-wife etc.). So far so good, but now it comes. All relationships have different attributes (created in CRM with Easy Enhancement Workbench, comparable to customer includes).

Does it make sense to create a subclass per relationship type, because based on that different logic has to be processed. Or put all these attributes, whether they belong to relationship type A, or B, in the same superclass?

Normally I would say the second option is better / more logical and put them all in ONE (super)class, but since every relationship is a specialization of the superclass due to all the different attributes, it would also make sense to create a new subclass for every relationship type. I actually want to avoid, using IF statement within the class (IF relationship A, ELSEIF relationship B, etc.), because when creating a new relationship type, I would have to change the superclass over and over again.

<removed_by_moderator> Hope to hear from you.

Any suggestions?

Edited by: Julius Bussche on Sep 12, 2008 10:35 AM


It looks like you want to implement the Open Closed Principle. You can try using the Interface or Abstract Super Class.

When using the Abstract Super Class, you need to create the Factory method, which can give back you the object reference of your required relationship. So, when ever you introduce a new relationship, you can change this method, or make the implementation of the Factory method dynamic i.e. all subclass for this superclass will have the same prefix with suffix as the relationship name.

You may find these blogs useful:




Naimesh Patel

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question