Skip to Content
Technical Articles
Author's profile photo Shivani Sahu

SAP OOPS LOCAL ABSTRACT CLASS PART: 2

INTRODUCTION

Hello everyone! This blog post describes how to create an ABSTRACT CLASS in SE38.

This is the second part of ABSTRACT CLASS.

Part 1 includes the steps to create GLOBAL ABSTRACT CLASS. If you haven’t checked out yet, Link is hereSAP GLOBAL ABSTRACT CLASS & OOPS PART:1

In this blog, we have mentioned the code along with result. Hope this will help the readers who are searching how to write abstract class in SE38.

STEPS TO CREATE LOCAL ABSTRACT CLASS

STEP1: Use tcode SE38. Enter the name of program then click on CREATE button.

STEP2: Write the description of the program or class. Keep TYPE as EXCUTABLE. Click on SAVE button.

STEP3: Save as local object or if we have any package then mention the name of package and click on SAVE button.

We are saving in local object.

STEP4: Write the code.

Parameters: p_kunnr type kunnr.

DATA: G_FNAME TYPE NAME1_GP,
      G_SNAME TYPE NAME2_GP,
      G_CITY TYPE NAME2_GP,
      G_STREETNO TYPE STRAS_GP.

CLASS class1 DEFINITION ABSTRACT.
  PUBLIC SECTION.
  METHODS DISPLAY ABSTRACT IMPORTING IV_KUNNR TYPE KUNNR
                  EXPORTING EV_FNAME TYPE NAME1_GP
                            EV_SNAME TYPE NAME2_GP
                            EV_CITY TYPE ORT01_GP
                            EV_STREETNO TYPE STRAS_GP.
ENDCLASS.

CLASS CLASS2 DEFINITION INHERITING FROM CLASS1.
PUBLIC SECTION.
METHODS DISPLAY REDEFINITION.
ENDCLASS.

CLASS CLASS2 IMPLEMENTATION.
  METHOD DISPLAY.
  SELECT SINGLE NAME1 NAME2 ORT01 STRAS
    FROM KNA1
     INTO ( EV_FNAME , EV_SNAME , EV_CITY , EV_STREETNO )
       WHERE KUNNR = P_KUNNR.
    ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
DATA: OBJECT1 TYPE REF TO CLASS2.
CREATE OBJECT OBJECT1.
OBJECT1->DISPLAY( EXPORTING IV_KUNNR = P_KUNNR
                  IMPORTING EV_FNAME = G_FNAME
                            EV_SNAME = G_SNAME
                            EV_CITY  = G_CITY
                            EV_STREETNO = G_STREETNO ).

WRITE:/ 'DETAILS ARE:',
      / 'FIRST NAME :', G_FNAME,
      / 'SECOND NAME :', G_SNAME,
      / 'CITY NAME :', G_CITY,
      / 'STREET NUMBER :', G_STREETNO.

RESULT

Hope this blog will help readers to create local Abstract Class in SAP ABAP OOPs with these 2 parts of the blog.

 

Assigned Tags

      7 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Prerna Pradeep Sahu
      Prerna Pradeep Sahu

      Useful Info. Being a beginner much needed.

      Author's profile photo Matthew Billingham
      Matthew Billingham

      Are you going to move onto Interfaces next?

      Author's profile photo Shivani Sahu
      Shivani Sahu
      Blog Post Author

      No, interface is already covered in blogs.

      Author's profile photo Matthew Billingham
      Matthew Billingham

      So are abstract classes.

       

       

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Who cares, the important part is that HCL can brag on LinkedIn about their "amazing" content: https://www.linkedin.com/feed/update/urn:li:activity:7081594759579938817?utm_source=share&utm_medium=member_desktop

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Shivani Sahu your LI profile says you're an SAP certified developer. I think you could do much better than these, sorry to say, primitive posts with very old-fashioned code examples.

      There is the whole chapter in Clean ABAP on abstract classes and interfaces, with good examples and all. Highly recommend reading it. It's not going to tell step-by-step how to create a class in SE24 or a report in SE38. But these steps are not different than creating a regular class. And if someone doesn't know how to do that that, are they're ready to understand this material? Doubtful. Not to mention, why aren't we showing readers in 2023 how to do these steps in Eclipse?

      I also work for a consulting company, so I understand there might be pressure to post something online to generate buzz. No problem with that. But honestly, if someone from Mindset posted stuff like this on SCN, we'd have a serious conversation about it.

      Please do some research before writing the next post and instead of just step-by-step, consider truly sharing your expertise and offering readers more thoughts on whether they should be doing these steps and why.

      Thank you!

      Author's profile photo Shivani Sahu
      Shivani Sahu
      Blog Post Author

      Hi Jelena,

      This is the first topic that I've covered in "BLOG", I know I'm certified but it doesn't mean that I can not post on any basic topic.

      Related with the point of eclipse, this I will consider it,

       

      Thank you.