{"id":7154,"date":"2025-07-30T22:34:53","date_gmt":"2025-07-30T17:04:53","guid":{"rendered":"https:\/\/www.sapewmhelp.com\/?question=what-is-inheritance"},"modified":"2025-07-31T10:38:23","modified_gmt":"2025-07-31T05:08:23","slug":"what-is-inheritance","status":"publish","type":"question","link":"https:\/\/www.sapewmhelp.com\/?question=what-is-inheritance","title":{"rendered":"What is Inheritance ? Using Inheritance in SAP ABAP"},"content":{"rendered":"<p>Inheritance allows one class to <strong>reuse<\/strong> the code from another class. In SAP ABAP, this helps in building <strong>modular<\/strong>, <strong>reusable<\/strong>, and <strong>maintainable<\/strong> programs.<\/p>\n<h3 data-start=\"1102\" data-end=\"1133\">Use of Inheritance in SAP<\/h3>\n<div class=\"_tableContainer_16hzy_1\">\n<div class=\"_tableWrapper_16hzy_14 group flex w-fit flex-col-reverse\">\n<table data-start=\"1135\" data-end=\"1958\">\n<thead>\n<tr>\n<th data-start=\"1135\" data-end=\"1169\" data-col-size=\"sm\"><strong>Purpose<\/strong><\/th>\n<th data-start=\"1169\" data-end=\"1252\" data-col-size=\"md\"><strong>Explanation<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Code Reusability<\/td>\n<td>You don&#8217;t need to rewrite common logic; it can be inherited from a base class.<\/td>\n<\/tr>\n<tr>\n<td>Standardization<\/td>\n<td>Common functionality can be centralized in a superclass and reused.<\/td>\n<\/tr>\n<tr>\n<td>Simplifies Maintenance<\/td>\n<td>Changes in the parent class reflect automatically in all child classes.<\/td>\n<\/tr>\n<tr>\n<td>Extensibility<\/td>\n<td>Child classes can add or override methods to provide specific functionality.<\/td>\n<\/tr>\n<tr>\n<td>Polymorphism Support<\/td>\n<td>You can treat objects of different subclasses uniformly using references.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 data-start=\"2412\" data-end=\"2451\">Types of Inheritance in SAP ABAP<\/h3>\n<ol>\n<li><strong>Single Inheritance<\/strong> \u2013 A subclass inherits from only one parent class.<\/li>\n<li><strong>No Multiple Inheritance<\/strong> \u2013 SAP ABAP does not support multiple inheritance, but it allows <strong>interfaces<\/strong> for similar functionality.<\/li>\n<\/ol>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code><!--StartFragment --><span><span>*&amp;---------------------------------------------------------------------*<\/span>\n<span>*&amp;\u00a0Report\u00a0\u00a0ZREP_LCLCLASS<\/span>\n<span>*&amp;<\/span>\n<span>*&amp;---------------------------------------------------------------------*<\/span>\n<span>*&amp;<\/span>\n<span>*&amp;<\/span>\n<span>*&amp;---------------------------------------------------------------------*<\/span>\n\n<span>REPORT\u00a0<\/span>zrep_lclclass<span>.<\/span>\n\n<span>CLASS\u00a0<\/span>parent_class\u00a0<span>DEFINITION<\/span><span>.<\/span>\n\u00a0\u00a0<span>PUBLIC\u00a0<\/span><span>SECTION<\/span><span>.<\/span>\n\u00a0\u00a0\u00a0\u00a0<span>METHODS<\/span><span>:\u00a0<\/span>display<span>.<\/span>\n<span>ENDCLASS<\/span><span>.<\/span>\n\n<span>CLASS\u00a0<\/span>parent_class\u00a0<span>IMPLEMENTATION<\/span><span>.<\/span>\n\u00a0\u00a0<span>METHOD\u00a0<\/span>display<span>.<\/span>\n\u00a0\u00a0\u00a0\u00a0<span>WRITE<\/span><span>:\u00a0<\/span>'This\u00a0<span>is\u00a0<\/span>parent\u00a0class'<span>.<\/span>\n\u00a0\u00a0<span>ENDMETHOD<\/span><span>.<\/span>\n<span>ENDCLASS<\/span><span>.<\/span>\n\n<span>CLASS\u00a0<\/span>child_class\u00a0<span>DEFINITION\u00a0<\/span><span>INHERITING\u00a0<\/span><span>FROM\u00a0<\/span>parent_class<span>.<\/span>\n\u00a0\u00a0<span>PUBLIC\u00a0<\/span><span>SECTION<\/span><span>.<\/span>\n\u00a0\u00a0\u00a0\u00a0<span>METHODS<\/span><span>:\u00a0<\/span>show<span>.<\/span>\n<span>ENDCLASS<\/span><span>.<\/span>\n\n<span>CLASS\u00a0<\/span>child_class\u00a0<span>IMPLEMENTATION<\/span><span>.<\/span>\n\u00a0\u00a0<span>METHOD\u00a0<\/span>show<span>.<\/span>\n\u00a0\u00a0\u00a0\u00a0<span>WRITE<\/span><span>:\u00a0<\/span>'This\u00a0<span>is\u00a0<\/span>child\u00a0class'<span>.<\/span>\n\u00a0\u00a0<span>ENDMETHOD<\/span><span>.<\/span>\n<span>ENDCLASS<\/span><span>.<\/span>\n\n<span>START-OF-SELECTION<\/span><span>.<\/span>\n\u00a0\u00a0<span>DATA\u00a0<\/span>obj\u00a0<span>TYPE\u00a0<\/span><span>REF\u00a0<\/span><span>TO\u00a0<\/span>child_class<span>.<\/span>\n\u00a0\u00a0<span>CREATE\u00a0<\/span>OBJECT\u00a0obj<span>.<\/span>\n\u00a0\u00a0obj<span>-&gt;<\/span>display<span>(\u00a0<\/span><span>)<\/span><span>.\u00a0\u00a0\u00a0<\/span><span>\"Inherited\u00a0method<\/span>\n\u00a0\u00a0<span>skip\u00a0<\/span><span>2<\/span><span>.<\/span>\n\u00a0\u00a0obj<span>-&gt;<\/span>show<span>(\u00a0<\/span><span>)<\/span><span>.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span>\"Own\u00a0method<\/span><\/span> <\/code><\/pre>\n<\/div>\n<p>Output:<br \/>\n<img decoding=\"async\" class=\"content-img\" src=\"https:\/\/www.sapewmhelp.com\/wp-content\/uploads\/2025\/07\/inheritence-2.png\" \/><\/p>\n<\/div>\n<\/div>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","question-category":[174],"question_tags":[190,191,192,168,177],"class_list":["post-7154","question","type-question","status-publish","hentry","question-category-ooabap","question_tags-inheritence","question_tags-method-overriding","question_tags-object-oriented-programming","question_tags-ooabap","question_tags-sap"],"_links":{"self":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/question\/7154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/question"}],"about":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7154"}],"wp:attachment":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7154"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fquestion-category&post=7154"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fquestion_tags&post=7154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}