Author: Rudramani Pandey

  • 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

  • Smart Contracts

    Preface – This post is part of the Blockchain Basics series.

    Introduction

    Since the blockchain was introduced, the common question was “How Blockchain will become a revolution?”. With the introduction of Ethereum in form of Solidity platform, the concept of Smart Contracts was developed. As it sounds they are the contracts handled in a smart way. It was introduced to automate the hectic contract signing process between two parties. In this article we will explore more about it.

    What are Smart Contracts

    A smart contract is a self-executing contract, which is automatically triggered once a condition is successfully met. This contract can be partially or fully executed with or without human interaction.

    Smart Contracts

    Advantages

    Following are the some of the advantages:

    • They are accurate, transparent and efficient as compared to paper contracts
    • They are are more secure
    • Better Storage and Backup
    • With blockchain it brings trust between two parties

     

    Use Case

    This concept can be easily understood by the example of Non-Disclosure Agreement signed by an employee whenever he/she joins an organization. The first step will be to automatically send each new joiner an agreement that can be digitally signed, once signed a digital password will be generated automatically and the credentials for official access can be sent to the new employee. These three steps don’t need any human interaction, and these can be easily achieved using smart contracts.

    This was a very simple explanation to replace human based operation with smart contracts. Once these are implemented in government offices for legal documentation, may help to curb corruption. They can even serve wider range of business problems and some of these use cases you can find in the given white paper: “Smart Contracts: 12 Use Cases for Business & Beyond”.

     

  • UI Elements in Web Dynpro

    Preface – This post is part of the SAP ABAP Web Dynpro series.

    Introduction

    There are various categories with user interface elements (UI elements) that are available in the Web Dynpro Explorer for creating the interface layout. These standard UI elements are for instance a Button, a Table or an Input Field. While developing the Web Dynpro applications, the UI elements are placed in a view displayed in a particular screen area at runtime.

    What is a UI Element in Web Dynpro

    Web Dynpro provides a design-oriented development of user interfaces and provides a compact class library of UI elements in the form of categories for application programming. Each UI element that is present in the library has different properties, events, and aggregations that determines the fact that how it is going to be appeared on the user interface. There are various categories available for the particular UI element’s properties, actions and aggregations, such as:

    Favorites

    By default, this category remains empty, unless one will select some of the frequently used UI elements. So this saves time because one will not need to select the elements over and over again.

    Text

    This category contains all the UI elements with textual content, as like caption, explanation, input field, label, etc.

    Action

    All the UI elements having some sort of property of action are grouped in this category, for example, button, button choice, link to action, link to URL, etc.

    Selection

    As the name suggests this category contains all the selection option like a radio button, checkbox, drop down, checkbox group, etc.

    Complex

    All the complex elements are categorized in this unit as like table, tree(hierarchy form), road-map(it displays the steps followed in a particular wizard), legend(this element helps to display descriptive text in different colors), date navigator(this element helps the user to enter and display the desired date), etc.

    Layout

    The elements that are used to form the design of the layout are grouped into this category, for example, page header, button row, tab strip, scroll container, etc.

    Graphic

    This category contains all the UI elements that include presentation graphics such as, network(The design that displays each entity in the form of nodes and connection between the nodes), image, value comparison, progress indicator, etc.

    Network will look like this:

    UI Elements in Web Dynpro

    Integration

    Those properties which are used to integrate different technologies in web Dynpro are achieved by the UI elements grouped in this category. For example, file upload, file download, interactive form, etc.

    Creating UI elements

    Steps to create UI Element:

    1. First, create one web dynpro application as shown in the previous article.
    2. Then we need to create one node in the context tab, here one node ‘SFLIGHT’ is created with some attributes
      Steps to create UI Element
    3. Create an event ‘get_flight’ in the method tab and then save the application.
    4. For creating UI elements dynamically in web dynpro ‘WDModify’ method is used.

     

    Code to create the input field and button element on the screen is:

    CALL METHOD cl_wd_input_field=>new_input_field
    
    Exporting
    
             bind_value = 'SFLIGHT.CARRID'
    
              id         = 'INPUT11'
    
    RECEIVING
    
             control    = lo_input.
    
    CALL METHOD cl_wd_button=>new_button
    
    
    
           EXPORTING
    
                          enabled   = 'X'
    
                           id        = 'B11'
    
                           on_action = 'get_flight'
    
                           text      = 'Get the Flight Data'
    
          RECEIVING
    
                            control   = lo_button.