SAP ABAP Fundamentals – Everybody needs to know!
It is used to hold the data during program run time. Variable can be declared with Different data types to contain different types of data. Such as Characters, String, Numeric, Dates, etc. It means when you create a variable it reserves some space of memory to contain information on various types of data. Variable can be declared as local and Global.
Local Variable: It can be declared locally in Subroutine, local include & function module & can be accessed in the same program.
Global Variable: It can be declared in TOP Include program that can be accessed in all subroutines, including programs & FM(Function Modules).
SAP has provided there are following types of predefined data types. It is used to create an Abap programming variable and it is also used in DOMAIN while creating an SAP table field in the data dictionary.
Type v/s Like keyword:
TYPE is a keyword. It is used to refer to a data type.
LIKE is also a keyword and it is used to copy the properties of an already existing data object which is you already created in the program.
For example for ‘TYPE’
DATA City TYPE char10.
OR DATA City(10) TYPE C.
(‘City’ is the variable name here and its data type will be character and length 10 ).
Now, for Example for ‘LIKE’
DATA City_name LIKE city.
(City_name refers to the property of ‘CITY’ and then gets assigned with data type character and length 10).
Note: CHAR10 is the data type, not the data object.
It is a structure and collection of fields that are used to hold a single line/row/record of data. It holds a maximum of one row at a time. It cannot contain multiple records at a time.
Each row of a table is a record and each column of a row is a field. A combination of fields together is called structure or Workarea.
Types: Begin of workarea_name,
Column1 Type char5,
Column2 Type char10,
Column3 Type char15
End of workarea_name.
Types: Begin of workarea_name,
Name Type char5,
Add Type char10,
Gender Type char6
End of workarea_name.
SAP Data is stored in a Standard/ database Table and suppose we need to display that standard table data in the SAP reports. So we first need to fetch the data from the database table during program run time and we need to hold those data into a temporary container that is called an Internal table. It stores data into memory from the database table during program execution time.
Example: SAP DATABASE Table
If we need to fetch the above data then we need a container to store those data in program memory.
Now we will try to create a first structure or work area then using it we will create an internal table.
Types: Begin of material,
Material Type Char18,
Created_on Type Dats,
Created_by Type Char12,
Mat_type Type Char4,
Mat_Grp Type Char9
End of material.
Data lt_Material Type STANDARD TABLE OF material.
Internal Table Types:
There are three types of Internal tables.
Standard tables The key access to a standard table uses a sequential search and the System can access records by table index or the key and the time required for access is linearly dependent on the number of entries in the internal table. The key of a standard table is always non-unique. You cannot specify a unique key. This means that standard tables can always be filled very quickly, since the system does not have to check whether there are already existing entries. You can sort them by a key and then READ via a BINARY SEARCH.
Data lt_Material Type STANDARD TABLE OF material.
Sorted tables are always sorted by the key and we cannot resort to the table. They also have an internal index. SAP System can access records either by using table index or table the key. Response time for key access is logarithmically proportional to the number of table entries. When you READ these tables, SAP automatically tries to use a BINARY SEARCH. The key of a sorted table can be either unique or non-unique.
DATA: lt_Material SORTED TABLE OF material WITH NON-UNIQUE KEY Material.
Hashed tables have no linear index. You can only access a hashed table using the key. The response time is independent of the number of table entries. The system accesses the table entries using a hash algorithm. The key of a hashed table must be unique. When you define the table, we must specify the key as UNIQUE. So we cannot insert the records between the records in the Hashed Table.
DATA: lt_Material HASHED TABLE OF material WITH UNIQUE KEY Material.
ABAP Data Dictionary:
DDIC stands for Data Dictionary. The Transaction code SE11 is used to call ABAP Dictionary. Using this we create many types of ABAP objects such as SAP Database Tables, Structure, Views, Lock Object, Search Help, Table Fields, Data Elements and Domain Etc.
SAP DATABASE Table:
SAP Tables are used to store the data records. SAP Table can contain one or more than one field, each field defined with its data type and length. When the SAP table is activated in Data Dictionary, then the SQL DDL statement CREATE TABLE is used to generate a physical database table and with all indexes from its definition in ABAP Dictionary.
There are three types of database tables available in SAP
It is used to store master data, transactional data as well as organizational data. All the business and application data are stored in this type of SAP table. Each transparent table corresponds to a physical database table.
Pooled tables are special tables in SAP ABAP Dictionary. It is used to store control information (e.g. screen sequences, temporary data, or program parameters). Several pooled tables can be combined to form a table pool. The table pool corresponds to a physical table on the database in which all the records of the allocated pooled tables are stored.
This is the logical table from ABAP Dictionary. It is used for different types of purposes such as continuous text, examples, and documentation. Several cluster SAP tables can be combined together to form a table cluster. Database, JOIN, VIEWS and APPEND Statements are not used in Cluster Tables. Cluster Tables are not directly maintained by SAP DATABASE tools and also this is easier and not created separately.
It contains the semantic characteristics of a field such as Descriptive information like field labels and documentation Etc. The domain is created under Data Element. A data element can also be referenced in ABAP programs with TYPE and you can use a data element to define the type of a table field, the structure composed of a table type.
This describes the technical characteristics of a table field such as Data Type and Length. The SAP Table field’s domain is assigned to the data element. SAP Table fields or structural components that use the data elements have the value range which is defined by the domain. SAP Domain defines a value range for a Table field.
Predefined ABAP Data Types:
There are following ABAP Data Types are used in ABAP mentioned below. These predefined elementary data types are used to specify the types of individual fields whose lengths are always fixed at runtime.
ABAP Delivery Class:
The delivery class is used to control the transportation of table data for an upgrade, installation, or client copy and transports between customer systems. The delivery class is also used for extended table maintenance.
There are many types of Delivery Classes available for different use.
Delivery Class A: Application table for master data and transaction data. The data in client-specific tables are copied only if the appropriate parameter is set, in client copies. In updates, installations, and language imports, the data in client-specific tables are imported only into the system.
Delivery Class C: Client-specific customer tables can be delivered with patterns for real data and customer tables for data entered by the customer only. In updates, installations, and language imports, the data in client-specific tables are only imported into the system. The data of client-specific tables are copied in client copies and any cross-client data is not copied.
Delivery Class L: Tables are used as a repository for temporary data. Tables in the delivery class L delivers as empty tables by SAP. Data is not copied into client copies. These tables are delivered as empty tables. Data is not transported in transport between customer systems. Data is not imported into updates, installations, and language imports.
Delivery Class G: Customer table where SAP can add data but not delete or modify it. Using the program RDDKOR54A, the customer table in the delivery class G must be assigned a customer namespace in a database table (TRESC).In client copies, the data of client-specific tables are copied and any cross-client data is not copied. The data in client-specific tables are imported as follows updates, installations, and language imports. In transports between customer systems, all data is transported only the data in the specified target client is respected in client-specific tables.
Delivery Class E: System table in which customers can make entries. Using program RDDKOR54, a system table in the delivery class E must be assigned a customer namespace in the database table TRESC. This system table is delivered with prefilled entries. In updates, installations, and language imports, all the data is imported and existing data is overwritten.
Delivery Class S: It means the system table which is delivered by SAP with predefined data as part of the system, such as ABAPDOCU_TREE containing the read-only tree of the ABAP keyword documentation. The system table is delivered with prefilled entries. The data of client-specific tables are copied into client copies. Any cross-client data is not copied. In updates, installations, and language imports, all data is imported and existing data is overwritten. Between the customer systems in transport, all the data is transported. In client-specific tables, the data in the specified target client is respected only.
Delivery Class W: The system table in the delivery class W is usually delivered with prefilled entries by SAP and it can be affected by customer modifications. The contents are transported using the transport objects assigned to the objects in question. These system tables are delivered with prefilled entries. No data is copied into client copies. All the data is imported and existing data is overwritten in updates, installation, and language imports. In transport between the customer systems, all data is transported. The data in the specified target client is respected only in client-specific tables. Data entered using extended table maintenance (T code SM30) cannot be transported here.
The technical setting of a table is used to define how the table is handled when it is created in the database. Here we can specify the table is buffered and changes to data records of the table are logged.
There are the following important parameters:
The Data Class of a table defines the physical area of the database table in which the table must be created.
There are the following types of Data Classes available in the Technical Setting.
The size category of a table defines the size of the extent created for a table. The Database system determines the required information about the memory to be selected and the extent size when the table is created in the database.
The Buffering of the technical setting defines whether the table can be buffered or not. It is used to define how many table records are loaded into the buffer when the table entry is accessed the first time.
Buffering is three types in Technical settings.
Single Record Buffered
Generic Area Buffered
If you want the table can be buffered, you must define a buffering type either Full Buffered or Generic Buffered, Single Record Buffered). It defines how many table records are loaded into the buffer when a table entry is accessed from Database.
It is used to define whether the system logs the changes to the table entries. If logging is switched on then the system records each & every change to a table record in a log table.