Category: ABAP Beginner

  • SAP SmartForms Form Logic

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

    Introduction

    As we have discussed already in the previous tutorial about the Form Builder, let’s see about the Form Logic in SAP SmartForms.

    In SAP SmartForms, the form logic defines the data to be read from the database, the conditions, and controls the flow of the form output. The form logic is described by the form structure on the left pane of the Smart Forms interface.

    SAP SmartForms Form Logic
    SAP SmartForms Form Logic

    Nodes in SmartForms

    When a new Smart form is created, there are default nodes on the left side.  Global Settings and Pages and Windows are the two roots that are created by default for every Smart Form.

    The Global Settings node has 3 sub-folders, namely Form Attributes, Form Interface, and Global definitions. The Form Interface contains the data which will be passed to the Smart Form from the calling ABAP program and the Global Definitions contain the data that are available throughout the Smart Form.

    Defining Form Logic in SAP SmartForms

    To define the form logic, a hierarchical structure has to be defined under Pages and Windows in Navigation Window. This hierarchy determines the rules for processing the Smart Form.

    The form logic is used to control the flow of the form output. The following rules for form logic should be remembered:

    • In the tree structure, a tab is defined in the Maintenance Window for every node to link the node to a condition. If the condition is fulfilled, the node is processed and if not, then the node is skipped as well as all its sub-nodes.
    • The nodes are processed from top to bottom.
    • The page break on each page depends on how much space is left on the current page.
    • A next page should be defined for each page and flow control is defined for each page. However, one can go to other pages dynamically.
  • Migration from SAPscript to 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 for important business processes. If an existing SAPscript form is available in the system, it can be migrated to SAP Smart Forms.  The SAPscript can be migrated individually or any number of SAPscript can be migrated in one go. In this article we will discuss the steps involved in the Migration from SAPscript to Smart Forms.

    Migration of a SAPscript

    Step 1: Enter SMARTFORMS in the common field. Enter the Smart Forms name in the form name.

    Open Smart Forms Transaction
    Open Smart Forms Transaction

    Step 2: From menu bar, choose Utilities -> Migration ->Import SAPscript  Form.

    Migration from SAPscript to Smart Forms

    Step 3: A popup will appear. Enter the name of the SAPscript which has to be migrated. Also, provide language in the language field.

    Import Smart Scripts
    Import Smart Scripts

    Note: If the SAPscript is not available in the selected language, a popup will appear with a list of all languages that are available on the form. Select one of the existing languages.

    Select a Language
    Select a Language

    Step 4: Press Enter. It opens the SAP Form Builder screen in change mode.

    Step 5: Now, change the layout and logic of the form. And Click on the Activate button to activate the Smart Forms.

    Mass migration of the SAPscript

    Step 1: Enter SE38 in the common field and execute the SF_MIGRATE report.

    Step 2: Enter the names and language of the SAPscript form and Execute. The system creates the corresponding Smart Forms with the name of the SAPscript with an extension  _SF.

    Step 3: To modify the Smart Forms, go to transaction SMARTFORMS and enter the name of the Smart Forms. Modify and click on the Activate button to activate it.

  • SAP Smart Forms Builder

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

    In the previous tutorial, we have learned about the basics of SAP Smart Forms. Let’s learn about the screen and windows in SAP Smart Forms Builder.

    Introduction

    SAP Smart Forms provides a graphical user interface that allows us to create and maintain the layout and the form logic of the form. The graphical user interface is known as the SAP Form Builder.

    The SAP Form Builder is divided into three sections:

    SAP Smart Forms Builder
    SAP Smart Forms Builder
    1. Navigation Window: It consists of nodes and sub-nodes, which contain all the elements like windows, texts, etc. It shows the hierarchical structure of the Smart Forms and maintains the form logic. It has 2 root nodes by default for every Smart Forms:
    • General setting’s node to maintain Form Attributes, Form Interface, and Global Definitions. The Global Definitions contain the data that are available throughout the Smart Forms and the Form Interface contains the data which will be passed to the Smart Forms from the calling ABAP program.
    • Pages and Windows to create pages of the form, position elements on the pages, and determine the flow of the process of the elements.

     

    1. Maintenance Window: It is used to maintain the attributes of all the elements in the navigation tree nodes. In this window, depending on the node type, additional graphical tools are integrated.
    • PC Editor for the text nodes.
    • Table Painter for tables and template nodes.

     

    1. Form Painter: It is used to design the layout of the page of the Smart Forms. It allows us to add Windows and graphics, determine their position and size. It can be displayed or suppressed by selecting Form Painter on/off.

     

    Features

    1.      Navigation

    If a node is selected in the Navigation Window, the system displays the corresponding maintenance screen and highlights the corresponding window in the Form Painter.

    Also, on selecting a window in Form Painter, the system highlights the corresponding node in the tree and displays the corresponding maintenance screen for the selected window.

    2.      Updating the form

    Some settings such as height, width, etc. that are done graphically in the Form Painter are automatically copied to the maintenance screen. However, if the attributes are changed in the maintenance screen, it reflects the Navigation screen and Form Painter only after RETURN is pressed.

    3.      Service function

    The Form Builder provides the following service functions:

    • It has a field list that contains all fields of the Smart Forms.
    • It has an error list.
    • It allows us to undo/redo the changes to the form description.
    • It allows uploading and downloading the form locally.
    • It allows returning to the last active version of the form.
  • 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.

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

     

  • 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

  • Table Maintenance Generator in SAP ABAP

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

    Introduction

    In SAP ABAP Tables, it is sometime required to maintain a table (Create, update, edit or delete a record) manually. In this case, Table Maintenance Generator helps us to achieve the same. In this article, we will explore Table Maintenance Generator and will also learn the events associated with it.

    Definition

    • A tool used to tailor the tables created by end users.
    • End user do not have access to SE11 or SE11 T-Codes in production system so by using the generator they can customize the tables.
    • The end users can create, delete and modify entries.
    • After every changes done, user must go to SM30 T-code and by passing view/table name, select the maintain button to get the changes reflected.

    Prerequisite

    When we create a table in SE11 ABAP Dictionary, some features need to be activated.

    1. Delivery class
    • Delivery class are used for controlling data transport of tables for installation, upgrade, and client copy, and for transporting between customer systems.
    • The delivery class is also used in extended table maintenance.

    TMG Delivery Class

     

    • It helps in filling seven entries.

     Delivery Class Entries

     

    1. Data Browser/Table View Maint.
      This tab states whether data can be displayed or maintain a database table or view using the tools Data Browser T-code SE16 and Table View Maintenance T-codes SM30 and SM31.

    It has 3 features:-

    • Display/Maintenance allowed – A user can view in data browser as well as make changes in the data browser and also maintain and display in SM30 and generate table maintenance dialog in SE54.
    • Display/Maintenance allowed with restrictions – A user can view and make changes but with some restrictions.
    • Display/Maintenance not allowed – A user can neither view in data browser (SE16) nor maintain.

    Table View Maint

    How to Create a Table Maintenance Generator

    • Go to SE11 (ABAP Dictionary) => pass the table name => change => utilities => table maintenance generator => Generate table maintenance dialog: Generation Environment.

    Generate table maintenance dialog

    • Pass the Authorization Group name, if there is no specific group of people then assign it to &NC& (without authorization group). In total 759 groups can be assigned.
    • Authorization object – Element of the authorization system. Authorization objects allow complex checks linked to several conditions of an authorization which allows a user to carry out an action.
    • Function Group – Pass the name where generated maintenance modules can be stored. It can be same as the table name.
    • Maintenance Screens
      • Maintenance type
        • Select the maintenance type and click on find screen numbers on the tool bar=> propose screen numbers => Screen number gets populated => Create a button on the application toolbar => Assign TMG and function group to the proper package and click OK.
        • A pop up appears (Request completed without errors).
        • Table maintenance generator is created with this message in the status bar.
    • Description of maintenance types
      • One step maintenance, one screen that is overview screen is displayed in which the entries are displayed in the form of lists.
      • It is processed at run time.
      • Entries should be displayed in one line of the screen.
      • Two step maintenance, an additional screen (single screen) is processed at run time.
      • The single screen can be called from the overview screen by function key for every entry.

    How to Use a Table Maintenance Generator

    Follow the given steps to use a Table Maintenance Generator:

    1. Go to SM30

    Table Maintenance Generator

    1. Pass the name of the table => Maintain (click) => the overview screen appears.

    TMG New Entries

    1. Click on NEW entries => add new entries and save (this is a part of another screen).

    As mentioned, only one record at a time is allowed to enter, since it is user friendly.

    1. If we do any changes in the table, then we need to re -adjust, re-create TMG.

    Events of a Table Maintenance Generator

    Follow given steps to create Events in ABAP TMG

    1. SE11 => Change => TMG => Environment => Events

    TMG Events

    1. After selection of type of event => Editor => Write the code between FORM/ENDFORM.

    TMG Event Form

    1. List of available events:

    TMG Event List 1 TMG Event List 2