Category: ABAP Differences

  • Difference between SAP Smart Forms and SAP Script

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

    Before discussing the difference between SAP Smart Forms and SAP Script, let’s have a short introduction of the two.

    SAP Smart Forms

    SAP Smart Forms is a tool to create and maintain forms for mass printing and sending documents. This tool is also used for developing PDF files, e-mails, and documents. It provides an interface to build and maintain the layout and logic for the form. It does not require any programming knowledge to modify the forms. It means the forms can be configured using simple graphical tools effortlessly.

    SAP Script

    SAP Script is a text processing system owned by SAP. It is used to generate formatted documents and to print for external purposes. It uses pre-formatted forms to print pre-formatted texts which are not possible with normal ABAP code. It is client dependent, i.e. if it created in client 100, it is not visible to other clients.

    SAP Smart Forms was introduced in 1998 to overcome the limitations of SAP Scripts and is superseded by Interactive Forms by Adobe since release 6.40.

    Difference between SAP Smart Forms and SAP Script

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

    SAP  Smart Forms SAP Script
    It is client independent It is client dependent.
    T-code is SMARTFORMS. T-code is SE71.
    It can be created without the main window. Main window is compulsory.
    Programming knowledge is not necessary. Programming knowledge is necessary.
    Texts support various colors. Only black and white color are allowed.
    Labels can not be created. Labels can be created.
    Multiple page format is available. Only single page format is available.
    Routines can be written. Routines cannot be written.
    Background logo cannot be printed. Background logo can be printed.
    Text can be printed in multiple character format. Text can be printed in only two character formats.
    A function module is generated when it is activated. No function module is generated when it is activated.
    Once control is transferred to the function module, it never comes back. It supports the repeated transfer of control.
    It cannot be downloaded/uploaded to the local disk. It can be downloaded/uploaded to the local disk.
  • Difference between Object-Oriented ABAP and Function module

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

    Before discussing the difference between Object-Oriented ABAP and Function module, let’s have a short introduction of the two.

    Object-Oriented ABAP

    Object-Oriented ABAP or OOABAP is the object-oriented extension of ABAP, which mainly focuses on the classes and object rather than the code flow. An object-oriented approach enables programmers to think like they are working with real-life entities.

    The Object-Oriented concept of ABAP mainly revolves around the classes and objects, which are the basic elements of OOABAP. A class is like a blueprint of an object or a template that binds similar kinds of data. It defines the characteristics of an object. An object is a working entity of a class. Each object is unique at its own, meaning with unique identity and attributes. Attributes define the state of an object whereas the behavior of an object refers to the changes that occur in its attributes over some time.

    The three pillars of OOABAP are:

    Encapsulation: It is a concept of preventing the data from being arbitrarily accessed by some other outside interference or protects the data from being misused.

    Polymorphism: It allows overwriting some functionality.

    Inheritance: It allows a sub class or a child class to inherit the properties from a parent class.

    Function module

    The classical approach where the ABAP program consists of program blocks and is executed sequentially is known as the Procedural Programming model. Function modules are one of the techniques that separate the functionality of the program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality.

    This technique improves the readability and maintainability of ABAP programs as well as incorporates the reusability of functions.

    Difference between Object-Oriented ABAP and Function module

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

    OOPS Function Module
    It is object-oriented. It is procedural oriented.
    It uses objects and classes. It contains a block of code for a specific functionality
    It is a bottom-up approach. It is a top-down approach.
    Inheritance is possible. Inheritance is not possible.
    Polymorphism is possible. Polymorphism is not possible.
    Have access specifiers: Private, public, and Protected. Does not have any access specifier.
  • Difference between CURSOR and SELECT statement

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

    Introduction

    Before discussing the difference between CURSOR and SELECT statement, we will have a short introduction of the two. Both of these operations are used in SAP ABAP to perform operations on SAP Tables/Data.

    CURSOR

    CURSOR decouples the process of SELECT statement and INTO clause. This is done by opening a cursor for a select statement. This is used to extract data in chunks from the database table. Only after getting the complete data, the data is stored in the target area

    It follows the following three-stage process to access the data from the database.

    1. Opening the cursor

    Syntax to open the cursor for SELECT statement:

    OPEN CURSOR [WITH HOLD] <c> FOR SELECT    <result>
    FROM      <source>
    [WHERE    <condition>] [GROUP BY <fields>] [HAVING   <cond>] [ORDER BY <fields>].

    To open a cursor, it is required to declare it first. It is declared using the DATA statement and special data type CURSOR. All clauses of SELECT statement can be used except the INTO clause.

    After the OPEN CURSOR statement, the database cursor points to the first line of the result set. The open cursor points to an internal handler just like a reference variable pointing to an object.  More than one cursor can be opened parallelly for a single database.

    1. Fetching the data

    Syntax to read data :

    FETCH NEXT CURSOR <c> INTO <target>.

    This statement decouples the INTO clause from all other clauses in the SELECT statement. This extracts the requested row from the database cursor, assigns into the target area and the cursor moves one line further in the selection set.

    1. Closing the cursor

    Syntax to close the cursor:

    CLOSE CURSOR <c>.

    If a cursor is already opened, it cannot be reopened.  It is necessary to close all the cursors which are no longer required since only a limited number of cursors can be opened simultaneously.

    SELECT statement

    SELECT statement is an Open SQL statement for reading data from one or more database tables, classic views, or CDS views. The SELECT statement reads the data directly into the target area specified in the INTO clause. While using SELECT…END SELECT statement, database is accessed each and every time fetching the data row by row. A SELECT statement makes use of the CURSORS implicitly to fetch the data from the database.

    Difference between CURSOR and SELECT statement

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

     

    CURSOR statement SELECT statement
    This decouples the process of SELECT statement and INTO clause.  Only after getting the complete data, the data is stored in the target area. The data is stored directly into the target area specified in the INTO clause.
    This creates a pointer to database record and data is not copied to the ABAP server Data is directly copied into a data object in the ABAP memory

     

  • Differences between REFRESH and CLEAR

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

    Introduction

    Before discussing the differences between REFRESH and CLEAR statement, we will have a short introduction of the two. Both of these Statements are part of SAP ABAP Reports/Editors and are mainly used to clear out the used variables and save memory or reuse the variables.

    REFRESH

    REFRESH statement sets the internal table to its initial size by deleting all the rows of the internal table. This frees up the allocated memory for the internal table.  A FREE statement is used to delete entire rows and free all the memory(used when the internal table is no longer needed).

    Syntax of REFRESH statement:

    REFRESH <itab>.

    For an itab, an internal table has to be specified.

    If an internal table itab has a header line, then the table body is initialized, not the table header. If itab has no header, it acts as a CLEAR itab statement. Hence, it is recommended to always use CLEAR statement instead of REFRESH.

    The use of a table with a header line is forbidden in classes, which makes the use of the REFRESH statement obsolete.

    CLEAR

    CLEAR statement clears the header line as well as the rows of the internal table and work area. This frees up the allocated memory required for the internal table and sets it to its initial size.

    Syntax of CLEAR statement:

    CLEAR <dobj>.

    For a dobj, itab or itab[] has to be specified.

    CLEAR itab is used to clear only the header line and the table rows i.e. clear the content of the structure. If the table header line is not defined, CLEAR itab clears the table content.

    CLEAR itab[] is used to clear the internal table contents.

    Differences between REFRESH and CLEAR

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

    REFRESH statement CLEAR statement
    It always refers to an internal table. It refers to an internal table as well as a work area.
    Header line cannot be cleared using this statement. Header line can be cleared using the CLEAR itab statement.
  • Differences between GET CURSOR and HIDE

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

    Introduction

    Before discussing the differences between GET CURSOR and HIDE, let’ have a quick introduction of the two.

    Interactive report in SAP ABAP is a report which displays the basic information on the basic list and the detailed information on the secondary list.

    Among various list events in the interactive report, the AT LINE-SELECTION is an event that is triggered when the user clicks on any list item. To know the selected list contents, there are 2 keywords or statements, GET CURSOR and HIDE.

    GET CURSOR

    GET CURSOR statement is used to read the name of the output field or the number of the list line on which the screen cursor in the displayed list is positioned and store the value into the variables field or line depending on how the FIELD or LINE is specified.

    Syntax: –

    GET CURSOR { {FIELD field [ field_properties]}
    | {LINE line [ line_properties]} }.

    HIDE

    HIDE statement is used to hide the content of the current output line into a temporary memory called hide area for further processing. HIDE statement is used withing loop…end loop to hide the values in the hide area.

    On double click on any list line, an event AT LINE-SELECTION is triggered and the system automatically identifies the line number and stores the corresponding record into the hide variable.

    Syntax:

    HIDE dobj.

    This statement places the contents of the dobj for the current output line (system field SY­LINNO) into the HIDE area. The data type of the dobj must be flat and no filed symbol or class attributes can be specified.

    Differences between GET CURSOR and HIDE

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

    GET CURSOR HIDE AREA
    It is used to store the value of the selected field name. It is used to store the line with line number.
    It responds for a particular field It responds for a particular line.
    Interactive reports can be generated using field name and field value Interactive report cannot be generated using this.

     

  • Difference between Update function module and Regular function module

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

    Introduction

    Before discussing the difference between Update function module and Regular function module in SAP ABAP, let’s have a short introduction of the two.

    Function modules are procedures that have a set of re-usable statements with importing, exporting parameters, etc. They are created in ABAP workbench using the Function Module Builder. They play an important role in updating and in the interaction between different SAP systems, between SAP systems and remote systems through remote calls.

    There are 3 Processing types of function module:

    1. Regular Function Module
    2. Remote-Enabled Function Module
    3. Update Module

    Regular Function Module

    Regular Function Module and Update Function module consists of a block of statements that are made available globally all over the SAP landscape.

    Update Module

    The Update function module is a function module for which the processing type property of the function builder is set to Update Module. This function module is not executed immediately but is scheduled for execution in a special work process called update work process. For this purpose, the name of the update function module along with the actual parameter is registered in the database table VBLOG as a log record.

    Syntax to register the function module to the log table:

    CALL FUNCTION <function_name> IN UPDATE TASK

    [EXPORTING p1 = a1 … fn = an] [TABLES  f1 = a1 … fn = an

     The actual execution of the program is triggered by the COMMIT WORK statement. The values of the actual parameters are received by the formal parameter of the function module from the VBLOG table. After registration of the function module, if the COMMIT WORK is not triggered then the function module is not executed and the entries are deleted from the log table when the program ends.

    The regular function module does not need to be registered to be called. This is executed immediately whenever a call to this function module is made. Sy-subrc can be checked for success and failure.

    Syntax to call a Regular function module:

    CALL FUNTION  <function_name>

    [EXPORTING  p1 = a1 … fn = an] [IMPORTING  f1 = a1 … fn = an] [CHANGING   f1 = a1 … fn = an] [TABLES     f1 = a1 … fn = an] [EXCEPTIONS e1 = r1 … en = rn

    [ERROR_MESSAGE = rE] [OTHERS = ro]].

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

    Difference between Update function module and Regular function module

    Update Function Module Regular Function Module
    It needs to be registered first in the log table There is no need to register
    It is executed when COMMIT WORK statement is triggered. It is executed immediately when a call is made to this function.
    Sy-subrc is undefined after execution Sy-subrc can be checked after the execution

     

  • Difference between User Exits and Customer Exits

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

    Introduction

    Before discussing the difference between User Exits and Customer Exits in SAP ABAP, let’s have a short introduction of the two.

    The enhancement allows the user to add their functionalities to the SAP standard applications without modifying the original application. Enhancement Framework is used to modify the standard SAP behavior as per the customer requirements. There are different ways to add custom functionalities in standard codes. User Exit and Customer Exit are among them.

    User Exits

    User exits are implemented in the form of subroutines and hence also called FORM EXITs. They are collected in Include and are attached to the SAP standard program. They are empty subroutines where one can fill their source code. They are the type of system enhancements originally developed for R/3 SD(Sales and Distribution). Technically they modify the existing code.

    Syntax:

    FORM USEREXIT_XXXX
    INCLUDE ZZUSEREXIT_XXXX
    ENDFORM.

    Customer Exits

    Customer exits act as hooks where one can hang their new functionalities. These are created for specific programs, screens, and menus within the standard applications. Technically, they are enhancements as they provide add-on functionality. They are used for all modules like MM, SD, FICO, PP etc.

    There are 3 types of Customer Exits:

    1. Function Module Exits

      It is implemented as a call to the function module. It allows the developer to add code in include that is implemented in a function module at a specific location in an SAP application program.

    Syntax:  CALL CUSTOMER-FUNCTION ‘910’

    1. Screen Exits

      It allows the customers to add fields to a screen in the SAP program via sub-screen which is called within standard screen’s flow logic.

    Syntax:  CALL CUSTOMER-SUBSCREEN CUSTOM_SRC

    1. Menu Exits

      These are implemented by SAP and are reserved menu entries in the GUI interface. It allows adding functionalities to menus.

    Syntax:   +CUS (additional item in GUI status)

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

    Difference between User Exits and Customer Exits

    User Exits Customer Exits
    It is implemented in the form of subroutine It is implemented for specific programs, screens, and menu within standard applications
    It is technically a modification as existing code are changed It is technically an enhancement as this provides add-on functionality
    It refers to SD module only It refers to all modules like MM, SD, FICO, PP etc.
    All variables, structures, internal tables, etc. are exposed to be viewed and/or changed Only variables, structures, and tables that are passed into the function through the interface are restricted to be viewed and/or changed
    It requires an access key It does not require any access key
    Changes remain after the upgrade Changes are lost after upgrade
    It gets automatically activated whenever the application/program is activated To implement this, a project is created in CMOD then activated

     

  • Difference between Primary Key and Foreign Key

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

    Introduction

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

    Keys are the fundamental part of the relational database as they establish a relation between the tables and ensure each record in the table is uniquely identified.

    A database contains a lot of tables which holds thousands of records all of which are unsorted and unorganized. Fetching a particular data from those records can be difficult and challenging. This is where Keys comes to the scenario. The two important keys of the relational schema are Primary Key and Foreign Key. In this article we will discuss the Difference between Primary Key and Foreign Key in detail.

    Primary Key

    A primary key in a table uniquely identifies each record in the table. It may refer to a column or a combination of columns to implicitly identify the records. The input values of the key columns defined must be unique for each record and not contain NULL values. Each table has can have one  Primary key or group of keys that are unique for every record.  No duplicate value is allowed in the primary key field.

    Foreign Key

    A foreign key is a set of one or a combination of columns in a table that is a primary key of another table. It is used in a table is used to establish a relation between tables in the ABAP dictionary, to create value checks for the input fields and to link multiple tables in a view or a lock object. Duplicate value is allowed in the foreign key field.

     

    Difference between Primary Key and Foreign Key

    Table 1 is the foreign key table (dependent table) and Table 2 is the check table(referenced table). Here the Column 3(foreign key of Table 1) points to the Col 1(primary key of Table 2).Column 3 of Table 1 and Col 1 of Table 2 must have same data type and length.

    Difference between Primary Key and Foreign Key

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

    Primary Key Foreign Key
    It uniquely identifies a record in the table It establishes relation between table and is a primary key in another table
    A table has mianly one primary key A table can have multiple foreign keys
    It cannot have Null value It can have Null values
    It cannot have a duplicate value It can have duplicate values
    It cannot be dropped from the parent table which refers to the foreign key in the foreign key table It can be dropped from the foreign key table even it is referring to the primary key of the main table

     

  • Difference between Append and Insert

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

    Introduction

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

    Internal tables are used to process the data dynamically during the program execution. Data is populated to the internal table during runtime i.e. program execution.

    APPEND and INSERT are the 2 statements that are used to populate the internal table.

    In this article we will explore more about the Difference between Append and Insert.

    Append

    APPEND statement adds one or more records at the end of the existing internal table.

    Syntax:

    APPEND {<work-area>| INITIAL LINE |LINES OF jtab [FROM idx1] [TO idx2]} TO <itable>.

    <work-area> adds the contents of the work area  <work-area> to the internal table <itable>.

    INITIAL LINE appends a blank line to the internal table <itable> with initial values in each field according to the definition.

    LINES OF jtab [FROM idx1] [TO idx2] appends the rows from idx1 index to idx2 index from jtab to the internal table <itable>.

    The APPEND statement sets sy-tabix with the index of the last appended row.

    Insert

    INSERT statement adds one or more records at a specified position of the internal table. The position can be specified by the primary table key or a table index.

    Syntax:

    INSERT {<work-area>| INITIAL LINE | LINES OF jtab [FROM idx1] [TO idx2]} TO <itable> [INDEX <idx>].

    <work-area> adds the contents of the work area  <work-area> to the internal table <itable>.

    INITIAL LINE appends a blank line to the internal table <itable> with initial values in each field according to the definition.

    LINES OF jtab [FROM idx1] [TO idx2] appends the rows from idx1 index to idx2 index from jtab to the internal table <itable>.

    INDEX specifies the position of the internal table where the new record has to be added. If the Index is not specified, the system adds the new record at the end of the internal table. If the internal table has a record at the specified index, then the new record is added at the specified index and the existing record is reinserted by incrementing the index by 1.

    The INSERT statement does not set the system field sy-tabix.

    Difference between Append and Insert

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

     

     

     

    APPEND INSERT
    It is a statement that is used to add a record at the end of an internal table. It is a statement that is used to add/insert record at a specific position of Internal Table.
    New records are always added to the end of the internal table. If the position is not specified only then the new records are added to the end of the internal table.
    System field SY-TABIX is set to the index of the last appended row. System field  SY-TABIX is not set.

     

     

  • Difference between Narrow casting and Wide Casting

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

    Introduction

    Before discussing the difference between Narrow Casting and Wide Casting, let’s have a short introduction of the two.

    Both the Narrow casting and Wide casting is related to Inheritance concept.

    The subclasses which inherit from the parent (super) class would usually have more components than the parent class, hence the subclasses are Wide.

    On the other hand, the parent (super) classes have a smaller number of components, hence the parent classes are Narrow.

    Narrow casting

    In Narrow casting, an instance of the subclass is assigned to the reference of the superclass. As we are switching from a “more specific view” to a “less specific view”, it is called Narrow casting. By this assignment, only the inherited components of the subclass can be accessed using the reference of the superclass.

    Steps to Narrow Cast:

    i) Declare a reference variable of the superclass

    DATA: lr_parent TYPE REF TO super_class.

    ii) Declare a reference variable of the subclass

    DATA: lr_child TYPE REF TO sub_class.

    iii) Create an instance of the subclass reference

    CREATE OBJECT lr_child.

    iv) Assign the instance to reference of the superclass

    lr_parent = lr_child.

    Wide Casting

    In Wide Casting, an instance of the superclass is assigned to the instance of the subclass. As we are switching to a “more specific view” from a “less specific view”, it is called Wide Casting. By this assignment, all the inherited components and specific components of the subclass can be accessed using the instance of the subclass. The Wide Casting will always fail unless the instance of a subclass has the same type as of the instance of the superclass.  So, it is required to do Narrow casting always before Wide casting.

    Syntax to Wide Cast:

    lr_child ?= lr_parent

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

    Difference between Narrow casting and Wide Casting

    Narrow Casting Wide Casting
    It means copying an instance of subclass to an instance of the super class. It means copying an instance of the super class to an instance of sub class
    Only inherited components of the subclass can be accessed. Inherited, as well as specific components of the subclass, can be accessed.
    Assigning operator is used. Casting operator is used.
    Syntax:

    lr_parent = lr_child

    Syntax:

    lr_child ?= lr_parent