Skip to Content
-3

Regarding OOABAP

What is Factory Design Pattern ? What is the real time example of factory design pattern in terms of SAP?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Nov 29, 2020 at 07:25 PM

    Hi Varun Shukla

    Here's about the pattern: https://en.wikipedia.org/wiki/Factory_method_pattern

    Here's an example for ABAP: https://blogs.sap.com/2012/02/20/factory-pattern-in-abap-oo/

    The example is complex, with configuration based on DB table, but it can also be as simple as

    METHOD create_instance.
      IF iv_value = 'A'.
        CREATE OBJECT ro_instance TYPE lcl_a.
      ELSE.
        CREATE OBJECT ro_instance TYPE lcl_default.
      ENDIF.
    ENDMETHOD.

    Kind regards,

    Mateusz

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 30, 2020 at 03:13 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 30, 2020 at 07:15 AM

    Hello Varun Shukla,

    The factory method is most used for creating objects without any leverage to its instantiation technique. Interfaces and encapsulation concepts of OOABAP plays a vital role here.

    You can follow the blog below which discusses the method in detail.

    https://blogs.sap.com/2012/02/20/factory-pattern-in-abap-oo/#:~:text=The%20factory%2Dpattern%20is%20one,concrete%20implementation%20to%20the%20users.

    Regards!

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.