Adapter design pattern provides unique INTERFACE to the outside world for different functionality encapsulated in separate implementations.
Does it sound familiar? Let’s look at SAP BAdI having multiple implementations where all of them are called the same way (using the same inputs/outputs) but the purpose and functionality of each of these implementations can be completely different.
INTERFACE lif_po_change.
METHODS:
change.
* for purchase order we can expect several
* IN/OUT parameters at such CHANGE method in real world
ENDINTERFACE.
CLASS lcl_change_address DEFINITION.
PUBLIC SECTION.
INTERFACES:
lif_po_change.
ENDCLASS.
CLASS lcl_change_address IMPLEMENTATION.
METHOD lif_po_change~change.
WRITE: / 'PO Address is being modified'.
ENDMETHOD.
ENDCLASS.
CLASS lcl_change_vendor DEFINITION.
PUBLIC SECTION.
INTERFACES:
lif_po_change.
ENDCLASS.
CLASS lcl_change_vendor IMPLEMENTATION.
METHOD lif_po_change~change.
WRITE: / 'Vendor address on PO is being modified'.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA:
lo_po_change TYPE REF TO lif_po_change.
CREATE OBJECT lo_po_change TYPE lcl_change_address.
lo_po_change->change( ).
* Using the same interface we achieve completely
* different results
CREATE OBJECT lo_po_change TYPE lcl_change_vendor.
lo_po_change->change( ).