Category: SAP

  • Difference between Enhancement point and Enhancement spot

    Preface – This post is part of the Differences in ABAP for Interviews series.

    Introduction

    Every year SAP provides a new update to its platform. All the SAP standard programs are designed in such a way that it meets almost all the requirements of a user of a particular sector. But sometimes, there comes a requirement that user wants something else that SAP program is providing. In this case, the simplest way is to modify the source code to meet the requirement. But the disadvantage in doing so is that the modification is erased as soon there is an update. To fix this issue, SAP introduced something called Enhancement framework. These enhancements are added in form of small hooks also known as Enhancement points. In this article we will discuss the difference between Enhancement point and Enhancement spot.

    Enhancement Point

    Enhancement points are the position in a SAP ABAP program where enhancement are made. The enhancements, when complied with the current source code work as if it was a part of the source code.

    Enhancement Spot

    All the enhancements can be added as per the SAP framework guidance or directly by the developer (explicitly). These positions available to a developer is termed as Enhancement options.

    When the enhancement is made based upon the developers choice, then these information are required to be stored in a container with their positions. These containers are termed as Enhancement Spot.

    Difference between Enhancement point and Enhancement spot

    Enhancement Point Enhancement Spot
    It is mainly predefined locations in SAP ABAP. It is mainly explicit and created by developers.
    It is placed with the help of ENHANCEMENT-POINT statement. It is placed with the help of SAP Enhancement Wizard in SE80.
    Enhancement point basically contains codes. Enhancement Spot basically contains the positions of Enhancement Options or Enhancement points.

     

  • Difference between Singleton Class and Persistent Class

    Preface – This post is part of the Differences in ABAP for Interviews series.

    Introduction

    SAP OOABAP provides different types of classes to handle different types of scenarios. Some of the classes are the part of SAP Design patterns to perform a specific type of workflow, whereas others are there to perform core functions. In this article we will compare two of them. Let us discuss the difference between Singleton Class and Persistent Class in SAP ABAP.

    Singleton Class

    Sometimes there is a need to instantiate an object at a time, that means only one instance is required at one point of time. This is a very common requirement while designing an application. To achieve such a scenario, there is one concept of ‘Singleton Pattern’ or ‘Singleton Class’ in OOABAP.

    A class is said to be a singleton class if it can have the utmost one instance only.

    Persistent Class

    Before going for persistent class, let’s first discuss the meaning of ‘persistent’.  A data is said to be persistent if it can be preserved beyond the runtime of program.

    For a session, ABAP program stays in local ABAP memory till the runtime of that program. To store it permanently, we use persistence service (implemented by persistence class).

    Difference between Singleton Class and Persistent Class

    Singleton Class Persistent Class
    It can have only one instance. It can have multiple instances.
    It cannot store data beyond runtime. Data can still persist beyond runtime.
    It is used for functions like single sign-on and logger. It is used for functions like booking system where particular transaction blocks a seat/item.

     

  • Difference between Enhancements and BADI

    Preface – This post is part of the Differences in ABAP for Interviews series.

    Introduction

    Every year SAP provides a new update to its platform. All the SAP standard programs are designed in such a way that it meets almost all the requirements of a user of a particular sector. But sometimes, there comes a requirement that user wants something else that SAP program is providing. In this case, the simplest way is to modify the source code to meet the requirement. But the disadvantage in doing so is that the modification is erased as soon there is an update. To fix this issue, SAP introduced something called Enhancement framework. In this article we will discuss the difference between Enhancements and BADI.

    Enhancements in SAP ABAP

    As discussed earlier, SAP introduced Enhancement framework to enhance a particular piece of source code. To keep these process easy and flexible, SAP provides certain area where these enhancement codes can be added. These are called “hooks”. The best part of these enhancements is that they behave like the actual code and at the same time, they are transported separately among the different landscapes.

    BADI in SAP ABAP

    Earlier, we have seen that we were able to add code into the source code and transfer the same to different landscapes. SAP later created a new type of enhancement framework which uses Object Oriented concepts. This new Enhancement technique, thus, was created in form of class and objects and was available for reuse.

    BADI stands for Business Add-Ins. They are object oriented based enhancement techniques that can be reused.

    Now let us discuss the difference between Enhancements and BADI.

    Difference between Enhancements and BADI

    Standard Enhancements BADI
    A standard Enhancement technique can be used only once. A BADI can be used any number of times.
    They are not object oriented. They are purely object oriented.
    They are easy to implement. It is the most sophisticated enhancement.
    These are mainly changed only by developer. The BADI codes are separated from the source code, hence customer too can do further implementations using BADI.

     

  • Difference between OPEN CURSOR and FETCH CURSOR

    Preface – This post is part of the Differences in ABAP for Interviews series.

    Introduction

    In previous article we have discussed the difference between Cursor and Select Statements. In this article we will focus upon the differences between Open Cursor and Fetch Cursor. Both Open Cursor and Fetch statements are part of SQL queries. Interestingly, both statements are dependent upon each other and are used to extract data or perform operations on SAP tables.

    OPEN CURSOR

    A cursor in SAP is like a pointer in other coding languages. It points towards the result of specific data selection. Unlike SQL query like SELECT, cursor doesn’t store any data in a variable, rather it points data with the help of a variable. To use cursor, we need to open it up, fetch required data and the close the cursor after its use. SAP allows 17 Open cursors at a time.

    OPEN CURSOR is a SQL statement that is used to open a database cursor and hold the pointer/cursor in a local variable.

    Syntax:

    OPEN CURSOR [WITH HOLD] dbcur FOR
      SELECT { select_clause
               FROM source }
            |{ FROM source
               FIELDS select_clause }
               [[FOR ALL ENTRIES IN itab] WHERE sql_cond]
               [GROUP BY group] [HAVING group_cond]
               [UNION [ALL|DISTINCT] select]
           [ORDER BY sort_key]
               [additional_options].

     

    Here the local variable dbcur is holding the cursor value. Select statement tells the cursor, what to hold.

    FETCH CURSOR

    Once we open a cursor, then we need to use the same with the help of another SQL query i.e. FETCH. A FETCH query extracts the requested row from the result set of the previously opened cursor (dbcur) and assigns them to a local variable.

    Syntax:

    FETCH NEXT CURSOR dbcur INTO|APPENDING ....

    Difference between OPEN CURSOR and FETCH CURSOR

    OPEN CURSOR FETCH CURSOR
    OPEN CURSOR does not store the data in any variable during runtime. A FETCH statement stores the data of a cursor in a local variable during runtime.
    OPEN CURSOR points to a data of a table. A FETCH statement actually stores data of a table in local variable.
    OPEN CURSOR is the very first step of a CURSOR pattern. FETCH statements are second and most important step of CURSOR pattern.
  • Difference between Singleton Method and Static Method

    Preface – This post is part of the Differences in ABAP for Interviews series.

    Introduction

    Before discussing the differences between a Singleton method and Static method, let’ have a quick introduction. A method is a block of codes that defines behaviour of an object of the class. The method can access all the attributes of the class and can change the object data content.

    Static and Singleton methods in SAP ABAP are very different in their usage and implementation. So it is very important to choose wisely either of them in our WRICEF.

    Singleton Method

    Sometimes there is a need to instantiate an object at a time, that means only one instance is required at one point of time. This is a very common requirement while designing an application. To achieve such a scenario, there is one concept of ‘Singleton Pattern’ or ‘Singleton Class’ in OOABAP.

    A class is said to be a singleton class if it can have the utmost one instance only.

    Static Method

    Static methods are defined using the CLASS-METHODS statement. They are called only once, when the program is started, irrespective to the class instance, and don’t get reinitialized throughout the execution of the program. They can access only static attributes and can trigger only static events of the class. They can be directly accessed by the class name itself.

    When shall we use singleton method and when to go for static methods?

    Static methods are the one that are meant to store the initialization information and should be available globally.  Whereas the most wide usage of singleton method is creating logs and single sign-on.

    Difference between Singleton Method and Static Method

    Singleton Method Static Method
    It is a design pattern. It is not a design pattern.
    It can be instantiated only once. It is triggered by a static component (static class, attributes and events) only and no instance components.
    It is implemented in a specific scenario where we cannot have multiple instances like login. It is widely used for single time initialization.

     

  • Difference between Structure and work area

    Preface – This post is part of the Differences in ABAP for Interviews series.

    Introduction

    We have already discussed Work Area and Structure in SAP ABAP. We already know how they are created and used within the ABAP Report programs. Structure and Work Area in ABAP coding are almost same. It is hard to specify any difference. In this article we will discuss the difference between Structure and work area.

    Structure in SAP ABAP

    A Structure in SAP ABAP is a part of group TYPES in SE11, which consists components that also, refer to a type.

    In simple terms, a structure is a reusable component that contains fields and holds single records at runtime.

    Work Area in SAP ABAP

    A work area in ABAP represents single row of an internal table and it is used to process internal table line by line. It holds only single data at runtime.

     

    Difference between Structure and work area

    Structure Work Area
    A structure is created using SAP Data Dictionary (SE 11) as well as within a ABAP program. A work area is created within a report or Function Module.
    A structure can be a global as well as a local component. A work are is a local component
    A structure is reusable across all the ABAP programming interfaces and data dictionary. A work area is reusable within the report it is created.
    A structure can be nested at multiple levels. A work area cannot be nested.
  • Difference between BAPI and RFC in SAP ABAP

    Preface – This post is part of the Differences in ABAP for Interviews series.

    Before discussing the difference between BAPI and RFC, let’s have a short introduction of the two.

    BAPI

    BAPI stands for Business Application Programming Interface. BAPIs are the specific methods that are stored in BOR (Business Object Repository) of the SAP system to carry out a specific business task. It enables the exchange of business data between SAP components, and between SAP and non-SAP components. It allows integration at the business level rather than technical level. It is stored as RFC enabled function modules in the ABAP Workbench Function Builder. To use a BAPI method to access the data in SAP business objects, an application program only needs to know how to call the method using the name of the BAPI and import/export parameters. Standard BAPIs are easier to use as it prevents the user from having to deal with a large number of different BAPIs. A standard BAPI is preferred over an individual BAPI.

    RFC

    RFC stands for Remote Function Call. It is a protocol for communication between applications of different systems in SAP environment that includes connections between SAP systems and between SAP systems and non-SAP systems.  It is a standard SAP interface for communication between different SAP systems. It describes an external interface to a system function module available in the SAP system. The functionality of R/3 applications can be extended from an external program using RFC interfaces.

    Using only RFC, an SAP system cannot be connected to a non-SAP system to retrieve the data. Only through BAPI, RFC can access the SAP system from a non-SAP system or vice versa.

    Difference between BAPI and RFC in SAP ABAP

    Now, let’s have a look at their difference.

    BAPI RFC
    It is an RFC enabled function module that provides external access to an SAP business application. It is a protocol for communication between applications of different systems in the SAP environment.
    It can be wrapped in Business Objects. It cannot be wrapped in Business objects.
    It can be compared to CGI applications. It can be compared to HTTP
    All BAPIs are RFC. All RFCs are not BAPI.
    Exceptions are not used in BAPI. Exceptions can be defined in the interface of the called function module

     

  • Difference between Exception handler and Event handler

    Preface – This post is part of the Differences in ABAP for Interviews series.

    Before discussing the difference between Exception handler and Event handler, let’s have a short introduction of the two.

    Exception handler

    Exceptions are events that interrupt the flow of executions and make the program to execute further impossible. So, the exceptions need to be handled.

    Exception situations can be detected and raised by either the program or runtime environment. Exceptions in the runtime environment are generally caused by the error situation that cannot be detected by the static program.

    Exceptions can be either handleable or non-handleable. Handleable exceptions are class-based that are predefined in the system or can be custom-defined. They can be raised by the RAISE EXCEPTION or THROW statement and handled by TRY – CATCH – ENDTRY.

    Non-handled exceptions create runtime error and the program terminates with a short dump.

    Event handler

    Events are messages raised by the object when a condition is met. The events are caught by the event handler method that implements the logic to handle the event. These are used by objects or classes that trigger the event handler methods in other objects or classes. Any number of handler methods can be called when the event is triggered. The link between the trigger and the event handler method is decided at run-time.  The event handler decides the event to which it wants to react.

    Using RAISE EVENT statement, the events of a class can be triggered in the methods of the same class. A method of the same or different class is declared as event handler method for the event evt of class class using the addition FOR EVENT evt OF class.

    Difference between Exception handler and Event handler

    Now, let’s have a look at their difference.

    Exception Event Handler
    Exceptions are the error that occurs during the execution of a program that interrupts the normal flow of the control. Events are the messages raised by an object which is raised when a condition is met
    Exception handler is a unit of code that is executed after detection of an exception. Event handler is a unit of code that is executed in response to an event.

     

     

  • SAP Smart Styles

    Preface – This post is part of the ABAP Beginner series.

    Introduction

    SAP Smart Styles are used to define paragraph and character formats. It can be assigned to texts and fields in the Smart Forms. A Smart Style has to be assigned to each Smart Forms. This is done globally for the entire Smart Forms in the Form Attributes of the Navigation window. It can be applied locally to a node that applies it to the entire subtree, overruling the global settings. A Smart Style can be reused. It can be downloaded locally and uploaded again later.

    SAP Smart Style Feature

    A Smart Style contains the following features:

    • Header data: It contains the default values of the font for the Smart Style. If different values are not assigned to the paragraph and character formats, the system uses these default values.
    • Paragraph format: It contains information on indents, spacing, font settings, text colors, tabs, numbering, and outline. It must have a unique name for each paragraph format.
    • Character format: It is used to assign special output effects such as superscript and subscript, barcode, and font attribute to sections of texts or character strings within a paragraph. Each character format must have a unique name.
    • Colors and underlines can be added to paragraph and character format.
    • Preview option.

    SAP Smart Style Feature

    Each Smart Styles has 3 predetermined nodes in the navigation window, namely, Header data, Paragraph formats, and Character formats.  The Header node contains the standard settings of the font for the Smart Style. It can be seen in the maintenance window. At the bottom, one can see the preview of the selected font.

    Steps to create Smart Style

    1. SMARTSTYLES is the transaction code for Smart Style. Enter SMARTSTYLES in the common field.

    Steps to create Smart Style

    Note:  SMARTFORMS t-code can also be used to create Smart Styles.

    1. Enter the Style name.
    2. Click on
    3. To activate, click on Activate

    Note: To use and transport a Smart Style, it has to be activated first. During activation, if the system finds any error, it displays an error list.

  • Garbage collector in SAP ABAP

    Preface – This post is part of the Object Oriented ABAP series.

    Introduction

    As a developer, we need not to explicitly configure memory allocation and deallocation in the system. This process triggers automatically, when the object is created memory is automatically allocated to it and when it is terminated the memory is destroyed by the background process called Garbage Collector to free up the space for new objects.

    The objects using dynamic memory allocation captures some memory and that memory is allocated until there are references to that object. When there is no reference to the object, it is assumed that the object is no longer need. Garbage Collector identifies the unused objects (no more references to the object are there) and scrap it out for other objects to reuse the space. It is called periodically by ABAP runtime environment.

    The programs that do not de-allocate memory at last collapse when there is no more memory left in the system to allocate. This scenario is termed as a memory leak in the program. As garbage collector is an automated process, the number of memory leak errors is minimised.

    Why proper Garbage Collection is important?

    Garbage collection plays an important role in system programming. The unseemly behaviour of the garbage collector can result in critical problems, like:

    • Increased memory requirement
    • Performance degradation

    Benefits

    Garbage collection eventually reduces or eliminates some bugs:

    • Dangling pointer bugs: When there are one or more references to the object is used in the program but the memory is freed.
    • Double free bugs: To free the memory which is already freed.
    • Memory leaks: When memory is not cleared and objects have no reference, this will lead to memory exhaustion.

    Drawback

    Garbage collectors can sometimes bring runtime overhead that can serve as the performance problem for a larger application. Hence, it is critical to implement the right garbage collection method to optimize the application performance.