Category: ABAP Beginner

  • LOAD-OF-PROGRAM: Program Constructor Event

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

    Program Constructor Event

    A Program Constructor event in SAP ABAP is used to load global constant value or data of a program. It consist only one Event: LOAD-OF-PROGRAM

    LOAD-OF-PROGRAM

    Load of Program is Just like a Class Constructor or Static Constructor of a Class.

    Now if you don’t know class constructor, then simply understand this thing, A Load of Program loads default values for a session e.g. Language.

    Now you may say, we can load default values using INITIALIZATION, yes you can but it will be executed for every run, while Load of Program is executed once for a session.

    LOAD OF PROGRAM is useful only in case of a report called using SUBMIT or the one that run using a transaction code else it will perform same as INITIALIZATION.

     

    Example of LOAD-OF-PROGRAM:

    LOAD-OF-PROGRAM.
    
    DATA global_langu TYPE sy-langu.
    global_langu = COND #( WHEN sy-langu = 'D' THEN 'German' ELSE 'English' ).

    Explanation:

    The above program have two statements.

    • The first statement is declaring a variable g_langu (A global variable for language) of type sy-langu (it fetches system language that is based on the system location).
    • The second statement is checking a condition, if the system language is D (i.e. German) then assign g_langu as ‘German’ and assign ‘English’ for any other system language.

    Notes:

    • It is the first even executed by SAP ABAP
    • It is used to initialize global default values
    • If in a program, LOAD-OF-PROGRAM is only used for initialization and there is no executable lines after that, then LOAD-OF-PROGRAM event is not raised

    Flow of an Executable Program

    The statement SUBMIT is used to load the program in a separate internal session and based upon the following sequence calls different events as mention below:

    1. LOAD-OF-PROGRAM
    2. INITIALIZATION
    3. AT SELECTION-SCREEN OUTPUT
    4. START-OF-SELECTION
    5. END-OF-SELECTION
  • SAP FICO (Financial Accounting and Controlling)

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

    SAP FICO (Financial Accounting and Controlling)

    SAP FICO is used to store and control the financial information of the organization. FICO is one of the most important modules as it is used to analyze the financial condition of the company in the market. It can integrate with other SAP modules such as SAP MM, SAP SD, SAP PP, SAP SCM, etc.

    SAP FICO

    The sub components of SAP FICO are as follows:

    1. Financial accounting General Ledger: It is a set of accounts a business uses to keep track of its financial transactions and create reports.
    2. Financial accounting Accounts receivable and payable: Accounts payable is the amounts the company owes for buying goods or services from a vendor and accounts receivable is the amount the company has to receive for supplying goods and services to a customer.
    3. Financial accounting asset: It is managing and supervising the fixed assets the company owns.
    4. Financial accounting bank accounting: This component is used to handle transactions that you process with your bank.
    5. Financial accounting Travel management: This has a complete integrated management of all processes involved in a business trip.
    6. Financial accounting Fund Management: It interacts with various modules of SAP to get fund details.
    7. Financial accounting Legal Consolidation: for a company with multiple units, legal consolidation helps to view all details in a single financial statement.

     

    Below are some transaction codes for SAP FICO module:

    F110 -> Parameters for automatic payment

    FB60 -> Enter incoming invoices

    PR00 -> Travel expenses

    FB01 -> Post document

    FTXP -> Maintain tax code

    Below are some basic tables SAP FICO module:

    SKA1 -> General Ledger accounts (Chart of Accounts)

    SKAT -> General Ledger accounts (Chart of accounts: Description)

    SKB1 -> General Ledger accounts (Company codes)

    KNBK -> Bank details

    KNVP -> Customer partners

    KNVK -> Contact persons

     

  • SAP Production Planning (PP)

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

    SAP Production Planning (PP)

    SAP Production planning as the name suggests deals with planning processes such as material planning, capacity planning, production order, and bill of material and goods movement. It is the process of fulfilling demands with the manufacturing capacity. It tracks and makes a note of the manufacturing process flows, for example the target and actual costs. It is integrated with other SAP modules such as MM, SD, FI, QM and PM.

    There are two types of production processes in SAP PP:

    1. Discrete Production: In this kind of production, the product and costs keep changing according to the orders and lots.
    2. Repetitive Production or Production industries: In this kind of production, the product does not change for a long period of time. It is not dependent on orders as production takes place in total quantity.

    The process of production execution is as follows:

    1. Convert planned order to production order: This is the first step. When a production order is created, its SAP is defined in the system
    2. Issue the production order: Unless the issuing of the production order is done, it cannot be executed.
    3. Issue goods for production order: after the order is issued, the goods need to be issued for execution of the order. Once it is done, the document number is updated in the system.
    4. Production order confirmation: All the remaining sub processes are executed according to the required operations to finish the production as per the order
    5. Goods receipt with respect to Production order: Once the production order is complete, the produced goods are placed the storage area.

    SAP Production Planning

    Some important tables in SAP Production Planning are:

    MDKP -> Document header Data

    MDTB -> Table structure

    S094 -> Stock analysis

    PLAF -> Planned order details

    S026 -> Material Usage

    Some basic Transaction codes in SAP Production Planning module are:

     MD25 -> Create planning calendar

    MD26 -> Change planning calendar

    MD27 -> Display planning calendar

    MEQ1 -> Maintain quota file

     

     

     

  • SAP CRM (Customer Relationship Management)

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

    SAP CRM (Customer Relationship Management)

    SAP CRM is nothing but the way businesses interact with their customers. Traditionally, this is done by automating and integrating your customer related activities such as sales and marketing, and customer service. But in today’s time, the CRM activities go beyond that and provide functionalities like personalization, e-commerce, social media, collaboration and more. New CRM softwares store all customer information from their contacts to social media activities. This information can be used to dramatically improve the business. CRM benefits are huge from increasing sales revenue, customer loyalty to lower costs and better customer related activities.

    The SAP CRM application is a software which targets small and large sized businesses in all the sectors.

    SAP CRM Architecture:

    The following are the key components in the SAP CRM architecture:

    • SAP ERM Server (CRM Enterprise, CRM Middleware and Adapter)
    • SAP ECC – used for backend
    • SAP BI – is used for reporting
    • SAP SCM – used to better the capabilities of CRM
    • Mobile and handheld devices
    • Internet
    • Enterprise portal

    SAP CRM

    The Adapter is mainly used for handheld devices and the internet. The CRM Enterprise is used for telephone and email services.

    The SAP ECC and CRM are closely related to each other and need to synchronise in some areas like sales, customer master records, organisational model, etc.

    Some of the important Transaction codes of the CRM module are:

    CRMD_ORDER -> Transaction processing

    R3As -> Start initial load

    CRM_DNO_MONITOR -> Transaction monitor

    SMOEAC -> Administration console

    PPOMA_CRM -> Change organizational model

    R3AM1 -> Monitor Objects

    Some of the important tables of the CRM module are:

    BUT000 -> General Data

    BUT020 -> Addresses

    BUT050 -> BP relationships/role definitions: General data

    BNKA -> Bank master data

    ADR2 -> Telephone numbers

  • SAP MM (Material Management)

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

    SAP MM (Material Management)

    SAP MM: Material management is a module of SAP which as the name suggests deals with material management and inventory management. It ensures that there is never a shortage of materials in the supply chain process of the organization. It also helps the organization to complete the purchasing of goods in a timely manner and in a cost effective way. It incorporates other modules like Sales and Distribution, Production Planning, Plant Maintenance, Project Systems, Warehouse Management which are based on Materials Management module.

    The process of material management is as follows:

    1. Determination of requirement: Determines what materials and services are required for the organization.
    2. Source Determination: Determines who can fulfil the requirement.
    3. Vendor Selection: After gathering the requirements, direct contact is made with the suppliers and a suppliers is chosen who can satisfy the requirements.
    4. Purchasing Order (PO): The purchasing department is informed about the products needed. When that request is approved, the purchase order is created and assigned to the supplier.
    5. Order Monitoring: Order monitoring is tracking of dates and the goods from the time of ordering to the time the goods are delivered. It is done to ensure that there are no discrepancies and if any, they can be handled beforehand.
    6. Goods Receipt: The goods are received and are checked for quality and condition.
    7. Invoice Verification: Reconciliation of the invoice and purchase order is done. It means the invoice received is checked for cost, quantity and quality.
    8. Payment: The vendor is paid.

    SAP MM

    Some of the important Transaction Codes for Material Management are as follows:

    MM01 -> For creation of material

    MM02 -> For change of material

    MM03 -> For display purposes

    ME51N -> Creation of purchase requisition

    ME41 -> creation of RFQ

    A few of the basic tables in SAP MM modules are:

    MARA -> general data, material type

    MLAN -> Sales data, Tax Indicator, Tax

    MAKT -> Short texts, descriptions

    EBAN -> Purchase Requisition

    EKES -> Vendor Confirmations

     

     

     

     

  • SAP SD (SALES AND DISTRIBUTION)

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

    SAP SD (SALES AND DISTRIBUTION)

    SAP SD (Sales and Distribution) is used to manage shipping, billing, selling and transportation of products and services. It is closely integrated to material management module of SAP and manages customer relationship from requesting the product from the vendor to the billing of the product. It allows organisations to manage customer and product related data.
    Following is the Sales and Distribution Cycle:
    SAP SD
    In an SD cycle, SD first generates a sales cost and the customer places the order. The goods are then picked up from the warehouse and delivered to the customer with an invoice which is then settled. Each step in SD module generates transactions in other modules such as, a sales order in the SD module generates a link to check product availability in Material management, a credit check or a tax calculation to FICO.
    SD follows the Order-to-cash cycle process which involves a set of business processes from receiving to fulfilling customer requests for products and services.

    Some of the important tables in SAP SD module are:

    KNA1 -> Customer Master: General Data
    KNB1 -> Customer Master: Company Code Data
    KNB1 -> Customer payment history
    VBUK -> Header status and administrative data
    VBUP -> Item Status

    Some of the important Transaction codes for SAP SD are as follows:

    VS00 -> Master Data
    VC00 -> Sales Support
    VA00 -> Sales
    VL00 -> Shipping
    VT00 -> Transportation
    VF00 -> Billing
  • ABAP Report Events: What are the events of Classical Reports?

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

    Events in ABAP

    ABAP is an event driven Programming language. ABAP Report Events are used to handle different kinds of events during runtime. It starts with the event name, followed by the programming codes belonging to that event.

    It is advisable to use Comment line to declare the end of an event, since Events do not have a closing Keyword and it ends as soon any other Event starts.

    There are different kinds of events in ABAP, SAP has categorized these events together.

    Categories of Events in ABAP:

    There are three categories of Events in ABAP:

     

    Event Category

     

    Explanation

     

    Events in the Category

     

    Program Constructor Events

     

    Except Pool programs it occurs in every programs.

     

    LOAD-OF-PROGRAM

     

    Reporting Events

     

    These events occur only in Executable Reports.

     

    INITIALIZATION

    START-OF-SELECTION

    END-OF-SELECTION (obsolete)

     

    Selection Screen Events

     

    These events occur during Selection Screen Processing

     

    AT SELECTION-SCREEN OUTPUT

    AT SELECTION-SCREEN

     

    List Events

     

    These events occur during Classical List Processing [List can be a table or consecutive Write statements, etc.]

     

    TOP-OF-PAGE

    END-OF-PAGE

    AT-LINE-SELECTION

    AT USER-COMMAND

    AT PFnn

    SET USER-COMMAND

     

    Events in Classical Report:

    Classical Reports have following events:

    • LOAD-OF-PROGRAM : First event fired, loads program in memory
    • INITIALIZATION: Initialize variable
    • START-OF-SELECTION : Actual Business Logic (After START-OF-SELECTION)
    • END-OF-SELECTION : To end above
    • AT SELECTION-SCREEN : To validate Multiple Input fields (After Initialization and before START-OF-SELECTION) (After
    • AT SELECTION-SCREEN OUTPUT: To manipulate Dynamic screen
    • AT SELECTION-SCREEN ON
    • AT SELECTION-SCREEN ON END OF
    • AT SELECTION-SCREEN ON BLOCK
    • AT SELECTION-SCREEN ON RADIOBUTTON GROUP
    • AT SELECTION-SCREEN ON VALUE REQUEST
    • TOP-OF-PAGE : To print heading
    • END-OF-PAGE: To print footer

    Programming Guidelines:

    1. Never use Selection Screen Events in Function Module
    2. Use LOAD-OF-SCREEN to load default values  for the type of Reports executed via SUBMIT or using a transaction code
    3. Use INITIALIZATION to load default values  for the executable type of Reports
    4. It is advised not to specify an event more than once [Except AT-SELECTION-SCREEN & GET event, all other can be specified multiple times.]
    5. If you are not specifying any event name, still specify START-OF-SELECTION to improve readability
    6. After every execution of events NEW-LINE event is executed automatically

    Ref: https://www.gotothings.com/abap/what-are-classical-reports.htm

    https://www.sapnuts.com/courses/core-abap/classical-reports/classical-report-events.html

  • Create, Read, Update & Delete – CRUD Operations in ABAP Report

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

    In ABAP, if you know basic SQL operation to perform CRUD Operations in ABAP report, then this article will teach you multiple ways to perform the same.

    Introduction

    ABAP report has more often a requirement to perform any of the following operation:

    • Create : It means, you add data into a table
    • Read : It means, you read data from a table
    • Update : It means, you update any data of a table
    • Delete : It means, you delete a record from a table

    Everything in programming are directly or indirectly performing CRUD operations only. Let’s take example of Facebook.

    Whenever anyone create a profile on Facebook, the data of new Facebook ID is added into a table.

    Create Operation - CRUD operations Image illustration
    Create Operation in Facebook

    If you want to see your profile, data is read from the same table.

    Read Operation in Facebook - CRUD operations Image illustration
    Read Operation in Facebook

    If you want to update your profile, data is updated in the same table.

    Update Operation in Facebook
    Update Operation in Facebook

    And if, you plan to delete your account permanently, data is deleted from the same table.

    Delete Operation in Facebook
    Delete Operation in Facebook

    You see, here we have performed CRUD operations only.

    ABAP Program to perform CRUD Operations

    Program Requirement: Create an ABAP report to provide four radio buttons with name Create, Update, Read and Delete. Employee ID input box will be always visible. If Create button is clicked, Input boxes will be available for Employee Details Input. On Save, it will save data in table. If Update button is clicked, Input boxes will be visible with pre-loaded data for the Employee ID. On Update, it will update data in the table. If Read is clicked, the data for the Employee ID will be visible. If delete radio button is clicked, on click of Delete button, data will be deleted.

    Some Tables you will need:

    Employee Basic Table
    Employee Basic Table

     

    Employee Salary Table
    Employee Salary Table

     

    Employee Address Table
    Employee Address Table

     

    "Program for Reading , Updating , Inserting & Deleting data from a table
    
    
    TABLES: zBarry_emp. "Employee Table
    DATA: lt_itab   TYPE TABLE OF zBarry_emp,  "Internal table for employee basic details table
          lwa_emp   TYPE zBarry_emp, "Workarea for employee basic details table
          lt_itab1  TYPE TABLE OF zBarry_add, "Internal table for employee address details table
          lwa_emp1  TYPE zBarry_add, "Workarea for employee address details table
          lt_itab2  TYPE TABLE OF zBarry_sal,  "Internal table for employee salary details table
          lwa_emp2  TYPE zBarry_sal, "Workarea for employee salary details table
          total_sal TYPE zBarry_salary, "total salary
          tax       TYPE zBarry_salary, "total tax
          c         TYPE zBarry_salary, "tax percentage
          inhand    TYPE zBarry_salary. "inhand salary
    
    PARAMETER: p_empid TYPE char8.
    
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-101. "selection screen block
    
    PARAMETERS:p_rad1 RADIOBUTTON GROUP rg1 USER-COMMAND flag DEFAULT 'X',
               p_rad2 RADIOBUTTON GROUP rg1,
               p_rad3 RADIOBUTTON GROUP rg1,
               p_rad4 RADIOBUTTON GROUP rg1.
    
    SELECTION-SCREEN END OF BLOCK blk1.
    
    
    
    
    PARAMETERS:
      p_fname TYPE char20 MODIF ID pa1, "parameter for first name
      p_lname TYPE char20 MODIF ID pa2, "parameter for last name
      p_city  TYPE char20 MODIF ID pa3. "parameter for city name
    
    
    
    
    
    
    AT SELECTION-SCREEN OUTPUT.
    
      LOOP AT SCREEN.
        CASE screen-group1. "selecion of parameters on the basis of radiobutton selection
    
          WHEN 'PA1'.
            IF p_rad1 = 'X'.
              screen-active = '0'.
            ENDIF.
    
            IF p_rad2 = 'X'.
              screen-active = '1'.
            ENDIF.
    
            IF p_rad3 = 'X'.
              screen-active = '1'.
            ENDIF.
    *
            IF p_rad4 = 'X'.
              screen-active = '0'.
            ENDIF.
    
            MODIFY SCREEN.
    
          WHEN 'PA2'.
            IF p_rad1 = 'X'.
              screen-active = '0'.
            ENDIF.
    
            IF p_rad2 = 'X'.
              screen-active = '1'.
            ENDIF.
            IF p_rad3 = 'X'.
              screen-active = '1'.
            ENDIF.
            IF p_rad4 = 'X'.
              screen-active = '0'.
            ENDIF.
            MODIFY SCREEN.
    
          WHEN 'PA3'.
            IF p_rad1 = 'X'.
              screen-active = '0'.
            ENDIF.
    
            IF p_rad2 = 'X'.
              screen-active = '1'.
            ENDIF.
            IF p_rad3 = 'X'.
              screen-active = '1'.
            ENDIF.
            IF p_rad4 = 'X'.
              screen-active = '0'.
            ENDIF.
            MODIFY SCREEN.
        ENDCASE.
      ENDLOOP.
    
    
    AT SELECTION-SCREEN ON RADIOBUTTON GROUP rg1. "Auto-Popullating data in parameters
    
      IF p_rad3 EQ 'X'. "if update radio button is selected
    
        SELECT emp_fname emp_lname
             FROM zBarry_emp
             INTO CORRESPONDING FIELDS OF TABLE lt_itab
           WHERE empid = p_empid.
        IF sy-subrc = 0.
    
          LOOP AT lt_itab INTO lwa_emp.
    
            p_fname = lwa_emp-emp_fname.
            p_lname = lwa_emp-emp_lname.
    
          ENDLOOP.
    
        ENDIF.
      ENDIF.
    
    START-OF-SELECTION.
    
      IF p_rad3 EQ 'X'. "Updating data
    
        SELECT *
             FROM zBarry_emp
             INTO TABLE lt_itab
             WHERE empid = p_empid.
    
        UPDATE zBarry_emp SET emp_fname = p_fname
            emp_lname = p_lname WHERE empid = p_empid.
        UPDATE zBarry_add SET city_name = p_city WHERE empid = p_empid.
    
        IF sy-subrc = 0.
          MESSAGE 'Employee Record Updated' TYPE 'I'.
        ELSEIF sy-subrc <> 0 .
          MESSAGE 'Wrong Employee ID3' TYPE 'E'.
          EXIT.
        ENDIF.
    
        EXIT.
    
      ENDIF.
    
      IF p_rad1 EQ 'X'. "Displaying Data
        SELECT *
          FROM zBarry_emp
          INTO TABLE lt_itab
          WHERE empid = p_empid.
        IF sy-subrc = 0 .
    
          LOOP AT lt_itab INTO lwa_emp.
    
            FORMAT COLOR 1 INTENSIFIED ON. "adding dark color to headings
            WRITE: /3 'Employee Id',
                    20 'First Name',
                    35 'Last Name',
                    70  'Date Of Birth',
                    90  'Gender',
                    110  'Marital Status',
                    130  'Created By',
                    150  'Creation Date'.
            ULINE. " FOR UNDERLINE
    
            FORMAT COLOR 2 INTENSIFIED ON. "adding dark color to fields
    
            WRITE:/3 lwa_emp-empid, 20 lwa_emp-emp_fname,35 lwa_emp-emp_lname,70 lwa_emp-dob,90 lwa_emp-gender,110 lwa_emp-marital,
            130 lwa_emp-created_by,150 lwa_emp-created_date.
          ENDLOOP.
          ULINE.
    
          SELECT *
         FROM zBarry_add
         INTO TABLE lt_itab1
         WHERE empid = p_empid.
    
          LOOP AT lt_itab1 INTO lwa_emp1.
    
            FORMAT COLOR 1 INTENSIFIED ON. "adding dark color to headings
            WRITE: /3 'Employee Id',
                    20 'Flat No.',
                    35 'Street Name',
                    70  'City Name',
                    90  'State',
                    110  'Pincode'.
            ULINE. " FOR UNDERLINE
    
            FORMAT COLOR 2 INTENSIFIED ON. "adding dark color to fields
    
            WRITE:/3 lwa_emp1-empid, 20 lwa_emp1-flat_no, 35 lwa_emp1-street_name,70 lwa_emp1-city_name,90 lwa_emp1-state,110 lwa_emp1-pincode.
          ENDLOOP.
          ULINE.
    
          SELECT *
          FROM zBarry_sal
          INTO TABLE lt_itab2
          WHERE empid = p_empid.
    
          LOOP AT lt_itab2 INTO lwa_emp2.
    
            FORMAT COLOR 1 INTENSIFIED ON. "adding dark color to headings
            WRITE: /3 'Employee Id',
                    20 'Transaction ID',
                    35 'Month',
                    70  'Date Of Salary',
                    90  'Basic Salary',
                    110  'Food Card',
                    130  'Transport',
                    150  'Variable_M',
                    170  'Variable_Q',
                    190  'Medical',
                    210  'Others'.
            ULINE. " FOR UNDERLINE
    
            FORMAT COLOR 2 INTENSIFIED ON. "adding dark color to fields
    
    
            WRITE:/3 lwa_emp2-empid,20 lwa_emp2-tid,35 lwa_emp2-mon,70 lwa_emp2-dos,90 lwa_emp2-bs,110 lwa_emp2-fc,130 lwa_emp2-transport,
            150 lwa_emp2-variable_m,170 lwa_emp2-variable_q,190 lwa_emp2-medical,210 lwa_emp2-others.
          ENDLOOP.
          ULINE.
          total_sal = lwa_emp2-bs + lwa_emp2-fc + lwa_emp2-transport + lwa_emp2-variable_m +
          lwa_emp2-variable_q + lwa_emp2-medical + lwa_emp2-others. "total salary calculated
    
          WRITE:/ 'Total Salary = ', total_sal.
    
          IF total_sal < 10000.
            WRITE: 'Voila! No Tax'.
          ELSEIF ( 10000 < total_sal AND total_sal <  35000 ).
            c = 5 / 100.
            tax = c * total_sal. "total tax calculated when 10000< total salary <35000
            WRITE : / 'Tax = ', tax.
          ELSEIF ( 30000 < total_sal AND total_sal <  50000 ).
            c = 10 / 100.
            tax = c * total_sal. "total tax calculated when 30000 < total salary <50000
            WRITE : / 'Tax = ', tax.
          ELSEIF total_sal > 50000.
            c = 15 / 100.
            tax = c * total_sal. "total tax calculated when total salary >50000
            WRITE : / 'Tax = ', tax.
          ENDIF.
          inhand = total_sal - tax. "inhand salary
          WRITE : / 'Inhand Salary' , inhand.
    
        ELSEIF sy-subrc <> 0 .
          MESSAGE 'Wrong Employee ID1' TYPE 'E'.
          EXIT.
        ENDIF.
      ENDIF.
    
    
    
      IF p_rad2 EQ 'X'. "Inserting Data
    
        lwa_emp-empid = p_empid.
        lwa_emp-emp_fname = p_fname.
        lwa_emp-emp_lname = p_lname.
        lwa_emp1-empid = p_empid.
        lwa_emp1-city_name = p_city.
    
        INSERT zBarry_emp FROM lwa_emp.
        INSERT zBarry_add FROM lwa_emp1.
    
        IF sy-subrc = 0.
          MESSAGE 'Employee Record Inserted' TYPE 'I'.
        ELSEIF sy-subrc <> 0 .
          MESSAGE 'Wrong Employee ID2' TYPE 'E'.
          EXIT.
        ENDIF.
    
        EXIT.
    
      ENDIF.
    
    
    
      IF p_rad4 EQ 'X'. "Deleting Data
    
        DELETE FROM zBarry_emp WHERE empid = p_empid.
        IF sy-subrc = 0.
          MESSAGE 'Employee Record Deleted' TYPE 'I'.
        ELSEIF sy-subrc <> 0 .
          MESSAGE 'Wrong Employee ID4' TYPE 'E'.
          EXIT.
        ENDIF.
      ENDIF.
    

    Code Explanation

    In the program mentioned above, we have discussed CRUD operation in ABAP Report. This program has comments wherever required. Still, we will be explaining key points of this program. This program utilizes ABAP Classical Events, do read it here, before proceeding.

    • Initially, we have defined Parameters to take input, variables to perform calculation and radio buttons to provide choice selection.
    •  AT SELECTION-SCREEN OUTPUT: Here we have written conditions such that few input boxes become hidden and other visible according to the condition.
    • AT SELECTION-SCREEN ON RADIOBUTTON GROUP rg1 to auto-populate data in parameters.
    • START-OF-SELECTION: Here we have written SQL codes to perform Create, Update, Read and Delete according to requirement and condition.

    Output Screens

    Dynamic Report Output
    Dynamic Report Output
    Dynamic Report Delete Option
    Dynamic Report Delete Option
    Dynamic Report Update Option
    Dynamic Report Update Option
    Dynamic Report Create Option
    Dynamic Report Create Option
    Dynamic Report Read Option
    Dynamic Report Read Option

    Tutorial Video

    You can watch the below video to learn implementation:

    [embedyt] https://www.youtube.com/watch?v=EtxHXU37fYA[/embedyt]
  • Search Help in SAP ABAP

    Search Help in SAP ABAP

    Before we learn Search Help in SAP ABAP, let us see a daily life example first.

    In Windows PC, when you click Search Help in SAP ABAP windows_logo_image, a set of fixed options appear in front of you.

    This is something that is created to help you and you can search for the apps that you want to open. These apps are limited and are predefined and you can select only the one that is visible to you. In this way windows restrict you to select only valid apps. SAP provides similar scenario of data/record selection from a predefined fixed value. These values are created using Search Help in SE11.

    Definition

    Search Help in SAP ABAP are reusable objects that are used to assign input helps (F4 helps) to screen fields.

    This becomes mandatory when input is a formal key (In case data depends upon data of another table e.g. Registration of Employees in an event on basis of his employee ID).

    How a Search Help Works?

    We will update it soon.

    Types of Search Help in SAP ABAP

    These are the following two types of Search Helps:

    Type Description
    Elementary search helps It reads records from table, structure or view on the basis of a condition and returns those records which are displayed by a dialog box.
    Collective search helps It combines multiple Elementary search helps to provide records.

     

    Advantages of Search Helps

    • Search Help is a reusable component
    • It helps to avoid wrong input to the dependent table. It means a table whose records are dependent upon data of another table; any record added in that table which is not present in dependent table will not be legit.
  • PARAMETERS in SAP ABAP: Types, Syntax & Examples

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

    Parameters in SAP ABAP Report

    Have you ever worked on HTML tags where we use <INPUT> tag to get single input OR C/C++ tag where we use SCANF/CIN statement to take single input. Just like that, in ABAP PARAMETERS are used to take single input.

    Definition

    PARAMETERS are ABAP statements which are used to declare input ABAP variables in ABAP Programs/Report, variables are just like DATA statements. For every PARAMETER variable declared, an input box becomes visible on selection screen.

    Syntax

    PARAMETERS   <NAME OF YOUR PARAMETER>  [ TYPE/LIKE ]   <DATA ELEMENT/ABAP PREDEFINED DATA TYPE/REFERENCE to ABAP Table, Structure or View Field>

    Examples

    Case 01: TYPE/LIKE to DATA ELEMENT.

    PARAMETERS   P_BARRY TYPE ZBARRY_NAME.      //Here P_BARRY is a Parameter with property same as ZBARRY_NAME which is a Data Element.
    
    PARAMETERS   P_ALLEN LIKE P_BARRY.      //Here P_ALLEN is a Parameter with Property same as Parameter P_BARRY i.e. ZBARRY_NAME.

     

     

    Case 02: TYPE/LIKE to ABAP PREDEFINED DATA TYPE.

    PARAMETERS   P_BARRY(10)    TYPE C.     //Here P_BARRY is a Parameter with property of a character and length 10.
    
    PARAMETERS   P_ALLEN LIKE P_BARRY.      //Here P_ALLEN is a Parameter with Property same as Parameter P_BARRY i.e. character and length 10.

     

     

    Case 03:  REFERENCE to ABAP Table, Structure or View Field.

    DATA    CARR_ID(40) TYPE c.
    
    CARR_ID =  ‘SFLIGHT-CARRID’.
    
    PARAMETERS  P_BARRY LIKE (CARR_ID).

     

     

    *NOTE: In the above statement, the PARAMETER is just like field CARRID of table SFLIGHT. It will have all the properties (length, data type, decimal places, etc) and search help of that field.

    DEFAULT Values of a PARAMETER

    Syntax:

    PARAMETERS    <NAME OF YOUR PARAMETER>    [TYPE/LIKE]   <DATA ELEMENT/ ABAP DATA TYPES/ DDIC Field>    DEFAULT  <YOUR DEFAULT VALUE>.

     

    Example:

    PARAMETERS   P_NAME(20)    TYPE    C     DEFAULT    ‘BARRY ALLEN’.

     

    Setting PARAMETER value from Memory

    We can store values in SAP Memory. To learn more about Memories click here.

    From these memories we can get the values and set it as default in PARAMETER.

    Have you ever wondered that after viewing your table name when you come back again to SE11, its name still appears? This is possible because every time we open anything in SE11, the value of Parameter is set into memory and when we revisit the DDIC/SE11, it get the Parameter value back from memory. Let us see how we can do it too in our program.

     

    To Set PARAMETER value in SAP Memory:

    SET PARAMETER ID <NAME OF YOUR Memory ID>  FIELD  <Name of the field whose value will be saved>.

     

    Example:

    SET PARAMETER ID  pid_barry   FIELD  lv_barry.

     

     

    To Get PARAMETER value from SAP Memory:

    GET PARAMETER ID <NAME OF YOUR Memory ID>  FIELD  <Name of the field which will get the value>.

     

    Example:

    GET PARAMETER ID  pid_barry   FIELD  lv_barry.

     

     

    To Give Default value to Parameter from SAP Memory:

    PARAMETERS    <Name of your parameter>  [TYPE/LIKE]   <DATA TYPE/DATA ELEMENT/DDIC REFERENCE>  MEMORY ID <NAME OF YOUR Memory ID>  .

     

    Example:

    PARAMETER   P_NAME(20)   TYPE    C    MEMORY ID   pid_barry  .

     

    *NOTE: IF any of the above operation fails, SY-SUBRC becomes 4.

    Allow PARAMETER to Accept LOWER and Upper Case

    The default value of Parameter is upper case that means all input changes to upper case. You can allow lower cases using given syntax.

    Syntax:  PARAMETERS    <Name of your parameter>  [TYPE/LIKE]   <DATA TYPE/DATA ELEMENT/DDIC REFERENCE>  LOWER CASE.

    Example:

    PARAMETER   P_NAME(20)   TYPE    C    LOWER CASE  .

     

     

    Reduce Visible Length

    You can allow as many lengths of Parameter you want and also restrict the length visible to the end user using given syntax.

    Syntax:  PARAMETERS    <Name of your parameter>  [TYPE/LIKE]   <DATA TYPE/DATA ELEMENT/DDIC REFERENCE>  VISIBLE LENGTH <Your Length>.

    Example:

    PARAMETER   P_NAME(20)   TYPE    C    VISIBLE LENGTH 5  .

     

     

    Define Required/Mandatory/Obligatory Field

    Suppose you want an input the will be saved in the table as a Primary key, it means it is a required field and it cannot be left blank. To tell user that it is mandatory to fill some values in this field you will use given syntax.

    Syntax:  PARAMETERS    <Name of your parameter>  [TYPE/LIKE]   <DATA TYPE/DATA ELEMENT/DDIC REFERENCE>  OBLIGATORY.

    Example:

    PARAMETER   P_NAME(20)   TYPE    C    OBLIGATORY.

     

     

    Attach Search Help to Parameters

    Search Help were earlier called Match Code Objects in SAP ABAP. To know more about Search Help Click Here.

    A search help provides the possible values for a given parameter. To attach a search help to a parameter use the syntax given below:

    Syntax:  PARAMETERS    <Name of your parameter>  [TYPE/LIKE]   <DATA TYPE/DATA ELEMENT/DDIC REFERENCE>  MATCHCODE OBJECT <Name of your Search Help>.

    Example:

    PARAMETER   P_NAME(20)   TYPE    C     MATCHCODE OBJECT     ZBARRY_SHELP.

     

     

    Check Parameter Input against Check Table or Fixed Value

    If you want a Parameter to have input only that value that is present in the Check Table. Then you need to do three things:

    1. Make the Parameter Obligatory: The Empty value will not be in check table and hence it will be a required field.
    2. DATA TYPE will be a field from table having Check-Value Relationship.
    3. Attach a Check: A Check will ensure the presence of valid value.

    Syntax:  PARAMETERS    <Name of your parameter>  [TYPE/LIKE]   < DDIC REFERENCE>  OBLIGATORY VALUE CHECK.

    Example:

    PARAMETER   P_CARRID     TYPE    SFLIGHT-CARRID     OBLIGATORY VALUE CHECK.

     

    The check will compare data with check table; if not present will throw an error.

     

    Define Checkbox

    A Parameter can be a simple field as well as a checkbox with given syntax.

    Syntax:

    PARAMETERS    <Name of your parameter>  AS   CHECKBOX.

    Example:

     PARAMETER:   P_CHECK1     AS   CHECKBOX   .
    
    P_CHECK2     AS   CHECKBOX    DEFAULT   ‘X’  .

     

    Here P_CHECK2 has default value ‘X’ which means it is checked.

     

    Define Radio Button

    A Parameter can be a simple field, a checkbox and even a radio button.

    Syntax:  PARAMETERS    <Name of your parameter>    RADIOBUTTON GROUP     <Name of Radio button Group> .

    Example:

    PARAMETER:   P_rad1     RADIOBUTTON GROUP      rad1       DEFAULT   ‘X’  ,
    
    P_rad2     RADIOBUTTON GROUP    rad1 ,
    
    P_rad3     RADIOBUTTON GROUP    rad1 .

     

    The radio buttons comes under a group with one of them as a default value. A radio button group here can have maximum length four. If you do not assign the default value, the first radio button is assigned automatically. Here ‘X’ means radio button is pressed.

     

    Modify Input Fields

    To modify appearance of a field or a Parameter, we assign it a MODIF ID whose length can be maximum 3 characters. Now these fields will behave as a single group. And using Modify Screen statements we can modify their appearance on screen.

    SYNTAX: PARAMETERS   <Name of your parameter>    [TYPE/LIKE]    <DATA TYPE/DATA ELEMENT/DDIC REFERENCE>    MODIF ID    <Name of your MODIF ID>.

    Example:

    PARAMETERS:   P_First_name(20)    TYPE    C   MODIF ID    md1,
    
    P_Last_name(20)    TYPE    C   MODIF ID    md1.

     

     

    Hide a Parameter

    Sometimes you need a parameter but you don’t need to display it. In such case you can pass default value, or a value via INITIALIZATION, or via another Program.

    SYNTAX: PARAMETERS   <Name of your parameter>  [TYPE/LIKE]    <DATA TYPE/DATA ELEMENT/DDIC REFERENCE>  NO-DISPLAY.