Author: Rudramani Pandey

  • How to build Smart Forms in SAP ABAP

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

    Introduction

    As we have already basics of the SAP Smart Forms, in this article we will learn to build Smart Forms in SAP ABAP to print a simple text.

    Steps to build Smart Forms in SAP ABAP

    Step 1: SMARTFORMS is the t-code for Smart Forms. Enter SMARTFORMS in the common field.

    SMARTFORMS
    SMARTFORMS Transaction

    Step 2: Enter a form name and click on Create button.

    Create button for Smart Forms
    Create Smart Forms

    Step 3:  Enter a short description of the Smart Forms.

    Short Description for Smart Forms
    Short Description for Smart Forms

    Step 4: To create a text, expand the node “Pages and Windows”, then “New Page”. Right-click on “Main Window”, then click on Create -> Text.

    Smart Forms Main Window
    Smart Forms Main Window

    Step 5: Give a name and description of this text. And enter the text which has to be printed.

    Text in Smart Forms
    Text in Smart Forms

    Step 6: Save and activate the Smart Forms.

    Step 7: To find the function module that got generated upon activation of the Smart Forms Click on Environment -> Function Module.

    Find Function Module of Smart Forms
    Find Function Module of Smart Forms

    A pop-up with the name of the function module will appear.

    Step 8: Copy the function module name and open t-code SE38 and enter the function module name.

    Function Module for Smart Forms
    Function Module for Smart Forms

    Step 9: Execute the function module.

    Execute Smart Forms Function Module
    Execute Smart Forms Function Module

    Step 10: Since there are no parameters to pass, click on Execute.

    Print preview of Smart Forms
    Print preview of Smart Forms
  • How to Transport Standard Text in SAP

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

    Introduction

    When a standard text is created or modified using SO10, unlike any other objects it doesn’t ask for any transport number. The standard text is manually assigned the transport request to migrate it from one system to another. In this article we will explain how to Transport Standard Text in SAP.

    Steps to Transport Standard Text in SAP

    Steps to assign standard text to the transport request:

    Step 1: Enter SA38 in the common field and execute RSTXTRAN report.

    SA38

    Step 2: Enter the task number of the transport request in the Name of correction field.

    RSTXTRAN report

    Step 3: Enter Text key-ID and Text key-language of the standard text which has to be assigned to the transport request.

    Enter Text

    Step 4: A screen with a list of texts will appear. Deselect all Objects and select the standard text which has to be assigned to the transport request. Press enter.

    Deselect all Objects

    Step 5: Press enter. Selected objects will be shown.

    Selected objects

    Step 6: Click on Trsfr. Text to corr. Button.

    Click on Trsfr

    Step 7:  A pop-up will appear. Click on yes.

    pop-up

    Step 8: Once confirmed, below screen will appear showing the selected standard text has been assigned to a Transport request.

    selected standard text

  • SAP Standard Text (SO10): Create, Edit & Read with ABAP

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

    Introduction

    SAP Standard text is an object that holds some reusable text. If the texts are used more than once, those can be entered as standard text. This is globally stored and can be included in scripts, Smart Forms, or ABAP programs. Usually, standard texts are created for printing documents or inserting content of the body.

    SAP Standard Text Formatting

    There are different formatting options available in the text editor. Let’s check them out.

    1. * Default Paragraph: It is a default format for the text.
    2. B Paragraph, Justified: The paragraph is justified.
    3. C Centered: It aligns the paragraph to the center.
    4. L   Paragraph, Left Aligned: It aligns the paragraph to left.
    5. Space   Continuous Text: When two or more lines are needed in the paragraph, space can be specified to make it continuous text in the editor.
    6. =     Extended Line: It appends the next line only at the output.
    7. (      Raw line: It is used to apply the same format to the next paragraph as the previous one.
    8. /      Line Feed: It displays the text in the next line, same as the write statement is used to print in the next line.
    9. /=    Line Feed and Extended Line: It displays the content of the current line in the next line.
    10. /(     Line Feed and Raw Line: It displays the preceding line at the next line and uses the format of the previous paragraph.
    11. /:     Command Line: These lines are not interpreted and the contents of the line are converted to caps. The command line must be a single line.
    12. /*    Comment Line: It is used to write comments. These lines are neither be executed nor interpreted.

    Steps to create a Standard Text

    Step 1:  SO10 is the transaction code to create a standard text. Enter SO10 in the common field.

    Transaction code SO10

    Step 2: Enter a name for the standard text in Text Name field and click on the Create button.

    Create Standard Text

    Step 3: Enter text in Standard text Editor.

    There are different text editors. To change the editor, click on GOTO and select Change Editor.

    Standard text Editor

    Step 4: Click on the Save button.

     

    Steps to include Standard text in Smart Forms:

    Step 1: SMARTFORMS is the t-code for Smart Forms. Enter SMARTFORMS in the common field.

    SAP Smart Forms

    Step 2: Enter a form name and click on Create button.

    Create Smart Forms

    Step 3: Expand the Pages and Windows node and create a Text node.

    Expand Smart Forms

    Step 4: Change the Text type to Include Text.

    Change Text Type

    Step 5: A “Change Text node” pop will appear. Click on Yes.

    Change Text node

    Step 6: Enter Standard text name, Text object, Text ID, and Language.

    Enter Standard text

    Step 7: Check and activate the Smart Forms.

  • 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.
  • What is SAP Smart Forms

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

    Introduction

    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.

    The data is retrieved from static and dynamic tables. The table heading and the subtotal is specified by the triggered event and the data is sorted before the final output is printed. It also allows to incorporate graphics that can be displayed either as the background or as a part of the form. The background graphics can be suppressed while taking the printout of the form.

    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. To know the differences between SAP Smart Forms and SAP Script, click here.

    SMARTFORMS is the transaction used to design the smart form layout.

     

    Architecture of SAP Smart Forms

    The architecture of the SAP Smart Forms separates application data retrieval from the actual definition of the form.

    Smart Forms

    The following components are used:

    1. Form Layout: Define the positions of elements on the page
    2. Form Logic: To read data from the database, to define conditions, and to control the process flow of the form output.
    3. Individual element: Elements can be Text, Table, Graphics, Address, etc.
    4. Form Interface: To transfer the data to form definition.

     

    Advantages of SAP Smart Forms

    • It does not require any programming language.
    • It is configured using graphical tools.
    • When the Smart Forms is activated, a function module is generated and when called by the ABAP program, the module interface is used to transfer the data as per the form description.
    • Data is retrieved from the static and dynamic table.
    • Texts, images, tables, barcodes can be embedded.
    • Importing parameters have to be defined to send the data to be printed.
    • It can be easily modified using Drag & Drop and Cut & Paste, without writing changing the codes.
    • Output can be in the form of Fax, Print, email, or HTML/XML format to a web browser.
    • Using generated XML output, Web Publishing is possible.
  • 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.
  • Class Constructor in a Class

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

    Introduction

    We have understood about constructors in our previous article, a constructor is a special method that is invoked automatically at the time object is created or instantiated. It has two types: Instance Constructor and Static Constructor. The static constructor also called as class constructor is invoked whenever there is first call to the class whether it is through an instance or class.

    The class constructor has some special properties like,

    • Each class has a single static constructor.
    • The class constructor is called exactly once for each class.
    • The method don’t have importing/ exporting parameters and cannot raise exception.

    The class constructor can also be used to set default values for global attributes irrespective of the instance or methods. Also, while declaring the class constructor one must keep in mind that the name of the constructor must be CLASS_CONSTRUCTOR and declared using the statement CLASS-METHODS in the declaration part of the class.

    Definition

    A class constructor is a method which is automatically invoked whenever the first call to the class is made, it may be through an instance or class.

    Example

    Let us look into an example:

    **** Class Definition****

    CLASS  ZCL_DEMO DEFINITION.

    PUBLIC SECTION.

    METHODS:  CONSTRUCTOR.                                                         “Instance Constructor”

    CLASS-METHODS: CLASS_CONSTRUCTOR.                              “Static Constructor”

    END CLASS.

    ****Class Implementation****

    CLASS  ZCL_DEMO IMPLEMENTATION.

    METHOD CONSTRUCTOR.

    WRITE: “Instance Constructor is initiated”.

    END METHOD.

    METHOD CLASS_CONSTRUCTOR.

    LV_DATE = SY-DATUM.                                                                  “Changing the value of attribute”

    END METHOD.

    END CLASS.

    START-OF-SELECTION.

    DATA: LO_DEMO TYPE REF TO ZCL_DEMO.

    **Class object creation**

    CREATE OBJECT LO_DEMO.

    **Whenever the first call to class is made CLASS_CONSTRUCTOR  is triggered

    WRITE: “INSTANTIATING CLASS CONSTRUCTOR”, ZCL_DEMO=>LV_DATE.

     

    A commonly asked question is that whether we can redefine the constructors? So, it is a big NO as the redefinition of constructors are not allowed and the program will fall into error “Constructor may not be over-defined”.

  • 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.