{"id":7159,"date":"2025-07-30T22:43:07","date_gmt":"2025-07-30T17:13:07","guid":{"rendered":"https:\/\/www.sapewmhelp.com\/?question=what-is-final-class"},"modified":"2025-07-31T10:37:23","modified_gmt":"2025-07-31T05:07:23","slug":"what-is-final-class","status":"publish","type":"question","link":"https:\/\/www.sapewmhelp.com\/?question=what-is-final-class","title":{"rendered":"What is Final Class ? how to use final class in SAP ABAP"},"content":{"rendered":"<p>A final class is declared using the keyword FINAL in its definition. It&#8217;s used when you want to prevent further inheritance of the class, ensuring its behavior cannot be modified through subclassing.<\/p>\n<h3 data-start=\"886\" data-end=\"914\">Why Use a Final Class?<\/h3>\n<div class=\"_tableContainer_16hzy_1\">\n<div class=\"_tableWrapper_16hzy_14 group flex w-fit flex-col-reverse\">\n<table data-start=\"916\" data-end=\"1404\">\n<thead>\n<tr>\n<th data-start=\"916\" data-end=\"946\" data-col-size=\"sm\"><strong>Reason<\/strong><\/th>\n<th data-start=\"946\" data-end=\"965\" data-col-size=\"md\"><strong>Explanation<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Encapsulation<\/td>\n<td>Prevents modification of core behavior.<\/td>\n<\/tr>\n<tr>\n<td>Security and Stability<\/td>\n<td>Ensures the logic remains consistent, especially for critical functionality.<\/td>\n<\/tr>\n<tr>\n<td>Performance<\/td>\n<td>ABAP runtime can optimize calls to final classes (minor performance benefit).<\/td>\n<\/tr>\n<tr>\n<td>Design Decision<\/td>\n<td>Enforces design rule that a class should not be extended.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"sticky end-(--thread-content-margin) h-0 self-end select-none\">\n<div><\/div>\n<div class=\"absolute end-0 flex items-end\">\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-js\" data-lang=\"JavaScript\"><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>zcl_final_class\u00a0<span>DEFINITION\u00a0<\/span>FINAL<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>zcl_final_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>a\u00a0final\u00a0class'<span>.<\/span>\n\u00a0\u00a0<span>ENDMETHOD<\/span><span>.<\/span>\n<span>ENDCLASS<\/span><span>.<\/span>\n\n\n<span>CLASS\u00a0<\/span>zcl_subclass\u00a0<span>DEFINITION\u00a0<\/span><span>INHERITING\u00a0<\/span><span>FROM\u00a0<\/span>zcl_final_class<span>.<\/span>\n\u00a0\u00a0<span>PUBLIC\u00a0<\/span><span>SECTION<\/span><span>.<\/span>\n<span>ENDCLASS<\/span><span>.<\/span><\/span> <\/code><\/pre>\n<\/div>\n<p>Output :<br \/>\nwhile saving the changes<br \/>\n<img decoding=\"async\" class=\"content-img\" src=\"https:\/\/www.sapewmhelp.com\/wp-content\/uploads\/2025\/07\/final.png\" \/><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<hr \/>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","question-category":[174],"question_tags":[171,193,194,168,177],"class_list":["post-7159","question","type-question","status-publish","hentry","question-category-ooabap","question_tags-class","question_tags-final-class","question_tags-objects","question_tags-ooabap","question_tags-sap"],"_links":{"self":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/question\/7159","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=7159"}],"wp:attachment":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7159"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fquestion-category&post=7159"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fquestion_tags&post=7159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}