Skip to Content

Factory pattern is one of the creational design patterns in object oriented design. This blog explains one of the approaches on how this pattern can be extended and implemented in ABAP Object Oriented Programming (OO).

In factory pattern, different implementations of an interface are instantiated based on a configuration.  Now, let us take a case where there are multiple implementations for multiple interfaces. The factory class would now have to choose specific implementation for a specific interface.

You can find an example class diagram in the file “factory_pattern.png”.

E type configuration table







C type configuration table






Algorithm within the class “CL_CLASS_FACTORY”

  1. Based on the interface, read customer’s configuration table to get the class name.
  2. If class name is not maintained in (1), read the configuration from SAP delivered configuration table to get class name from interface name.

For the above example, for interface IF_GENERIC, class CL_GENERIC is picked up from the configuration table whereas for the interface IF_GENERIC_1, class CL_GENERIC_1 is picked up from the configuration.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply