Category: SAP

  • SAP Tables: How to Create SAP ABAP Tables

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

    SAP Tables

    Unlike other Database where we write SQL commands (DDL) to create table, SAP provides us option to create Tables in ABAP Dictionary. Upon Activation, SAP Tables are actually defined in database.

    Creation of SAP Tables:

    #Using ABAP Dictionary

    Step 01: Open SE11.

    Step 02: Click Database table Radio Button and give your Table name starting with Z or Y e.g. “ZBarry_Table”.

    Step 03: Click Create, Enter explanatory description for table in Short Description e.g. “Table for Test”.

    Step 04: Under Delivery & Maintenance tab maintain the following:

     FIELDS Value Description
    Delivery Class Select from given drop down

    A –Application Table

    C – Customer Table

    A Delivery class controls the transport of table data.
    Data Browser/ Table View Maint. Select the Maintenance option from given drop down If allowed, It allows the table owner to maintain data via SE16.

     

    Step 05: Under Fields tab maintain the following:

    FIELDS Value Description
    Field It can be 16 digit Alphanumeric word starting with a letter and can contain underscore It is the column name of your table
    Key Tick all the fields whose value will be unique and can define the relationship with other tables A table must contain at least one key field, else it can’t be activated.
    Initial Value Indicator Tick if the field must have an initial value All key fields must always be given initial values. By default all fields are assigned initial values irrespective of indicator.
    Data Element Select your Data Element or create one If you are not using Predefined Type, you need to provide a Data Element
    Predefined Type : If you are not using Data Element, click the Predefined Type tab & enter following:
    Data type Any Data type like CHAR,INT According to requirement specify the data type
    Length Give max length of your field Length will be dependent upon Data Type
    Decimal places Number of places after decimal point Mainly for Float variables
    Short description Explanatory statement for your field What your field means/doing
    Include Structure: Whenever we include a structure in table, it might have fields with same name as there are other fields in table. To avoid conflict we address the field with a suffix (3-27 Character with ‘-‘) for that structure. This suffix is given in Group tab.
    Group 3-27 Character To Address Include Structure fields

     

    Note: Maintain foreign key relationship by clicking. Also maintain Search Help by clicking Srch Help tab.

    Step 06: Under Entry help/check tab maintain the following: It will be maintained automatically after step 05. [You can skip this step]

    FIELDS Value Description
    Field Same as above Same as above
    Data Element Same as above Same as above
    Data Type Same as above Same as above
    Foreign Keys Foreign Keys for that field It will be reflected after you maintain Foreign Key relationships
    Check Table Check Table for Field It will be reflected once you have check table relationship for the field
    Origin of input help Input help with fixed values, with check table, search helps, Static Input Help It reflects the way your input will be made to the given field
    Srch Help Your Search Help name To attach Search Helps to field
    Defaults Any Value depending upon the type of field To assign Default value for the field
    Domain Domain of specified Data Element If your Data Element has a Domain, it will reflect here

     

    Step 07: Under Currency/ Quantity Fields tab maintain the following: [You can skip this step]

    FIELDS Value Description
    Field Same as above Same as above
    Data Element Same as above Same as above
    Data Type Same as above Same as above
    Reference Table Reference Table name If your data element refers to a table
    Reference Field Field of Reference table being Referred It is actually the field being referred by the data element
    Short Description Same as above Same as above

     

    Step 07: Maintain Indexes and Append Structure from respective tab. [You can skip this step]

    Step 08: Maintain following @Technical Settings: [Important Step]

    FIELDS Value Description
    Data Class APPL0 – Master Data
    APPL1 – Transaction DataAPPL2 – Organizational Data
    It describes the type of Data you will be storing
    Size category From 0 to 4 It defines the expected space required for table in database
    Buffering Choose from Radio Button It tells whether your table will be using buffering or not. If yes, then which type of Buffering.

     

    Step 09: Once all the above fields are maintained, save, check for errors and activate your table.

     

    Additional Information

     

    • All Key fields should be maintained in the beginning.
    • Maximum 16 key fields are permitted per table.
    • Length of key field can be max 255 characters (and 120 if data is to be transported).
    • A table can have total 249 fields.
    • A field name must not be longer than 16 characters.
    • Fields of type STRING, LRAW, LCHR must be at the end of table.
    • Fields without data element cannot have foreign keys, F1 Help and fixed values.
    [embedyt] https://www.youtube.com/watch?v=9Ejtbd9SS7Y[/embedyt]
  • SAP ABAP Data Elements

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

    DATA ELEMENTS

    We cannot use Domain directly neither in a Report/Program nor as a table field. We need to add some semantic information i.e. Field Label, heading, etc. For this purpose we need data elements.

    Definition:

    Data Elements are reusable objects that are used to add Field Label, Heading, Documentation (F1 Help) and assign a parameter ID and a Search Help (F4 Help).

    Note:  In Domain Level also we have an option to define Search Help which fetches either fixed value defined there or from Value Help Table while the one we assign in Data Element is from Global Search Helps that we create via SE11.

    Creation of Data Elements:

    #Using ABAP Dictionary

    Step 01: Open SE11.

    Step 02: Click Data type Radio Button and give your Data Element name starting with Z or Y e.g. “ZBarry_DataElement”.

    Step 03: Click Create, Choose Data Element Radio Button and Enter explanatory description for Data Element in Short Description e.g. “Data Element for Test”. This short Text appears as title of Data Element F1 help Documentation.

    Step 04: Under Data Type Tab, you will have two options.  Choose any one and provide its corresponding details.

    FIELDS Value Description
    Elementary type:  It is used to define Data Element on the basis of either Domain or predefined Data types.
    1. Domain Enter your Domain Name It adds technical characteristics in Data Element same as that of Domain.
    2. Predefined Type Enter Data Type & Length Data Type can be any predefined data types with any length.
    Reference Type:  It is used to create a pointer to data objects.
    1. Name of Ref. Type Name of Class, Interface, Object, ANY or Data The Data Element will point to the given Value.
    2. Reference to Predefined Type Enter Data Type, Length and Decimal Places Data Type can be any Predefined Data Type like CHAR, INT and Length & Decimal Places can be of any length.

    Step 05: Add your Search Help, Parameter ID, Default Component Name and Mark your Data Element as a change document under Further Characteristics tab. For more read ABAP Documentation.

    Step 06: Add Short, Medium, Long, Heading field label under Field Label tab. Field Label is used to display the name of fields in Parameters of Report, column Header of Table & structure. The purpose of providing different Labels is that these labels are displayed according to input template size.

    [embedyt] https://www.youtube.com/watch?v=MxJsMhgQVeo[/embedyt]
  • Domain in ABAP

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

    Domain in ABAP

    To define Data in ABAP Dictionary we need Domain, Data Element and Tables. Domain in ABAP is the smallest unit that is defined in ABAP Dictionary. Thereafter, Data Element is created which further describes the domain to the End User. Thereafter Table is created which utilizes the Data Element.

    All domains are saved in a Standard ABAP Table DD01L and their Text Descriptions are saved in Standard ABAP Table DD01T.

    Definition:

    Domain in ABAP is a reusable object that is assigned to a Data Element and it is used to define a value range (F4 Help) and provides technical attributes (Data Type, Number of character, etc).

     

    Creation of Domains:

    #Using ABAP Dictionary

     

    Step 01: Open SE11.

    Step 02: Click Domain Radio Button and give your domain name starting with Z or Y e.g. “ZBarry_Domain”.

    Step 03: Click Create, Enter explanatory description for Domain in Text Field e.g. “Domain for Test”.

    Step 04: Under Definition tab we have two options whose significance are described below:

     

    FIELDS Value Description
    Format
    Data Type Choose from pre-defined values It describes type of data e.g. INT for Integer and CHAR for Character
    No. of Characters Maximum length of Data 20 for CHAR means 20 Letters allowed
    Decimal Places Max. allowed Decimal Values Decimal Places mainly for Float Type Value e.g. 10000.08
    Output Characteristics
    Output Length Max. Output Length It is mainly for Floating Values
    Conversion Routine Two Function Modules:

    CONVERSION_EXIT_xxxxx_INPUT

    CONVERSION_EXIT_xxxxx_OUTPUT

    Takes Input in one format and return as another e.g. Takes 02.01.2009 as Input and Returns 02 Jan 2009 as Output
    Sign Negative Set if your data can be negative
    Lower Case Lower Case Toggles Case

     

    Step 05: Under Value Range you can fix your Input using following three ways:

    • Fixed Value Range: If you Want to Fix Input of Gender, you can create following
    Fixed Value Description
    F Female
    M Male

     

    • Interval Value Range: If you want to give Interval as Value Range
    • Value Help: If you want to give fix value from given table. This is the concept of Value Table and Check Table which we will discuss in upcoming chapters.
    [embedyt] https://www.youtube.com/watch?v=sTWpe9rvmQo[/embedyt]
  • ABAP Data Dictionary

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

    ABAP Data Dictionary

    Before we jump directly in to Data Dictionary concept, let us learn something about basic SQL operations. To perform any operation on Data we need to perform two things: Define Data and Manipulate Data. Both of these operations are achieved by SQL [Structured Query Language] operations. SQL is a language that helps us to communicate with our database.

    SQL can be, therefore, divided into two parts:

    DDL: DATA DEFINITION LANGUAGE

    DML: DATA MANIPULATION LANGUAGE

    DDL part of ABAP is managed by ABAP Dictionary. Data Dictionary is used to create and manage data definitions (metadata).  ABAP Dictionary helps to create user defined types (domain, data elements, structures and table types) which are further utilized by ABAP objects (tables or views).

    DML part of ABAP is written using open SQL commands like:

    OPEN SQL COMMAND DESCRIPTION
    SELECT To Read Data from Database
    INSERT To Insert Data in Database
    UPDATE To Update current Data in Database
    MODIFY To Insert/Update Data in Database (whichever applicable)
    DELETE To Delete from Database

     

    Features of ABAP Dictionary:

    1. DOMAIN: A reusable object that is assigned to a Data Element and it is used to define a value range (F4 Help) and provides technical attributes (Data Type, Number of character, etc).
    2. DATA ELEMENT: A reusable object that takes attributes of a Domain. It is used to create Field Labels & Field Documentation that appears as field help (F1 Help).
    3. TYPES [STRUCTURE]: A reusable object that is used to create a global structure. TYPE option in ABAP is also used to create DATA ELEMENTS and TABLE TYPES.
    4. TABLE TYPES: A TABLE TYPES is used to create global Internal Table. A TABLE TYPE needs a LINE TYPE that acts as the workarea of that Internal Table.
    5. TABLES: A TABLE is used to create a physical table definition in database. These are defined in ABAP Dictionary independently of the database [that means every Table in independent with respect to other tables and storage].
    6. VIEWS: It creates logical View of more than one table. By Logical View we mean a view that is presented to the user not that is actually stored in database [also called Physical View].
    7. SEARCH HELPS: These are the objects that are used to create and assign Input Help (F4 HELP) to screen fields.
    8. LOCK OBJECTS: These are used to synchronize the access of same data by different users.

    Advantages of ABAP Dictionary:

    1. Data Integrity
    2. Data Consistency
    3. Data Security
    4. Data reusability

     

  • SAP Variable- SAP ABAP Variable

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

    SAP ABAP Variable

    The data objects that stores value according to allotted memory space are called Variables. As the name suggests values of VARIABLE can be varied using ABAP statements. SAP variable can be of Predefined Data Types that we have discussed in our earlier post or of Data Elements Type that we will discuss later. In this post I will show how to declare Data Variables using predefined Data Types.

    ABAP Variables are declared using keyword DATA. These are created every time during Program execution and destroyed after every execution.

    Example:

    1. Declaring single variable.DATA NAME (20) TYPE n.

     

    1. DECLARING USING DEFAULT DATA TYPE: Character is the default data type i.e. if you are not giving any data type it will be a character.

     

    DATA NAME (20).

     

    1. Declaring multiple variable using colons (:).

    DATA:   ID (10) TYPE n,

    NAME (20) TYPE c.

    1. Declaring Variable using LIKE instead of TYPE keyword. LIKE keyword is used if the data type of given variable is same as the one we have already used. We make the second variable like the first variable.

    DATA:   FIRST_NAME (10) TYPE c,

    LAST_NAME (10) LIKE FIRST_NAME.

    1. Declaring Structured Variable. In our previous post we learned about Structured Data Types. Similarly, we can define structured Variable using keyword BEGIN OF<Variable Name> and END OF<Variable Name>.

     

    DATA:   BEGIN OF EMPLOYEE_DETAILS,

    ID (10) TYPE n,

    NAME (20) TYPE c,

    END OF EMPLOYEE_DETAILS.

     

    1. Declaring Variable Using/Referring Existing Structured Data Type:We can declare a structure Data Type and can reuse it in different ways to create Structured Variable.

    Example:

    TYPES:   BEGIN OF ADDRESS,

    HOUSE_NUMBER (10) TYPE n,

    NAME (20) TYPE c,

    END OF EMPLOYEE_DETAILS.

    DATA:   HOUSE_ADDRESS TYPE ADDRESS,

    OFFICE_ADDRESS LIKE HOUSE_ADDRESS.

     

    Difference between Structured Data Type and Structured Variable:

     

    1. DATA TYPES are structures that are created to be used by DATA to create variables.
    2. DATA TYPES creates structure using keyword TYPES that holds no memory while Variables created using keyword DATA holds memory.

    Accessing SAP Variable of Structured Variable:

     

    To access each individual field of structured variable, we use hyphen (-).

    Example: Here we will access NAME from EMPLOYEE_DETAILS (Point 5 Above is a Structured Variable)

    EMPLOYEE_DETAILS-NAME

    To assign value we use equal to sign (=)

    EMPLOYEE_DETAILS-NAME = ‘BARRY ALLEN’.

  • SAP Operator: Arithmetic and Comparison Operation

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

    SAP Operator: Arithmetic Operators

    Following are the basic SAP Operator using which Arithmetic operations can be performed upon ABAP variables:

    1. Assign Values to variables

    To assign value to a variable, we can use equal to “=” sign or Keyword MOVE.

    DATA:   LV_NUMBER1 TYPE      n,

    LV_NUMBER2   TYPE     n.

    LV_NUMBER1 = 10.

    MOVE LV_NUMBER1 TO LV_NUMBER2.

    WRITE: / LV_NUMBER1, LV_NUMBER2.

    OUTPUT:

    1. Apply Sum, Subtraction, Multiplication and division on two or more variables

    DATA:           LV_NUMBER1 TYPE      n             VALUE  10,

    LV_NUMBER2   TYPE     n             VALUE  20,

    LV_ADD                TYPE     n,

    LV_SUB                 TYPE     n,

    LV_MUL               TYPE     n,

    LV_DIV                 TYPE     n.

    LV_ADD = LV_NUMBER1 + LV_NUMBER2.

    (OR)

    A = ADD LV_NUMBER2 TO LV_NUMBER1.

    LV_SUB = LV_NUMBER1 – LV_NUMBER2.

    (OR)

    B = SUBTRACT LV_NUMBER2 FROM LV_NUMBER1

    LV_MUL = LV_NUMBER1 * LV_NUMBER2.

    (OR)

    C = MULTIPLY LV_NUMBER1 BY LV_NUMBER2

    LV_DIV                 = LV_NUMBER2 / LV_NUMBER1.

    (OR)

    D = DIVIDE LV_NUMBER2 BY LV_NUMBER1

    WRITE: / LV_ADD, LV_SUB, LV_MUL, LV_DIV.

    (OR)

    WRITE: / A, B, C, D.

     

    1. Clear Variables

    Keyword CLEAR is used to clear the values in variable to default values i.e. 0 for numeric and “ ” for character field.

    WRITE: / “BEFORE CLEAR”.

    WRITE: / A, B, C, D.

    CLEAR: A, B, C, D.

    WRITE: / “AFTER CLEAR”.

    WRITE: / A, B, C, D.

     

     

    ABAP MATHS FUNCTIONS

    ABAP provides predefined built-in maths functions that you can use according to your requirement.

    Following are some of the Maths Functions:

    FUNCTIONS SUPPORTED NUMERIC DATA TYPES DESCRIPTION
    ABS ALL TO CALCULATE ABSOLUTE VALUE
    SIGN ALL TO DETERMINE SIGN, RETURNS 1 FOR (+) 0 FOR (-)
    CEIL ALL It gives next highest integer i.e.  ceil (2.1) = 3
    FLOOR ALL It gives next lowest integer  i.e. floor (2.1) = 2
    TRUNC ALL It gives truncated part of the input
    FRAC ALL It gives fractional part of input i.e. FRAC(1.2) = .2
    COS,SIN,TAN F It will implement the given trigonometry function
    EXP F It will implement Exponential function
    LOG F It will implement Natural Log on that number
    SQRT F It will return square root of the input
    MOD N It will return remainder mod(12,5) = 2

     

    SAP Operator: Comparison Operators

    Following are the SAP Operator provided for ABAP Comparison Operation:

    Operator Alternate Form Meaning
    = EQ Equality Test returns 1 if equal
    <> NE Inequality Test return 1 if True
    > GT Greater Than Test
    < LT Less Than Test
    >= GE Greater than or Equal
    <= LE Less than or Equal
    BETWEEN Interval Test returns value between two value
    IS INITIAL Initial Test returns True if variable have no value
    IS NOT INITIAL Not Initial Test returns True if variable is not empty

     

    Apart from above operators ABAP also provide Bitwise Operators and Character String Operators

  • What is ABAP

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

    What is ABAP?

    A general interview question: “What is ABAP?”. ABAP stands for Advanced Business Application Programming. It is a 4th Generation (because it is domain specific language) programming language developed by SAP. The ABAP kernel is implemented in C++.ABAP is a hybrid programming language that supports both a procedural and an object-oriented programming model.
    All ABAP programs also called Reports reside inside SAP database. In the database all ABAP code exists in two forms: source code, which can be viewed and edited with the ABAP Workbench tools; and generated code, a binary representation somewhat comparable with Java byte code.

    When you write a code in ABAP editor, it is saved in two files. One is the exact what you have written and other is the code converted in Binary format. The Binary code is the one actually executed by the computer.

    ABAP has both compiler and Interpreter. Firstly, the ABAP compiler translates an ABAP program it into an intermediate language called an ABAP load. Then the ABAP virtual machine, an interpreter for ABAP loads (i.e. it can execute ABAP loads) comes into the picture. SAP has two tables to store these files, ABAP reports in D010S table and ABAP Loads in D010L table.

    ABAP on Application Server ABAP

    ABAP is the programming interface of Application Server ABAP (AS ABAP) in SAP NetWeaver. A prerequisite to use the ABAP programming language is to install an Application Server ABAP. The components of an Application Server ABAP can be organized in the layers (presentation, application, and database) of three-tier client-server architecture in accordance with their tasks.

    • The presentation layer represents the user interface of an AS ABAP (SAP GUI or Web browser)and it is distributed to the workstations of individual users.
    • The application layeris implemented by utilizing one or more application servers. The application layer contains the ABAP runtime environment in which ABAP programs are executed.
    • The database layerconsists of a database system in which the central dataset of an Application Server ABAP is saved.

    Programming Models

    ABAP supports the following:

    • An object-oriented programming model based on classesand interfaces
    • A procedural programming model based on function modulesand subroutines

    Both modules offer interoperability.

    Types of ABAP programs

    ABAP distinguishes two types of executable programs:

    • Reports : Simple Programs which provides Input/output option to user
    • Module pools: Complex Programs which provides different screens for better user experience.

     

    The non-executable program types are:

    • INCLUDE modules : It gets included automatically at generation time; it is often used to subdivide large programs
    • Subroutine pools: It contains ABAP subroutines (enclosed by FORM/ENDFORM statements and invoked via PERFORM).
    • Function groups: These are libraries of self-contained FMs (enclosed by FUNCTION/ENDFUNCTION and invoked via CALL FUNCTION)
    • Object classes: similar to Java Classes &define a set of methods and attributes
    • Interfaces: It contain method definitions without implementations for which any class implementing the interface must provide explicit code.
    • Type pools: Type pools define collections of data types and constants.

     

    Development Environment

    There are two possible ways to develop in ABAP.

    ABAP Workbench

    The ABAP Workbench is part of the SAP ABAP system and is accessed via SAPgui. It contains different tools for editing programs. The most important of these are (transaction codes are shown in parentheses):

    • ABAP Editor(SE38): It is used to write and edit reports, module pools, includes and subroutine pools
    • ABAP Dictionary(SE11): It is used to process database table
    • Menu Painter(SE41): It is used to design the user interface (e.g. menu bar & standard toolbar)
    • Screen Painter(SE51): It is used to design screens and flow logic
    • Function Builder(SE37): for function modules
    • Class Builder(SE24): It is used to construct ABAP Objects classes and interfaces

    The Object Navigator (SE80) provides a single integrated interface to access various tools (including all tools mentioned above).

    ABAP Development Tools

    • Using certain set of plug-in in the Eclipse platform we can develop ABAP programs in eclipse, these are formally known as “ABAP in Eclipse” or ABAP Development Tools (ADT).
    • In this scenario, the ABAP developer installs the required tools on his computer and works locally, whereas a continuous synchronization with the backend is performed.
  • SAP Memory and ABAP Memory: Different types of Memory in SAP

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

    SAP Memory and ABAP Memory: Different types of Memory in SAP

    In this post we will discuss SAP Memory and ABAP Memory i.e. ABAP memory organization with reference to the ABAP program; that is, which memory is accessed by an ABAP program. There are three types of memory in SAP system:

    • SAP Memory / Shared Memory
    • User Memory
    • ABAP Memory

    SAP Memory / Shared Memory

    • In our previous post, we talked about sessions. SAP memory will have access of all the main sessions within the SAP GUI.
    • You can use SAP memory either to pass data from one program to another within a session, or to pass data from one session to another.
    • An ABAP program uses SET/GET parameters to access SAP memory. These parameters are set for a particular user or program using the SET PARAMETER statement. Other ABAP programs retrieve the already set parameters using the GET PARAMETER statement.
    • The most frequent use of SPA/GPA parameters is to fill input fields on screens

     

    User Memory

    User Memory is the memory that is allocated for each user who is logged in.  A user session is assigned its own memory area of the user memory, in which SPA/GPA parameters can be stored.SPA/GPA parameters are set using SET PARAMETER and read using GET PARAMETER.

     

    ABAP Memory

    • Each SAP session contains an area called ABAP memory. ABAP memory is available to all internal sessions.
    • ABAP programs uses the EXPORT and IMPORT statements to access it.
    • All ABAP programs can also access the SAP memory.

     

     

     

  • Official ABAP Programming Guidelines

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

    Official ABAP Programming Guidelines [As per SAP Documentation]:

    ABAP Programming Guidelines as per the official SAP documentation consists of the following major points:

    Follow the KISS principle:

    KISS is an acronym and can have any of the following meanings (the list is not exhaustive):

    • Keep it simple, stupid.
    • Keep it small and simple.
    • Keep it sweet and simple.
    • Keep it simple and straightforward.
    • Keep it short and simple.
    • Keep it simple and smart.
    • Keep it strictly simple.
    [Add on: I will say follow KISS ASS principle, i.e. Keep It Short, Smart and Strictly Simple]

    Have less nesting depth:

    It means try not to write loops under loops or Select Query / SQL commands under loop statements. It affects the execution badly.

    Follow the SoC principle:

    • Follow the separation of concerns principle. As a result, the software:
    •  is more stable
    • easier to understand
    • can be reused more easily
    • easier to transport
    • has better maintenance
    • can be tested more easily

    It can be as simple as keeping data declarations and the implementation of the functions separate to keeping different segments of codes under different methods of a class for better understanding.

    Comply with or check compliance with existing product standards:

    Adhere to the product standards that exist in your organization, and ensure the correctness and quality of your programs by testing them during development and after completion with all the test tools at your disposal.

    As part of this basic rule, we recommend that you use all available tools that help to ensure the correctness and quality of ABAP programs and follow the ABAP programming guidelines.

    ABAP Programming Guidelines

    • Include the extended program check(transaction code is SLIN) in your programming routine and correct all messages (It will display the errors in the form of messages).
    • Always use the Code Inspectortool (transaction SCI) using the standard check variant, and correct all messages.
    • You must check the usability & accessibility of your interface (GUI) elements by using all available appropriate tools (integrated into the workbench tools and ABAP Test Cockpit).
    • You must cover all the functions of your procedural units by using unit tests with ABAP Unit (integrated into ABAP Workbench, Code Inspector, and ABAP Test Cockpit).
    • All the functions of your application must be covered by using scenario tests (e.g. for calculator, the scenario will be two inputs and pressing Add ‘+’ button) with eCATT (transaction SECATT).
    • For better performance of your code, check the memory consumption of your programs, and for that, you can use ABAP Memory Inspector (transaction S_MEMORY_INSPECTOR), and by using the memory analysis function integrated into the ABAP Debugger.
    • Check runtime behaviour and performance by using the ABAP runtime analysis tool (transaction SAT).
    • Check the test coverage by using a coverage analyser (transaction SCOV and integrated into ABAP Unit Browser of ABAP Workbench).
    • You must follow the ABAP – Security Notes(for more, visit: https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abenabap_security.htm) to protect your programs and data from attacks from outside.
    • A programmer must make his program readable. For that, you need to Document your programs (codes) and services using all available means: Starting with comments, this ranges from simple data element documentation for context-sensitive input help, to class and method documentation for documenting APIs, to explanations of concepts and tutorials in other repositories such as SAP Knowledge Warehouse, or on the Internet, for example in the SAP Developer Community (SCN, http://scn.sap.com).

    What I actually wanted to tell you is that whenever you start coding, use the tools underlined above. You might not need them, and you might be a perfect coder, but nobody in the industry will tell you to use ABAP programming guidelines, and your code will fail in the testing phase. So, make it a habit to follow the ABAP programming guidelines.

    More ABAP Programming Guidelines

    • Use ABAP objects: Use ABAP objects wherever possible for new and further developments. Here are the reasons why:
      • Data encapsulation: Simple Reports, FM doesn’t give a clear differentiation between externally and internally usable data. But ABAP object does use PUBLIC, PRIVATE and PROTECTED sections.
      • Explicit instantiation: Multiple instantiations and automatic garbage collection (it means auto-deletion of unused memory) have exclusive advantages.
      • Inheritance: Reuse of classes via inheritance reduces code.
      • Interfaces: This means that developers do not need to concern themselves with the implementation details of the class behind the interface.
      • Events: Events define a program flow strictly, and event trigger does not need to know about any other handlers.
      • Cleansed Syntax: Classical ABAP reports have evolved over time and contain several obsolete and overlapping concepts.These obsolete concepts were kept aside during the construction of ABAP object concepts
      • Access to new technology: ABAP objects are often only the way to deal with new technology. Web Dynpro ABAP and ICF (Internet Connection Framework) provides only class-based interfaces. UI5 supports classes and FMs only.

     

    • Original Language: Once specified, there is currently no technical support for the replacement of an original language by another language across an entire project. We specify it every time we create a new object in ABAP repository.
    • Program Type: Select the appropriate program type according to your requirement. Following are the possible program types in ABAP(We will read about them in detail later):
      • Executable program: ABAP Editor creates executable programs. These are simple programs and supports selection screens.
      • Class pool: The Class Buildertool in ABAP Workbench (SE80) can define these. They are used as a repository for global classes and interfaces.
      • Interface pool: These are the ABAP programs that contains the definition of exactly one global interface and it is loaded using the interface.
      • Function group (function pool): All function modules we create belong to a function group. A function group is a collection of function modules sharing global data with each other.
      • Module pool: The ABAP editor (SE38) helps create a module pool. They are a collection of screens and are called via transaction codes.
      • Subroutine pool: ABAP editor (SE38) creates these. They are a collection of subroutines.
      • Type group (Type Pool): ABAP Dictionary (SE11) creates these. They are a group of TYPES and CONSTANTS.
  • What are SAP Session

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

    What are SAP Session?

    “SAP Session” are a way to control the number of logins or number of active users on a single landscape. To make it easier, let us assume that we have three landscapes, i.e. ISD, IST, ISP. These three landscapes will be used for different purposes, i.e. for development, testing and production. There are three types of sessions in SAP:

    • User Session
    • ABAP Session
    • Internal Session

    Now, SAP has given you three different environments. These are nothing but user sessions. As soon, you have opened SAP GUI, you have logged into a user session. And now you have logged in to ISD, i.e. for development.  In this scenario, you have also logged in to the ABAP session.  Now, you have opened the SE38 transaction to make a report, so now you have logged in to the internal session.

    If you have understood the sessions, then we can proceed with the definitions.

    User Session

    Logging on to an application server opens a user session. Logons take place using SAP GUI, the RFC interface, or ICF. A user session is assigned its own memory area of the user memory. From a user session, it is possible to open further user sessions on the same application server or another server in a program-driven way.

    ABAP Session

    An ABAP session is opened for each user session. Each ABAP session is assigned its own memory area of ABAP memory, in which data clusters can be stored.

    Further ABAP sessions for a user session can be opened as followed:

    • Enter a transaction code after “/O” in the command field in the toolbar.
    • Call the function module TH_CREATE_MODE.
    • Call a Dynpro when processing an asynchronous RFC.

    A maximum of 16 ABAP sessions are possible per user session, and the default is 6.

    Internal Session

    Each call of an ABAP program creates a new internal SAP session in which the called program is loaded. This is where the modifiable objects of the program are held. In one ABAP session, the maximum number of internal sessions can be nine.

    Close a hung SAP Session

    Let’s say you want to end session three. You can go to either session one or two and enter this command in the transaction box: /i3.
    This will immediately close the hung up session (session four in this case).

    Or you can do this the long way by going to SM04 and double-click your user ID, select a session and hit ‘end session’.