Author: Rudramani Pandey

  • ABAP Syntax

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

    Mandatory ABAP Syntax for Every Coder

    The following ABAP syntax is mandatory for every coder:

    1. ABAP is not a case sensitive language (It is case sensitive in the case of field name being passed in the function module).
    2. Every program must start with a keyword.
    3. Each program must end with a period (.)
    4. Every chained statement must have a single keyword followed by a colon (:) and the individual statement followed by a comma (,).
      Example:
      DATA :LV_PLAYER(10) TYPE c,

    LV_SCORE (100) TYPE n,

    LV_WICKET (10) TYPE n.

    1. To make the entire line comment use an asterisk (*) mark at the beginning of the statement.
    2. To make a comment after a statement in the same line, use a double inverted comma (“) before the comment.
    3. Use PRETTY PRINTER to provide indentation to your codes and make them readable for testers
    4. Nomenclature: Use the following prefixes before given types of fields
    Prefix Field Name
    LWA Local Work Area
    GWA/WA Global Work Area
    LTY Local Structure
    LT Local Internal Table
    GT Global Internal Table
    IT/ITAB Internal Table
    V Variable
    C Contant
    ZRP Custom Report Program
    ZCL Custom Class
    LV Local Variable

     

    [Note: Use underscores (_) after using prefixes]
    1. ABAP codes are whitespace sensitive.
      Example: a = b+c(d) and a = b + c ( d ) have different meanings. The first one c(d), will give ‘c’ of length ‘d’. The second one will call function ‘c’ with parameter ‘d’.
    2. In the ABAP custom field, i.e. custom reports, custom data element, custom domain always starts with ’Z’. It means everything we are going to create will be custom and not standard (SAP creates standard ones). So, they will start with ‘Z’ or ‘Y’.

    Example: ZBarry_Allen might be my report name

     

    1. ABAP provides both statements based syntax as well as the expression-based syntax
      Example:

      1. ADD Tax to Total.
      2. Total = Total + Tax.

    Both will give the same output.

  • ABAP Data Types and Constants

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

    Data Types

    ABAP Data types are the one which tell us about the technical characteristics of a Variable.

    By technical characteristics we mean the type of variable (Integer or Character) and its length.

    In SAP we can either use Global Variables created with the help of SE11 or can create local variables using these Data Types.

    Following are the Data Types (or Elementary Data Types) provided by SAP:

    DATA TYPE Description Default Length Default Value
    C Character 1 ‘ ’
    N Numeric 1 0
    I Integer 4 0
    F Float 8 0
    P Packed 8 0
    D Date 8 00000000
    T Time 6 000000
    X Hexa Decimal 1 X’0’
    STRING Variable Length String
    XSTRING Variable Length Raw Byte Array

     

    Constants

    Just like other languages, ABAP also provides benefits of storing some value under constants whose value cannot be altered later in the program. For example you want to store value of PI (π) i.e. 3.14 and which always have this value only, then constants will be a great help to you. The keyword is CONSTANTS.

    Example:

    CONSTANTS: pi TYPE p DECIMALS 3 VALUE ‘3.142’,

    No TYPE c VALUE ‘’.

     

    User Defined Data Types:

    To use the above data types user has to write the given codes with keyword TYPES. To define the lengths of variable type the length next to the variable name in bracket.

    Example:

    TYPES:ID (10) TYPE n,

    NAME (20) TYPE c.

     

    Structured Data Types:

    Just like other programing language where you create structures having several data variable, ABAP also provides same feature. Just like the example mentioned above we create Structured Data Types using Keyword BEGIN OF<Structure Name> and END OF<Structure Name>.

    Example:

    TYPES:  BEGIN OF EMPLOYEE_DETAILS,

    ID (10) TYPE n,

    NAME (20) TYPE c,

    END OF EMPLOYEE_DETAILS.

     

     

  • SAP System Variables

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

    SAP System Variables

    ABAP has given some predefined types of variables used to query system statuses. These variables are called SAP system variables. We use these variables to check whether a given command works properly. These are filled during runtime. They can store numeric, char, integer, date or time values. There is a field SY-SUBRC which is always zero ‘0’ in case of the correct program run.

    There is a table/structure in ABAP Dictionary (SE11) where you can find all the lists of these variables with descriptions.  They can be accessed using the keyword “SYST-” or “SY-”.

    Following are some of the SAP System Variables:

    NAME TYPE LENGTH DESCRIPTION
    SY-SUBRC i Returns value 0 in case of no error of above statement
    SY-DATUM d System Date
    SY-UZEIT t System Time
    SY-INDEX i Loop Index: Contains previous loop passes with the current one
    SY-TABIX i Row number in the table index of Internal Table
    SY-UCOMM c 70 Function Code that has raised the event PAI

    Programming Guidelines:

    1. It is recommended not to define a local variable starting with “SYST-” or “SY-” ( although not forbidden).
    2. Do not use obsolete system fields. Here is a list of obsolete ABAP system fields.
    3. Use System Fields at the right position. It means using an SY-SUBRC check after a mathematical expression will never change its value.

    Implementation of System Variables:

    WRITE: / “ABAP SYSTEM VARIABLES”.
    WRITE: / ‘DATE:’ SY-DATUM.
    WRITE: / ‘TIME:’ SY-UZEIT.

    The output for the above code is:

    ABAP SYSTEM VARIALBES
    27-06-2018
    11:34:00
    
    

    To view the complete list of ABAP System Variables, visit here.

  • ABAP IF ELSE and Case

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

    ABAP IF-ELSE and Case: ABAP Control Statements

    ABAP IF-ELSE and case statements, also known as ABAP control statements are used to control the flow of the ABAP Program based on logical statements.

    We have four types of Control Statements:

    IF Statements

    The code between Keyword IF and END IF is executed only if the condition is true.

    Example:

    DATA:   LV_NUMBER TYPE i VALUE 32.
    
    IF LV_NUMBER > 30.
    
    WRITE: / ‘You have passed the examination’.
    
    ENDIF.

    Output:

    You have passed the examination

    IF-ELSE Statements

    The code between keyword IF and ELSE is executed only if the condition is true. The code between keyword ELSE, and END IF is executed only if the condition is false. It is used to check two conditions simultaneously.

    Example:

    DATA:   LV_NUMBER TYPE i VALUE 29.
    
    IF LV_NUMBER > 30.
    
    WRITE: / ‘You have passed the examination’.
    
    ELSE.
    
    WRITE: / ‘You have failed the examination’.
    
    ENDIF.

    Output:

    You have failed the examination

     

    IF-ELSEIF Statements

    It validates multiple conditions one by one. The syntax is just like above. Apart from that, it includes Keyword ELSE IF.

    Example:

    DATA:   LV_NUMBER TYPE i VALUE 31.
    
    IF LV_NUMBER >90.
    
    WRITE: / ‘You have passed the examination with Distinction’.
    
    ELSEIF LV_NUMBER >30 AND LV_NUMBER <90.
    
    WRITE: / ‘You have passed the examination’.
    
    ELSE.
    
    WRITE: / ‘You have failed the examination’.
    
    ENDIF.

    Output:

    You have passed the examination

     

    CASE-ENDCASE Statements

    It is used to validate the conditions of a single variable based on its content. The Keywords are CASE, WHEN and END CASE. Let us suppose you are making a calculator where you provide +, -, x, / options. For that, you can take a single input, and on the basis of input, you can perform an action.

    Example:

    DATA:   LV_INPUT1         TYPE i,
    
    LV_INPUT2         TYPE i,
    
    LV_OPERATION                TYPE c,
    
    LV_OUTPUT                       TYPE i.
    
    CASE LV_OPERATION.
    
    WHEN ‘+’.
    
    WRITE: / ‘The Sum is:’ LV_INPUT1 + LV_INPUT2.
    
    WHEN ‘*’.
    
    WRITE: / ‘The Product is:’ LV_INPUT1 * LV_INPUT2.
    
    WHEN OTHERS.
    
    WRITE: / ‘Not Found’.
    
    ENDCASE.

    ABAP control statements are seldom compared with ABAP Loop Control statements. They are different and mentioned below:

    Loop Control Statements

    If you want to break the normal flow of an ABAP loop, then you need loop control statements. ABAP provide three-loop control statements, i.e. CONTINUE, CHECK, EXIT.

    CONTINUE

    This statement will pass the current loop unconditionally. It needs IF statements to apply conditions. As soon as the compiler reads this statement, it skips the current loop and goes to the next iteration. This will be clearer with an example.

    CHECK

    This statement will pass the current loop conditionally. If the CHECK condition is true, it executes the rest of the statements. Otherwise, it skips the current loop and goes to the next iteration. This will be clearer with an example.

    EXIT

    This statement will end all the iterations as soon as the compiler reads this statement. It also needs IF statements to apply conditions. After the EXIT statement, the program control goes to the statement just after the LOOP statements.

  • What are the Operations we can perform upon ABAP Strings

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

    ABAP STRING OPERATIONS

    We can perform some basic operations on ABAP strings like concatenating them, splitting them, replacing them and searching some characters in a string. Let us see some of them:

    CONCATENATE (Two Strings)

    It is a keyword that combines two or more strings into a single string.

    SPLIT (A String)

    It is a keyword that splits a string into smaller strings based upon a condition.

     

    ABAP Strings

    SEARCH (For A String)

    This keyword searches for character/string in other strings. If found, it sets SY-SUBRC = 0; else sets it 4.

    REPLACE (A String by Another String)

    This keyword replaces a substring with another substring in the main string. If replaced, it sets SY-SUBRC = 0; else sets it 4.

    For more operations on strings, go here.

  • Control Break Statements in ABAP Loop

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

    Control Break Statements in ABAP Loop

    If you want to break the normal flow of an ABAP loop, you need control break statements in the ABAP loop. ABAP provide three-loop control statements, i.e. CONTINUE, CHECK, EXIT.

    CONTINUE

    This statement will pass the current loop unconditionally. It needs IF statements to apply conditions. As soon as the compiler reads this statement, it skips the current loop and goes to the next iteration. This will be clearer with an example.

    CHECK

    This statement will pass the current loop conditionally. If the CHECK condition is true, then it executes the rest of the statements. Otherwise, it skips the current loop and goes to the next iteration. This will be clearer with an example.

    EXIT

    This statement will end all the iterations as soon as the compiler reads this statement. It also needs IF statements to apply conditions. After the EXIT statement, the program control goes to the statement just after the LOOP statements.

     

     

    ABAP LOOP

    ABAP provides keywords that can be used to run some codes again and again based on a condition called ABAP Loop. Let’s see them one by one.

    Do-END DO Statements

    These are called unconditional loops because we don’t provide any condition for the loop but provide a fixed number of times for the loop to run. If you want to execute certain codes a fixed number of times, this is the best loop to use.

     

    WHILE-END WHILE Statements

    These are called conditional loops because we provide a condition for the loop to run. Loop runs and executes the codes till the condition is true.

    In the figure below, we can see the difference between Do and While loop statements.

    Control Break Statements in ABAP Loop

    FOR LOOP Statements

    For statements are the most used statements in any language. ABAP also provides the same looping method. Syntax is: FOR i = … [THEN expression] UNTIL|WHILE condition

    You can read more about it here.

    NESTED LOOP

    Nested means using one loop under another loop. It will be clearer with an example.

  • ABAP LOOP: Everything you need to know

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

    ABAP LOOP

    ABAP provides keywords that can be used to run some codes again and again on the basis of a condition called ABAP Loop. Let see them one by one.

    Do-END DO Statements

    These are called unconditional loops because we don’t provide any condition for the loop but provide a fixed number of times for the loop to run. If you want to execute certain codes a fixed number of times, then this is the best loop to use.

     

    WHILE-END WHILE Statements

    These are called conditional loops because we provide conditions for the loop to run. The loop runs and executes the codes till the condition is true.

    In the below figure, we can see the difference between Do and While loop statements.

    abap loop

    FOR LOOP Statements

    For statements are the most used statements in any language. ABAP also provides the same Looping method. Syntax is: FOR i = … [THEN expression] UNTIL|WHILE condition

    You can read more about it here.

    NESTED LOOP

    Nested means using one loop under another loop. It will be clearer with an example.

    Loop Control Statements

    If you want to break the normal flow of an ABAP loop, then you need loop control statements. ABAP provide three-loop control statements, i.e. CONTINUE, CHECK, EXIT.

    CONTINUE

    This statement will pass the current loop unconditionally. It needs IF statements to apply conditions. As soon as this statement is read by the compiler, it skips the current loop and goes to the next iteration. This will be clearer with an example.

    CHECK

    This statement will pass the current loop conditionally. If the CHECK condition is true, then it executes the rest of the statements; otherwise, it skips the current loop and goes to the next iteration. This will be clearer with an example.

    EXIT

    This statement will end all the iterations as soon as it is read by the compiler. It also needs IF statements to apply conditions. After the EXIT statement, the program control goes to the statement just after the LOOP statements.

  • What is SAP: Systems, Applications & Products in Data Processing

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

    What is SAP?

    SAP is software as well as a Company which provides ERP solution.The initialism SAP stands for Systems, Applications & Products in Data Processing.

    It is pronounced as S-A-P. (In German language, sap means idiot. That’s why they forbid it to call sap and rather call it S.A.P)

    The SAP software is built on ABAP Programming language which was developed by SAP itself.

    The Headquarter of SAP is in Walldorf, Germany.

    The current version of SAP software is called SAP-ERP 6.0 which is an upgraded version of SAP-R/3, here R stands for ‘Real Time Processing’ and 3 stands for ‘3 tier’ platform i.e.

    1. Database
    2. Application server
    3. Client (GUI)
    what is sap
    Basic Architecture of NetWeaver Stack

    SAP-ECC i.e. ERP Central Component is the core component of the SAP’s Business Suite which consists of:

    • ERP
    • CRM
    • SCM
    • S/4 HANA

    What are Modules in SAP?

    Initially, SAP was single software for all operations but with time it evolved and started focusing upon different processes.

    To lower the load on single software and to divide the work on the basis of field, it came in different modules. SAP has following major Modules:

    • MM: Material Management
    • PP:Production Planning
    • SD:Sales and Distribution
    • HR:Human Resources or HCM: Human Capital Management
    • QM:Quality Management
    • FICO:Financial Accounting and Controlling

    What is SAP-NetWeaver?

    SAP-NetWeaver is a technology by SAP which is developed primarily using ABAP.  It is a solution stack of SAP’s technology products.

    In simpler words, it is a breadboard on which other hardware’s (here SAP-Modules/ Non-SAP modules) can be attached.

    What is SaaS?

    SaaS stands for software-as-a-service.It is a way of delivering applications/Apps over the web/internet.

    Customers can access SaaS Apps right from any Web browser via any of their devices (Mobile, PC, tablet). It means there is no requirement to buy, install, maintain, or update any Hardware or Software.

    The SaaS provider will take care of every next required operations– and the customer will always have the latest version of the application.

    Following are the major SaaS products:

    • SAP-SuccessFactors HR Solutions
    • SAP-Hybris Cloud for Customer
    • Ariba Network: Sourcing, Procurement, & Finance
    • Concur: Travel & Expense Management
    [embedyt] https://www.youtube.com/watch?v=hfxugVuYiVE[/embedyt]
  • SaaS: Everything you need to know

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

    What is SaaS: SAP Software-as-a-Service

    SaaS stands for software-as-a-service. It is a way of delivering applications/apps over the web/internet. Customers can access SaaS apps right from any web browser via any of their devices (mobile, PC, tablet), which means there is no requirement to buy, install, maintain, or update any hardware or software. The SaaS provider (here it is SAP) will take care of every next required operation– and the customer will always have the latest version of the application.
    Following are the major SaaS products:

    •  SAP SuccessFactors HR Solutions
    •  SAP Hybris Cloud for Customer
    •  Ariba Network: Sourcing, Procurement, & Finance
    •  Concur: Travel & Expense Management

    SAP SaaS: SAP on cloud

    What is SAP On-Cloud?

    SAP recently came with a service called SaaS, i.e. Software AS A Service. It is nothing different, but the SAP S/4-Cloud platform for the entire ERP suite it has. Following are some of the SAP versions, both on-cloud as well as on-premise.

    SAP On-Premise SAP S/4-Cloud
    SAP HCM SAP SuccessFactors
    SAP FSCM SAP Ariba Network
    SAP FI SAP Concur
    SAP CRM SAP Hybris Cloud

    What is SaaS

     

    What to choose between On-Premise and Cloud?

    This is a very important question regarding service selection. SAP provides ECC & ERP services in two ways. Both of them have HANA Database. The selection is purely based on the requirement of the customer. In the given table, we will explain possible conditions where these two services are applicable:

    Feature SAP On-Premise SAP On-Cloud
    Infrastructure It is installed within the premise. You have to pay for infrastructure installation. It is a cloud-based service. You need to pay for the service as per your use.
    Support The support team of the enterprise can handle it. Total support dependency is on SAP.
    Upgrade Every year new upgrades will be required. The on-cloud service is upgraded by SAP itself.
    Functional Full ERP solution is available Limited ERP solution is available
    Investment Hardware, Software and support team Payment as per service and time

     

    You can even choose a hybrid version where you can have functionality and the advantage of both on-premise and on-cloud. For more information click here.

     

    [embedyt] https://www.youtube.com/watch?v=q0oqcQ7IFZ4[/embedyt]
  • On Premise Vs Cloud SAP: What to choose among them?

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

    What is the Difference between SAP On-Premise and SAP on Cloud: On-Premise Vs Cloud?

    To know the difference between SAP on-premise vs cloud, we need to understand both of them one by one. SAP on-premise is based on the physical position of the ERP system while SAP on-cloud is an SAP Software-As-A-Service.

    What is SAP On-Premise?

    When SAP started its ERP services, it has to go physically to the place/company where it wanted to install its software.

    On-premise software is the one, which is installed and runs on the premise(the work area/building) of that company. All the ERP solutions provided by SAP, i.e. SAP CRM, SAP Suite, SAP HCM, etc., are on-premise solutions.

    sap On-Premise

    Advantages of SAP On-premise:

    • Preconfigured hardware
    • Preinstalled software
    • Solution validation by SAP and partner
    • Reduced risk
    • Increased flexibility and control

     

    Disadvantages of SAP On-premise:

    • High initial investment
    • Hardware management required
    • Software update required

     

    What is SAP On-Cloud?

    SAP recently came with a service called SaaS, i.e. Software AS A Service. It is nothing different, but SAP S/4 cloud platform for the entire ERP suite it has. Following are some of the SAP versions both on-cloud as well as on-premise.

    SAP On-Premise SAP S/4 Cloud
    SAP HCM SAP SuccessFactors
    SAP FSCM SAP Ariba Network
    SAP FI SAP Concur
    SAP CRM SAP Hybris Cloud

    on Premise vs Cloud

    Advantages of SAP On-Cloud:

    • Quick return on investment
    • Monthly pricing
    • No hardware management
    • Automatic software updates
    • Good data security
    • Scalability
    • Better utilization of resources

    Disadvantages of SAP On-Cloud:

    • Data compliance issue for confidential data
    • Existing infrastructure cannot be utilized
    • Customization and integration restriction

    What to choose between SAP On-Premise and SAP Cloud: On-Premise vs Cloud?

    This is a very important question regarding service selection. SAP provides ECC & ERP services in two ways. Both of them have HANA Database. The selection is purely based on the requirement of the customer. In the given table, we will explain possible conditions where these two services (on-premise vs cloud) are applicable:

    Feature SAP On-Premise SAP On-Cloud
    Infrastructure It is installed within the premise. You have to pay for infrastructure installation. It is a cloud-based service. You need to pay for the service as per your use.
    Support The support team of the enterprise can handle it. Total support dependency is on SAP.
    Upgrade Every year new upgrades will be required. The cloud is upgraded by SAP itself.
    Functional Full ERP solution is available Limited ERP solution is available
    Investment Hardware, Software and support team Payment as per service and time

     

    You can even choose a hybrid version where you can have functionality and the advantage of both on-premise and on-cloud. For more information, click here.

    [embedyt] https://www.youtube.com/watch?v=KVydGQGR1Lo[/embedyt]