Category: SAP

  • Difference between a Static Breakpoint and Dynamic Breakpoint

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

    Introduction

    Before jumping to the difference between a Static Breakpoint and Dynamic Breakpoint, let’s have a short introduction of the two.

    What is a Breakpoint in SAP ABAP?

    A Breakpoint is a signal in a specific line of the ABAP program that interrupts the normal execution of the program and the control is transferred to the Debugger. A breakpoint can be active or passive at runtime and can be set for the specific users, all users or based on checkpoints. Breakpoints help in debugging and analysing ABAP Objects, ABAP programs and evaluating only the concerned sections of ABAP code, while skipping the rest of the areas.

    Static Breakpoint

    Static Breakpoints are recommended for use only during the development of an application where the program execution needs to be interrupted at the same point for analysis. These must be deleted once the development phase is over. These are set by an ABAP statement and can be of the following types:

    • User non-specific: These are inserted by the ABAP keyword BREAK-POINT. These are applied to all users and the system interrupts the execution for all the users.
    • User-specific: These are inserted by the ABAP keyword BREAK <USERNAME>. These are applied to the specified user and the system interrupts the execution for the specified user.

    Dynamic Breakpoint

    Dynamic Breakpoints are triggered when the program that you are running reaches a particular ABAP statement or exception class. These are user-specific and gets automatically deleted when the user logs off. A total 30 dynamic breakpoints can be set without changing source code.

    Dynamic Breakpoints are more flexible than Static Breakpoints as the former can be created, deactivated or deleted at runtime. Dynamic breakpoints can be set even when the program is locked by another user.

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

    Difference between a Static Breakpoint and Dynamic Breakpoint

    Static Breakpoint Dynamic Breakpoint
    They can be set using statement “BREAK-POINT” and “BREAK <USERNAME>” in ABAP code. They can be set in ABAP editor and in debugging mode.
    These are not normally user specific; but can be set for specific users. These are user specific.
    These cannot be set when the program is locked by another user These can be set even if the program is locked by another user.
    These needs to be deleted manually. These are deleted automatically when you log-off from SAP.

  • How to Create SAP OData

    Preface – This post is part of the SAP ABAP OData Tutorial series.

    Introduction

    In our previous article, we have already discussed what an OData is. In this article we will go through step by step process to create a SAP OData service. Later on, we will register our service and also test if it is working fine. In this article, we will not write any code related to CRUD (create, write, update and delete). To learn CRUD in OData, click here.

    Step by Step Process to create SAP OData service

    In this section we will follow multiple predefined steps to create an OData, these are:

    1. We will use SAP Service Gateway Builder (SEGW) to create a new project
    2. We will Import DDIC/CDS or other Structure to create an OData Model
    3. We will Generate our OData
    4. We will Register and test our Service

    Create a new Service Builder project

    To create a new project, follow the given steps:

    1. Go to transaction code SEGW, it will start the Gateway Service Builder.
    2. Click on the Create Project button, as shown below:
    3. Enter the given information
    Field Description Example
    Project It is the name of your SAP OData Service. It will start with Z or Y ZPROJECT_NAME
    Description Enter a description for your OData Demo OData Project
    Project Type SAP Provides given four Project Options:

    1.       Service with SAP Annotations

    2.       Service with Vocabulary-Based Annotations

    3.       Annotation Model for Referenced Service

    4.       OData 4.0 Service

    We will learn about them in details, later.

    Service with SAP Annotations

     

    Generation Strategy It will be preloaded as Standard which means, it has all standard configurations. Standard
    Package Enter your project package or temporary package i.e. $TMP $TMP
    Person Responsible It will be preloaded with your User ID/ User Name barryAllen

    OData creation

    1. Press Continue and Save.

    Import a DDIC structure

    To use an OData Service, it should be designed in such way that it will read/update one or more table. Therefore, we need to import any table, structure or view. These are part of DDIC structure. We can also import Data model from file, RFC/ BOR Interface or a search help. But in this section, we will learn how to import a DDIC structure:

    1. Click on the Data Model under the project we have recently created to expand it.
    2. Right Click on Data Model and click Import and then click DDIC Structure
      OData DDIC Import
    3. Now, a Wizard will open. Enter the following details, there:
    Field Description Example
    Name Enter a name of Model. It should be explanatory. CustomerData
    Type We have two options here:

    1.       Entity Type: This means a simple DDIC structure/table/view will be imported

    2.       Complex Type: This means a complex DDIC structure/table/view will be imported

    Choose Entity Type
    ABAP Structure Choose your required table or structure name. Just copy and paste the name of your DDIC table/structure/view zcustomer_data
    Create Default Entity Set It will create an Entity Type with the same fields as of Entity. Also, the name will remain same. We recommend you to leave it check marked. Leave it check marked

     

    The above details are shown below:
    OData Entity Set Creation

    1. In the next step, the wizard will show all the fields of the imported table. Just select them all and click next as shown below:
      OData Entity Set Creation2
    2. In the next step, the wizard will show all the checked fields. Here you need to check the primary keys and finish, as shown below:
      OData Entity Set Creation3

     

    Generate OData Service

    Now, we have created an OData object with a model. Now to use this Object we need to generate all the required classes. To generate, press the Generate Runtime Objects  OData Generate Icon button, as shown below:

    OData Generate Runtime Objects

    Note: The Generate Runtime Objects button automatically saves the project before generating classes.

    Pressing the above button, will open a dialog box as shown below:

    OData Class Generation

    Just press Continue, as shown above. The above process will generate following classes:

    Class Name Description
    MPC Class MPC stands for Model Provider Class. This is generated and refreshed every time, we generate a class. It is not recommended to extend this class for Model Annotations, because all the methods are deleted whenever the OData is generated.
    MPC EXT Class This is the Extended MPC class, and all the methods are conserved even the OData is generated.
    DPC Class DPC stands for Data Provider Class. This is generated and refreshed every time, we generate a class. It is not recommended to extend this class for CRUD operation, because all the methods are deleted whenever the OData is generated.
    DPC EXT Class This is the Extended DPC class, and all the methods are conserved even the OData is generated.
    MDL Class The is the Model Class.
    SRV Class This is the Service Class.

     

    Just click on Lock Object to generate the classes, as shown below:

    OData Service Generation

    Register SAP OData using the Gateway client

    Once the OData is generated, now it is the time to register the service. Once the service is registered, then only it can be used anywhere.

    To generate an OData, follow the given steps:

    1. Double click the node Service Maintenance
    2. Select any System and click Register as shown below:
      OData Service Register
    3. Enter an Alias, if asked as shown below:
      OData System Alias
    4. Now, in the next screen you get following options:
    Field Description
    Technical Service Name This is auto generated service name
    Service Version It is auto generated service version
    Description It is the Description of the OData you have mention earlier
    External Service Name It is same to the auto generated service name
    Namespace It is by default bank
    External Mapping ID It is by default Empty
    External Data Source Type It is by Default set to source type C
    Technical Model Name It is auto generated Model Name
    Model Version It is auto generated Model Version
    Package Assignment Assign your package name here, or just choose Local Object from the button below. It will be then $TMP
    ICF Node It is by default “Standard Mode”
    oAuth Enablement It provides option to add extra authentication, in case you need oAuth2 enablement choose it, else leave it blank

     

    In our case, we just need to choose package and click confirm, as shown below:

    OData Service Registration

    Once the service is registered, the Registration will turn green, as shown below:

    OData Service Status

    Test the OData service

    1. To test the OData service, click the SAP Gateway Client button, as shown below:OData Test Service
    2. It will open a new screen, here click Add URI Option as shown below:
      OData Add URI Option
    3. Choose $metadata, here:
      OData $metadata
    4. Click Execute as shown below:
      OData Service Status 200

    If the status is 200, as shown above, then it means your OData is working fine.

    In upcoming articles, we will learn how to perform CRUD operation using OData.

    Tutorial Video

    You can watch the below video to learn implementation:

    [embedyt] https://www.youtube.com/watch?v=2rEZrFj2haE[/embedyt]
  • Difference between Procedural Programming and Object-oriented Programming

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

    Introduction

    Before jumping to the difference between a Procedural Programming and Object-oriented Programming, let’s have a short introduction of the two.

    Programs are the instructions that tell the computer what to do to come up with the solution to a particular problem. There are several approaches to building solutions to specific types of problems with programming. Two of the most important approaches are procedural programming and Object-Oriented Programming.

     

    Procedural Programming

    Procedural Programming is a structured programming approach, based upon the concept of calling procedures which consists of a series of computational steps to be carried out. It follows Top Down approach to solve any problem. There is no accessing mode required to access the attributes or functions of a particular program. There is no proper way of hiding data, hence it is less secure.

    Object-oriented Programming

    Object-Oriented Programming is based upon the concept of Objects and Classes. It follows Bottom Up approach to solve the problem. The OOP paradigm focuses on the data rather than the algorithm to create the modules by dividing into the data and functions. An object contains the data in the form of attributes and codes in the form of methods. It provides data abstraction; hence it is more secure than procedural programming.

    Procedural Programming and Object-oriented Programming

    Procedural programming is simple and straight forward as it allows good isolation and containment for variables when properly scoped with functions and control loops. But it becomes more prohibitive to maintain the larger codes.  Here comes the Object-oriented Programming which makes it easy to maintain the codes as new objects can be created which control their data. SAP provides us option to implement of them altogether.

    Difference between Procedural Programming and Object-oriented Programming

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

    Procedural OOPs
    It is process-oriented. It is result-oriented.
    Follows Top down approach. Follows Bottom up approach.
    Each function contains different data. Each object controls its data.
    There is no access specifier They have access specifiers such as Private, Public, Protected etc.
    Adding new data and function is not easy. Adding new data and functions is easy.
    Overloading is not possible. Overloading is possible.
    It is less secure. It is more secure.
    No concept of inheritance. Inheritance is allowed.

     

  • Difference between SAP Memory and ABAP Memory

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

    Introduction

    Before jumping to the differences between SAP memory and ABAP Memory, let’s have a short introduction.

    ABAP programs utilize two types of memory: SAP memory and ABAP memory. The main difference between the two memories is their scope.

    SAP Memory and ABAP Memory

    ABAP memory is very limited as it can only accessible within one internal session and programs running outside the session are not able to read or write this memory. Whereas, SAP Memory is a global memory and is accessible to all the programs running under that session as well as across different main sessions. SAP memory can be used to pass data from one program to another either within a session or to another session.

    In terms of usage, the main use of ABAP memory is to make data accessible to multiple programs within the same session. Whereas, SAP memory also makes data available across multiple sessions.

    When dealing with SAP memory, GET/SET parameters are used to exchange data. To set these parameters for a user or a program, SET PARAMETER is used and other programs can then retrieve the parameter using the GET PARAMETER command. On the other hand, ABAP memory can be accessed by the ABAP programs within the same internal session using IMPORT and EXPORT commands. Data within this memory remains intact during a sequence of program calls.

    It is important to they are used appropriately to enhance the speed and efficiency of the application as well as resource usage.

    Difference between SAP Memory and ABAP Memory

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

    SAP Memory ABAP Memory
    It is a Global Memory. It is a local Memory.
    All SAP GUI sessions have access to it. All programs within a session can have access.
    It makes data available across main session It makes data available multiple session within same session.
    Data can be exchanged using GET/SET. Data can be exchanged using EXPORT/IMPORT.

     

  • Data Class vs Delivery Class in SAP ABAP: Differences

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

    Introduction

    The most common question of an ABAP Interview is the difference between Data Class and Delivery class of an ABAP Table. In our previous articles, we have discussed both in detail and now we will discuss their differences.

    Before jumping to the difference between a Data Class and Delivery class, let’s have a short introduction of the two.

     

    Data Class

    A Data Class represents a physical area in the database where all the data of the table assigned to this Data Class are stored.

    Data Class in ABAP can be assigned to a table using its Technical Settings. SAP was smart while creating properties for tables. With the help of Data Class, SAP divides and organize the Tables according to their type of Data. It keeps all Master Data together, all Transaction Data together, all User Data together and all Organizational Data together. This increases system performance as well as increases system availability.

    Types of Data Class are:

    • APPL0 (Master Data): Data which is rarely changed.
    • APPL1 (Transactional Data): Data which is changed frequently.
    • APPL2 (Organizational Data): Data defined when the system is installed and seldom
    • USER and USER1 are provided for the customer.

     

    As Data Class determines the type of data the table contains, the Delivery class determines the behaviour of the table.

     

    Delivery Class

    A delivery class defines:

    • Transport control of Data within Landscapes and customer systems
    • Transport control of Data for an installation and upgrade
    • Transport control of Data of client copy
    • If data can be maintained in Extended Table Maintenance [SM30] using TMG or not.

     

    In short, we can say a delivery class determines whether data of the table can be maintained & transported or not.

    Types of Delivery Class are:

    • A: Application table (master and transaction data).
    • C: Customer table, data maintained by the customer only.
    • L: Table for storing temporary data

     

    Difference between Data Class and Delivery class

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

    Data Class Delivery Class
    It determines the actual physical area of database where table is created It controls the degree to which SAP or customer is responsible for table maintenance
    It is set in Technical settings for the table It is set in Delivery & Maintenance
    It determines the type of data the table contains. It determines the table type.
    They are of 5 types:

    APPL0 à Master Data

    APPL1 à Transactional Data

    APPL2 à Organizational Data

    USER, USER1

    Following are the delivery classes:

    Aà Application table

    Cà Customer table

    L,G,E,S,W

     

     

  • Difference between Domain and Data Element

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

    Introduction

    Before jumping to the difference between a Domain and Data Element, let’s have a short introduction of the two. We need to use data in ABAP reports and it needs to be define in ABAP Dictionary and for that we need to define Domain, Data Element and, Tables.

     

    Domain

    A domain is a reusable object which describes the technical characteristics of an attribute. It defines a value range, which sets the permissible data values for the fields, data types, conversion routine, etc. A single domain can be used for any number of fields of identical structure.

    With the help of domain, lowercase letters can be entered into the table fields.

     

    Data Element

    A domain cannot be directly used in a Report/Program or as a table field, it is assigned to a data element that adds some semantic information to the field i.e. Field Label, heading, etc.

    Data Element is the smallest individual component of the complex types and is used to provide field labels, documentation, parameter ID, and search help for the table field.

     

    At Domain level, Search Help fetches data either from defined fixed value or Value Table while Search help assigned to Data Element fetches data from Global Search help created via SE11.

     

    Difference between Domain and Data Element

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

    Domain Data Element
    It is used to describe the technical characteristics of an attribute. It is used to describe the semantic definition of the table field.
    It describes the value range, data types, and conversion routine. It provides field labels, documentation, parameter ID, and search help for the table field.
    Search help assigned to it fetches data from either fixed value or Value Help Table. Search help assigned to it fetches data from Global Search help created via SE11.
    It is assigned to a data element. It is assigned to a table field or structure.
    It cannot be referenced in ABAP programs. It can be referenced in ABAP programs with TYPE.
    It is stored in Standard Table DD01L and Domain texts are stored in DD01T. It is stored in standard Table DD04L and Data Element texts are stored in DD04T.

     

  • Subroutine in SAP ABAP

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

    Introduction

    A good coder always tries to reduce repetitive codes and implements codes in such way that it can be reused. Subroutine in SAP ABAP provides us the same functionality. In this article we will learn what it is and how to implement it in SAP ABAP.

    What are Sub Routine

    A Subroutine in SAP ABAP is a well-defined reusable procedures used for code modularisation. Subroutines can be used locally in a program.

    It is written between FORM and ENDFORM.

    PERFORM subroutine is used to invoke subroutine.

    Passing values with Subroutines

    There are 2 ways to pass values with subroutines:

    Pass By Value

    • In this the actual and formal parameter refers to different memory.
    • IF the value of formal parameter is changed then the value of actual parameter won’t change.
    • Keyword VALUE identifies that the parameter is passed by value.

    Pass by Reference

    • In this the actual and formal parameters refer to same memory.
    • If the formal parameter is changed, actual parameter also changes.

    Types of Subroutines

    Internal Subroutines

    Subroutines that are defined in the same program and called within the same program.

    External Subroutines

    Subroutines that are defined in a program and are called in a different program are called as external subroutines.

    How to create a are Sub Routine Module in SAP

    1. Go to SE80
    2. Select your program for which you want to create a subroutine -> select -> create a subroutine (name it).
    3. Write a code in FORM and ENFORM and if u want to call it as an internal subroutine then PERFORM has to be included.

    Calling a Subroutine

    Internal Subroutines

    REPORT PROGRAM NAME.

    PERFORM SUBROUTINE NAME.

    FORM SUBROUTINE NAME.

    P1 TEXT

    FORM SUBROUTINE NAME.

    Write:  ‘This is internal subroutine’.

    ENDFORM.

    External Subroutines

    FORM FORMNAME.

    Select *from MARA into table it_mara where matnr is s_matnr.

    ENDFORM.

    To call this form in a program.

    PERFORM subroutine_name IN PROGRAM program_name.

    Advantages of Sub Routine

    • Pass by value allocates new memory location for use in subroutines
    • Pass by reference passes a pointer to a memory location.

     

  • Message Class in SAP ABAP (SE91): Create & Use Examples

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

    Introduction

    To issue a message or warning or error or any kind of information in ABAP, either we have to hard code that message or maintain it in text symbols. What if the same message is required somewhere else like in any other program or class, again hard coding it or maintaining in text symbol would be recurring and inefficient procedure.

    Instead of doing this, we can collect all the messages at one place and use it multiple times and at multiple places, that one place is nothing but a message class. Any message can be identified with a unique number assigned to it. To use a message from message class in any ABAP program or in any class, we only need to specify the message class, message number and message type.

    Definition

    Message Class is like a container which contains all messages in it. All the messages from different message classes are stored in database table T100.

    Message Class Creation

    A message class can be created in two ways:

    1. Through transaction code SE91.

     

    Message class creation through T-Code SE91
    Message class creation through T-Code SE91

     

    Message class Maintenance Screen
    Message class Maintenance Screen
    • Syntax of calling these messages from message class in ABAP Programs:

            MESSAGE <type of message><message number>(message class name) WITH <parameter>.

    Example 1 : MESSAGE I000(ZTEST_CLASS).                                                     “Information Message

    Example 2 : MESSAGE E0001(ZTEST_CLASS) WITH 0001.                                     “Error Message

    Note: In figure 2, message text at 001 position is having ‘&’. With this operator we can pass text/literals whatever we want to display. So, for example 2 message will get displayed as:

     ‘The value 0001 is invalid’.

    1. Through report.

    Syntax : REPORT <Report Name> message-id <Message Class>

    “Double click on message class name to create a message class.

    Advantages

    A single message can be used multiple times at multiple places, we don’t need to hard code same message or maintain the same text symbols in different programs.

  • What is SAP OData

    Preface – This post is part of the SAP ABAP OData Tutorial series.

    Introduction

    If you plan to expose your SAP Data (Table or Query Data) to external environment like UI5/Fiori or HANA, then you need to push your data in a form of API. By API we mean, using OData we will generate a service link that can be accessed via internet and can be used to perform CRUD operations. SAP OData in SAP ABAP environment is just like another ABAP Class. We can access the methods of this class using SEGW transaction. We can write our required code here for the data manipulation and once we activate the class, the service link that we generate will act accordingly.

    Definition

    SAP OData is a standard Web protocol used for querying and updating data present in SAP using ABAP, applying and building on Web technologies such as HTTP to provide access to information from a variety of external applications, platforms and devices.

    In SAP, we use SEGW transaction code to create an OData Service. SEGW stands for Service Gateway.

    Architecture of SAP OData

    Here, we will discuss about the High level architecture of SAP OData.

    SAP OData High Level Architecture
    SAP OData High Level Architecture

    Why we need ODATA

    SAP OData comes with multiple advantages. It not only helps us to expose data but also helps a customer to access data from anywhere and any device. If there will be no OData services, then the data will remain on premise and in case a user needs to access their data, they might have to visit the data location, which is uncomfortable for the digital world.

    Advantages of an ODATA

    Using SAP OData provides us following advantages:

    • It helps to obtain human readable results i.e. you can use your browser to see the output data
    • It is very easy and relatively fast to access data
    • It uses all the standards of web protocols i.e. GET, PUT, POST, DELETE, and QUERY
    • It uses Stateless Applications: It means Server does not save any data of Client (e.g. UI5 Application) and treats every OData call as a new call
    • It receives data in form of related pieces of information, one leading to another: It is an interaction pattern known as “alert-analyse-act”, “view-inspect-act”, or “explore & act”. According to this pattern not all data are loaded together, and a user analyses a data and reaches its required information after navigation. In this way the data loads quickly and correctly.

    SAP OData V2 (Version 2)

    OData v2 is a set of new standards which are add-ons to SAP OData V1, and these are as follows:

    • Client-side sorting and filtering
    • All requests can be batched
    • All data is cached in the model
    • Automatic Message handling

    You can read more about SAP OData v2 vs OData v1 here.

    SAP OData V4 (Version 4)

    OData v4 is the latest upgradation to the SAP OData services which comes with some addition and some reduction of features, such as:

    • The new version brings simplification in terms of data binding. The new OData V4 model simplifies the data binding parameter structure.
    • OData v4 requires only asynchronous data retrieval.
    • The Batch groups are solely defined via binding parameters in the new OData v4 calls with the corresponding parameters on the model as default.
    • It supports use of an operation binding. And now it is much easier to bind operation execution results to controls.
    • Create, Read, Update and Delete (Remove) operations are available implicitly via the bindings
    • In OData v4, the Metadata is only accessed via ODataMetaModel

    You can read more about SAP OData v4 vs OData v2 here.

  • SAP Package

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

    INTRODUCTION

    A development class (container) to store different development objects together that are developed by a developer. Earlier anyone could use any developed object because everything was stored in a flat structure. In order to set up protection for developers’ development object package concept was introduced. In order to address technical modularization in large scales for developed objects SAP Package concept was introduced.

    SAP PACKAGE BUILDER CONCEPT

    • Packages are a further development of the current development classes with added semantics.
    • They are designed to help developers encapsulate, modularize, decouple units in the SAP System.
    • They extend the concept of development classes with added attributes as nesting, interfaces, visibility and use accesses.

    SAP PACKAGE BUILDER

    1. It helps to implement the concept of packages in ABAP Workbench.
    2. It can be called using transaction SE21 or SPACKAGE.

    Features of SAP PACKAGE BUILDER

    1. It helps to create packages and sub packages.
    2. It can specify a package hierarchy.
    3. Define package interface for users.

    HOW TO CREATE A PACKAGE IN SAP.

    1. Enter the package name -> create.

    SAP Package Builder

    2. Package is either created or you can display a created one.

    SAP Package Creation

    3. It has certain attributes.

    1. Package Interfaces:
    • In order to make package content visible.
    • Only those package element that are added in the interface are visible.
    • Package make their services available to other package using the package interface.

    SAP Package Interface

         2. Sub Packages

    • It holds an attribute of packages ‘Nesting’.
    • A package can be created /or an existing package can be added.

    SAP Sub Package

         3. Package Hierarchy

    • The main focus is to provide a structure for packages.
    • Sub packages can be inserted inside main package.
    • This shows the depth to which they are nested.

    HOW TO MOVE OBJECTS FROM ONE PACKAGE TO ANOTHER.

    Go to SE80 -> Give the program name -> Right click-> Additional functions -> Change package assignment.

    SAP Package Assignment

    After giving the new package name -> ok.

    Assign Object to a Package

    SAP PACKAGE TABLES

    TDEVC

    SAP PACKAGE TABLES