Category: SAP

  • SAP Tcode or Transaction CODE?

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

    SAP Tcode or Transaction CODE

    What is SAP Transaction Code?

    SAP provides an easy access menu to navigate through its various screens like ABAP reports, ABAP classes, ABAP dictionary. But instead of navigating via these menus which will take a long time to reach, they have also provided shortcut codes/ key codes also known as transaction code.

    Following are the basic SAP transaction codes that every programmer must remember:

    SAP Tcode DESCRIPTION Uses
    SE11 ABAP DICTIONARY To create SQL Objects
    SE24 CLASS BUILDER To create Global Classes
    SE37 FUNCTION BUILDER To create A Function Module
    SE38 ABAP EDITOR To create a Program
    SE80 ABAP WORKBENCH To manage all ABAP Objects

     

     

  • SAP Program: How to code in SAP ABAP Language

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

    SAP Program: Hello World in ABAP

    I believe a programmer is born with the Hello World program. So, we will start with this SAP program only.

    Follow the following steps to make your first program (Happy Coding)

    1. Open Transaction SE38
    2. Write your program name starting with Z or Y (Reason is in our ABAP syntax post)

    Example: ZBARRY_ALLEN

    1. Click on Create
    2. Write Title

    Example: This is My First Program

    1. In Attributes, select Executable Program in Type and click Save
    2. Press Local Object to save it in a temporary folder (Reason will be discussed in upcoming posts)
    3. Now, this is the screen in the SAP program where you can write your codes(Excited?)
    4. Just write the code below:
     WRITE “HELLO WORLD”.
    1. Now, click Save, Check and Activate one by one, as shown below.
    2. Now run the SAP program by clicking on Run or pressing F8.

    That’s it. You have successfully written your first ABAP program.

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