{"id":7332,"date":"2025-08-03T12:07:17","date_gmt":"2025-08-03T06:37:17","guid":{"rendered":"https:\/\/www.sapewmhelp.com\/?question=what-is-an-abstract-class-in-sap-abap"},"modified":"2025-08-03T12:07:17","modified_gmt":"2025-08-03T06:37:17","slug":"what-is-an-abstract-class-in-sap-abap","status":"publish","type":"question","link":"https:\/\/www.sapewmhelp.com\/?question=what-is-an-abstract-class-in-sap-abap","title":{"rendered":"What is an Abstract Class in SAP ABAP?"},"content":{"rendered":"<p>An abstract class is a class that cannot be instantiated directly. It serves as a blueprint for other classes. Abstract classes typically include:<\/p>\n<ul>\n<li>Abstract methods, which are declared but not implemented.<\/li>\n<li>Concrete methods, which can be implemented and inherited.<\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th>Feature<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Not instantiable<\/td>\n<td>Cannot use <code>CREATE OBJECT<\/code> on abstract classes.<\/td>\n<\/tr>\n<tr>\n<td>Used for inheritance<\/td>\n<td>Serve as base classes for child classes.<\/td>\n<\/tr>\n<tr>\n<td>Can contain abstract methods<\/td>\n<td>These must be implemented in subclasses.<\/td>\n<\/tr>\n<tr>\n<td>Can contain concrete methods<\/td>\n<td>These can be used directly by child classes.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-python\" data-lang=\"Python\"><code><!--StartFragment --><span><span>REPORT\u00a0<\/span>zrep_lclclass<span>.<\/span>\r\n\r\n<span>CLASS\u00a0<\/span>lcl_animal\u00a0<span>DEFINITION\u00a0<\/span>ABSTRACT<span>.<\/span>\r\n\u00a0\u00a0<span>PUBLIC\u00a0<\/span><span>SECTION<\/span><span>.<\/span>\r\n\u00a0\u00a0\u00a0\u00a0<span>METHODS<\/span><span>:<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0speak\u00a0ABSTRACT<span>,<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span>move<\/span><span>.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span>\"\u00a0This\u00a0can\u00a0be\u00a0implemented\u00a0if\u00a0needed<\/span>\r\n<span>ENDCLASS<\/span><span>.<\/span>\r\n\r\n<span>CLASS\u00a0<\/span>lcl_animal\u00a0<span>IMPLEMENTATION<\/span><span>.<\/span>\r\n\u00a0\u00a0<span>METHOD\u00a0<\/span><span>move<\/span><span>.<\/span>\r\n\u00a0\u00a0\u00a0\u00a0<span>WRITE<\/span><span>:\u00a0<\/span>'Animal\u00a0<span>is\u00a0<\/span>moving'<span>.<\/span>\r\n\u00a0\u00a0<span>ENDMETHOD<\/span><span>.<\/span>\r\n<span>ENDCLASS<\/span><span>.<\/span>\r\n\r\n<span>\"\u00a0Concrete\u00a0subclass<\/span>\r\n<span>CLASS\u00a0<\/span>lcl_dog\u00a0<span>DEFINITION\u00a0<\/span><span>INHERITING\u00a0<\/span><span>FROM\u00a0<\/span>lcl_animal<span>.<\/span>\r\n\u00a0\u00a0<span>PUBLIC\u00a0<\/span><span>SECTION<\/span><span>.<\/span>\r\n\u00a0\u00a0\u00a0\u00a0<span>METHODS<\/span><span>:<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0speak\u00a0<span>REDEFINITION<\/span><span>.<\/span>\r\n<span>ENDCLASS<\/span><span>.<\/span>\r\n\r\n<span>CLASS\u00a0<\/span>lcl_dog\u00a0<span>IMPLEMENTATION<\/span><span>.<\/span>\r\n\u00a0\u00a0<span>METHOD\u00a0<\/span>speak<span>.<\/span>\r\n\u00a0\u00a0\u00a0\u00a0<span>WRITE<\/span><span>:\u00a0<\/span>'Woof!'<span>.<\/span>\r\n\u00a0\u00a0<span>ENDMETHOD<\/span><span>.<\/span>\r\n<span>ENDCLASS<\/span><span>.<\/span>\r\n\r\n<span>START-OF-SELECTION<\/span><span>.<\/span>\r\n\u00a0\u00a0<span>\"\u00a0Parent\u00a0Class<\/span>\r\n\u00a0\u00a0<span>DATA<\/span><span>(<\/span>lo_animal<span>)\u00a0<\/span><span>=\u00a0<\/span><span>NEW\u00a0<\/span>lcl_animal<span>(\u00a0<\/span><span>)<\/span><span>.<\/span>\r\n\u00a0\u00a0lo_animal<span>-&gt;<\/span>speak<span>(\u00a0<\/span><span>)<\/span><span>.<\/span>\r\n\u00a0\u00a0<span>WRITE<\/span><span>:\u00a0<\/span>'Animal\u00a0can\u00a0speak'<span>.<\/span>\r\n\u00a0\u00a0<span>SKIP<\/span><span>.<\/span>\r\n\u00a0\u00a0<span>\"\u00a0child\u00a0class<\/span>\r\n\u00a0\u00a0<span>DATA<\/span><span>(<\/span>lo_dog<span>)\u00a0<\/span><span>=\u00a0<\/span><span>NEW\u00a0<\/span>lcl_dog<span>(\u00a0<\/span><span>)<\/span><span>.<\/span>\r\n\u00a0\u00a0lo_dog<span>-&gt;<\/span>speak<span>(\u00a0<\/span><span>)<\/span><span>.<\/span>\r\n\u00a0\u00a0lo_dog<span>-&gt;<\/span><span>move<\/span><span>(\u00a0<\/span><span>)<\/span><span>.<\/span><\/span> <\/code><\/pre>\n<p>Output:<br \/>\nCheck the Program ( CTRL + F2 ).<br \/>\n<img decoding=\"async\" class=\"content-img\" src=\"https:\/\/www.sapewmhelp.com\/wp-content\/uploads\/2025\/08\/abstract-class.png\" \/><\/p>\n<p>if not initated the Parent class then the output will be.<br \/>\n<img decoding=\"async\" class=\"content-img\" src=\"https:\/\/www.sapewmhelp.com\/wp-content\/uploads\/2025\/08\/abstract-class-2.png\" \/><\/p>\n<p>Output:<br \/>\n<img decoding=\"async\" class=\"content-img\" src=\"https:\/\/www.sapewmhelp.com\/wp-content\/uploads\/2025\/08\/abstract-class-3.png\" \/><\/p>\n<\/div>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","question-category":[174],"question_tags":[178,171,195,264,265,177],"class_list":["post-7332","question","type-question","status-publish","hentry","question-category-ooabap","question_tags-abap","question_tags-class","question_tags-object","question_tags-object-oriented","question_tags-oo-abap","question_tags-sap"],"_links":{"self":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/question\/7332","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=7332"}],"wp:attachment":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7332"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fquestion-category&post=7332"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fquestion_tags&post=7332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}