{"id":1162,"date":"2014-10-15T06:52:17","date_gmt":"2014-10-15T05:52:17","guid":{"rendered":"http:\/\/oprsteny.cz\/?p=1162"},"modified":"2014-10-15T06:53:54","modified_gmt":"2014-10-15T05:53:54","slug":"design-patterns-in-abap-adapter","status":"publish","type":"post","link":"https:\/\/oprsteny.cz\/?p=1162","title":{"rendered":"Design Patterns in ABAP &#8211; Adapter"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"358\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=358\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" data-orig-size=\"44,50\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Picasa&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1365690880&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"SAP\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" class=\"size-full wp-image-358 alignleft\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" alt=\"SAP\" width=\"44\" height=\"50\" \/>Adapter design pattern provides unique <strong><em>INTERFACE<\/em><\/strong> to the outside world for different functionality encapsulated in separate implementations.<!--more--><\/p>\n<p>Does it sound familiar? Let&#8217;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.<\/p>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/DESIGN_PATTERNS_ADAPTER_01.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1160\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=1160\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/DESIGN_PATTERNS_ADAPTER_01.png\" data-orig-size=\"531,333\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Adapter class diagram\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/DESIGN_PATTERNS_ADAPTER_01.png\" class=\"size-medium wp-image-1160 aligncenter\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/DESIGN_PATTERNS_ADAPTER_01-300x188.png\" alt=\"Adapter class diagram\" width=\"300\" height=\"188\" srcset=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/DESIGN_PATTERNS_ADAPTER_01-300x188.png 300w, https:\/\/oprsteny.cz\/wp-content\/uploads\/DESIGN_PATTERNS_ADAPTER_01-478x300.png 478w, https:\/\/oprsteny.cz\/wp-content\/uploads\/DESIGN_PATTERNS_ADAPTER_01.png 531w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<pre lang=\"abap\">INTERFACE lif_po_change.\r\n  METHODS:\r\n    change.\r\n*   for purchase order we can expect several \r\n*   IN\/OUT parameters at such CHANGE method in real world\r\nENDINTERFACE.\r\n\r\nCLASS lcl_change_address DEFINITION.\r\n  PUBLIC SECTION.\r\n    INTERFACES:\r\n      lif_po_change.\r\nENDCLASS.\r\n\r\nCLASS lcl_change_address IMPLEMENTATION.\r\n  METHOD lif_po_change~change.\r\n    WRITE: \/ 'PO Address is being modified'.\r\n  ENDMETHOD.\r\nENDCLASS.\r\n\r\nCLASS lcl_change_vendor DEFINITION.\r\n  PUBLIC SECTION.\r\n    INTERFACES:\r\n      lif_po_change.\r\nENDCLASS.\r\n\r\nCLASS lcl_change_vendor IMPLEMENTATION.\r\n  METHOD lif_po_change~change.\r\n    WRITE: \/ 'Vendor address on PO is being modified'.\r\n  ENDMETHOD.\r\nENDCLASS.\r\n\r\nSTART-OF-SELECTION.\r\n  DATA:\r\n    lo_po_change TYPE REF TO lif_po_change.\r\n\r\n  CREATE OBJECT lo_po_change TYPE lcl_change_address.\r\n  lo_po_change-&gt;change( ).\r\n\r\n* Using the same interface we achieve completely \r\n* different results\r\n  CREATE OBJECT lo_po_change TYPE lcl_change_vendor.\r\n  lo_po_change-&gt;change( ).\r\n<\/pre>\n<h2>Output<\/h2>\n<p><a href=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/DESIGN_PATTERNS_ADAPTER_02.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1161\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=1161\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/DESIGN_PATTERNS_ADAPTER_02.png\" data-orig-size=\"287,147\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Adapter design pattern &amp;#8211; Output\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/DESIGN_PATTERNS_ADAPTER_02.png\" class=\"size-full wp-image-1161 aligncenter\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/DESIGN_PATTERNS_ADAPTER_02.png\" alt=\"Adapter design pattern - Output\" width=\"287\" height=\"147\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Adapter design pattern provides unique INTERFACE to the outside world for different functionality encapsulated in separate implementations.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Design Patterns in ABAP - Adapter","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[16,15,8,4,9],"tags":[446,340,335,341,221],"class_list":["post-1162","post","type-post","status-publish","format-standard","hentry","category-abap","category-algorithms","category-behavioral-patterns","category-design-patterns","category-development","tag-abap","tag-adapter","tag-design-patterns-2","tag-interface","tag-oo-abap"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3nYbe-iK","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1162"}],"version-history":[{"count":2,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1162\/revisions"}],"predecessor-version":[{"id":1165,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1162\/revisions\/1165"}],"wp:attachment":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}