ABAP Presentation
ABAP Presentation
SAP Software was Founded in 1972 by Wellenreuther, Hopp, Hector, Plattner and Tschira.
SAP system consists of a number of fully integrated modules, which covers virtually every aspect of the business
management.
2. Sales team approaches the Inventory department to check for the availability of the product
3. In case the product is out of stock, the sales team approaches the Production Planning Department to manufacture
the product
4. The production planning team checks with inventory department for availability of raw material
5. If raw material is not available with inventory, the Production Planning team buys the raw material from the Vendors
6. Then Production Planning forwards the raw materials to the Shop Floor Execution for actual production
7. Once ready, the Shop Floor Team forwards the goods to the Sales Team
9. The sales team updates the finance with revenue generated by the sale of the product. Production planning team
update the finance with payments to be made to different vendors for raw materials.
10. All departments approach the HR for any Human Resource related issue.
Key benefits of the centralized system are:
•Increases productivity, better inventory management , promotes quality , reduced material cost,
effective human resources management, reduced overheads boosts profits
•Better customer interaction and increased throughput. It also improves customer service
•SAP Software is a centralized enterprise management system also known as Enterprise Resource
Planning.
Sap R/3 Architecture Tutorial
• Presentation
• Application
• Database
Components of SAP R/3 Architecture
• Dispatcher Queue: Various work process types are stored in this queue.
• Gateway: It enables communication between SAP system and between SAP system
and external systems.
• ABAP-Work processes: - It separately executes
dialog steps in R/3 applications.
Types of work processes are given as below:-
• Memory-pipes: It enables communication between ICM and ABAP work processes.
• Message Server: It handles java dispatchers and server processes.It enables communication within java
runtime environment.
• Enqueue Server:It handles logical locks that are set by the executed Java application program in a
server process.
• Central Services: Java cluster requires a special instance of the central services for managing locks and
transmitting messages and data. Java cluster is a set of processes that work together to build the reliable
system. Instance is group of resources such as memory, work processes and so on.
• Java Dispatcher: It receives the client requests and forwards to the server process.
• Threading: Multiple Processes executes separately in the background, this concept is called threading.
• ICM: It enables communication between SAP system and HTTP, HTTPS, SMTP protocol. It means by
entering system URL in the browser you can access SAP from browser also.
How the SAP Logon Process works?
1) Once a user clicks on the SAP system from GUI, the user request is forwarded to Dispatcher.
2) Request is stored in Request queues first. Dispatcher follows First in First out rule. It will find free
work process and if available will be assigned.
3) As per user request, particular work process is assigned to user. For example, when user login to the
system then Dialog work process is assigned to the user. If user runs a report in background then
background work process is assigned to the user. When some modifications are done at database level
then update work process is assigned. So as per user's action work process is assigned.
4) Once user is assigned the dialog work process then user authorizations, user's current setting are
rolled in to work-process in shared memory to access user's data. Once dialog step is executed then
user's data is rolled out from work process. Thus shared memory will be cleaned and other user's data
can be saved in shared memory area. Dialog step means the screen movements. In a transaction,
when a users jumps from one screen to other the process is called a dialog step.
5) First work process will find the data in the buffer. If it finds data in buffer then there is no need
to retrieve data from database. Thus response time is improved and this process is called hit.If it
does not find the data in buffer then it will find the data in database and this process is called
miss. Hit ratio should be always higher than miss ratio. It improves the performance of system .
6) Other requested data is queried from the database and once the process is complete,the result
is sent back to GUI via dispatcher.
7) At the end user's data is removed from shared memory so the memory will be available to
other users.This process is called roll-out.
ABAP T CODES:
• Smartforms – Smartform
A Table is Simply Group of fields and which can store multiple records.
• TRANSPARENT: It is used to store application data such as Master and Transactional Data.
• We always create Transparent tables only.
• There is a One to One relatioinship i.e. for the table in DDIC another table with the same structure and the same
name and the same fields will be created in the original Data base.
• POOLED: It should be used exclusively for storing internal control information (screen sequences, program parameters,
temporary data, continuous texts such as documentation).
• The data from several different pooled tables call be stored together in a table pool.
• This is Many to One relationship i.e. for many pooled tables in DDIC only one Data base table will be created in
the Database.
• CLUSTER: It should be used exclusively for storing internal control information (screen sequences, program parameters,
temporary data, continuous texts such as documentation).
• The data from several different cluster tables call be stored together in a table clusters.
• This is Many to One relationship i.e. for many cluster tables in
DDIC only one Data base table will be created in the Data Base.
All the Tables in the Cluster Tables should have a common Primary Key.
TABLE CREATION
We Call Provide the technical attributes such as Data type, Length and Description of the Fields in 2-ways (Refer
the below
diagram).
• One Way is providing the technical attributes Directly i.e Provide the Data type, Length and Description
Individually.
• 2nd Way is providing the technical attributes through Data Elements and Domains i.e Provide the Data type
length and Description by grouping into Data Elements and domains.
•
Table Table T
B
Fields O
Fields P
O
T
T
B
O
Data O
Data M
Description T
Element T
Length T
O
O
M
P
Domain
In Table creation we have the following
• Domain:- It is used to define the Technical Attributes (Data type and Length) and the Value ranges (Fixed
values and Intervals). A domain is assigned to a data element . All the table fields or structure components
that use this data element then have the value range defined by the domain.
• Data Element:-- A Data Element describes either an elementary type or a reference type . An elementary
type is defined by the built-in data type, length and possibly the number of decimal places. These type
attributes can either be defined directly in the Data Element or copied from a domain.
• Delivery Class:- It Defines the type of the data that is going to be stored and also it defines the owner of the Table
and also the delivery class controls the transport of tables data for installation, upgrade, client copy and when
transporting between customers systems.
• Data Class: - It is the physical area or table space that the table has to be stored in the Database.
• Size Category- The size category defines the expected space required for the table in the database. You call choose
a size category from 0 to 4 for your table. Each category is assigned a certain fixed memory size in the database,
which depends on the database system used.
• Table Maintenance Allowed: If you click on this click box, you call enter the entries into the table.
DATA TYPES
BOTTOM- UP Approach
Maintain Field Label. This Label will be displayed when we refer the same While Designing the Screen
in Module Pool Programming.
CHAR : Character string. Fields of type CHAR may only have a maximum length of 255 in tables. If longer character
strings are used in tables, use data type LCHR. There are no restrictions for the length of such fields in structures.
STRING : Character sequence of variable length. In the Dictionary, you can specify a length (minimum 256 characters)
for this type. Usage in database tables is also possible. However, there are limitations and these are described in the
explanations given for the ABAP keyword STRING. String fields cannot be used in the key for tables, in indices, or in the
WHERE condition of a SELECT statement. In ABAP, the Dictionary type STRING is mapped onto the ABAP type STRING,
which is used as a reference to a memory area of variable size.
INT : 1-byte integer, value range from 0 to 255. The length is defined as 3 places for this data type.
NUM : Character string that may only contain digits. The length of a field of this type is limited to a maximum of 255
places.
Header
Global Declarations
Processing Logic
Subroutines
STEPS TO CREATE TABLE
• Click on the radio-button ‘Database 'Table' , enter the database name as 'ZXXX' to be created and click on 'CREATE‘
button. Enter the mandatory fields like 'Short Description', Delivery class as 'A', and Check Table Maintenance Check
Box. Then click on the Fields tab.
• Provide the Field name and the Data Element for LIFNR i.e ZGLIFNR which is already created. Press Enter after
entering the Data Element so that we get all the information attached to it (Data Type, Length, Description).
• Now Click on the “Technical Settings' on title tool bar. Enter the Data Class and Size Category. Save It.
• Press F3 to come back to the main screen. Save, Check, Activate the table.
• Path to maintain the Data on the Table Utilities -> Table contents -> Create Entries
• Enter the Vendors details. After entering save (Ctrl + S) or Press Save Button to update the table contents.
• Path to view the contents of the table. Utilities -> Table Contents ->Display.
• Press F8 for all the records or provide the Required Vendor Account No's and then Execute(F8).
STEPS TO CREATE STRUCTURES.
• Execute SE11 . Click on the ‘Data Type’ option on the screen. Enter the Name and click on 'Create'.
• Enter the Short text, Component(Field Name) and Component Type(Data Element).
• Save, Check, Activate After Providing all the Components and Component types .
• Open the Database Table in Change Mode, i.e. Execute SE11 and Provide the Name of the Table and Click on Change
• Select the Row i.e. where you want to JNCLUDE the Structure and then click on '+' or 'New Rows' button
• Provide .INCLUDE as Field name and Structure name as Field type. Save, Check and Activate.
• Click on the expand All Include Button to see the fields included in the Structure.
APPEND STRUCTURE :- Here as we use ‘INCLIDE' structure for custom table or user defined table, we use 'APPEND'
Structure for adding the required fields for the standard database tables.
• Open SE11 and 'Display' the table to which the structure is to be appended. Click on 'Display'.
• Click on the APPEND STRUCTURE button on the application toolbar.
• Then click on the ‘New Append Structure’ for appending the structure to the standard database table.
• Enter the structure name starting with ‘Z‘ or 'Y'. Then say 'ENTER' or click on tick button.
• Enter 'Short Text' and the required Components(Field Names),Component Type(Data Element).
• Save the Structure, 'Check it' and Active'. Then come back to the table screen by pressing F3 or the back button.
• Screen Painter: The ABAP/4 Development workbench provides special tool known as the Screen Painter to design and
maintain the screen and its elements.
• Screen Painter is a tool that allows the user to creates GUI screens for the transactions
• A Screen is also known as a DynPro (Dynamic Program).
• A Dynpro is a combination of a screen and the associated flow logic
• The Screen Painter is available in two modes. Graphical and Alphanumeric modes
• To use the screen painter enter SE51
A Screen is made up of different elements like the pushbuttons, radio buttons, checkboxes, labels etc.
Each of these elements are associated with:
• Attributes: Describe a screen. Screen attributes include things like a description, a type, and position.
• Field attributes: Describe an element. For example, a particular field accepts only character input.
• Flow logic: Describes the relationship between a screen element and its underlying application. Flow logic is a series of
instructions.
Menu Painter:
Using the Menu Painter, you can design the interface components. The Menu Painter components are as follows:
• Status: Defines the combination of menu bars, menu lists, F-key settings, and functions available to an interface. For
example, an Editor application might have two statuses: edit and view. In edit status, the cut function is available and
with the view status the cut function is unavailable.
• Menu bars: Define functions available to the user. Where the functions appear depend on the dialog. If the dialog is
modal, the functions appear at the bottom of the interface as a row of buttons. In the primary window, the functions
can appear both as a row of menus and as buttons in a tool bar.
• Menu list: Lists the items in a specific menu. For example, an edit menu might contain items like copy, cut, and replace.
• F-key settings: Define keyboard keys associated with a particular interface function.
With CALL SCREEN, the current (calling) chain is suspended, and a next screen (or screen chain) is called in. The called
screen can then return to the suspended chain with the statement LEAVE SCREEN TO SCREEN 0. Sometimes we might
want to let an user call a popup screen from the main application screen to let them enter secondary information.
After they have completed their entries, the users should be able to close the popup and return directly to the place
where they left off in the main screen. Here comes CALL SCREEN into picture. This statement lets us insert such a
sequence into the current one.
Lock objects are use in SAP to avoid the inconsistency at the time of data is being insert/change into database.
• - Read Lock (Shared Locked) : protects read access to an object. The read lock allows other transactions read access
but not write access to the locked area of the table
• - Write Lock (exclusive lock) : protects write access to an object. The write lock allows other transactions neither
read nor write access to the locked area of the table.
• - Enhanced write lock (exclusive lock without cumulating) : works like a write lock except that the enhanced write
lock also protects from further accesses from the same transaction.
You can create a lock on a object of SAP through transaction SE11 and enter any meaningful name start with EZ Example
EZTEST_LOCK.
Lock Mechanism
Following are the two main functions
accomplished with the lock mechanism −
You can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user
to open the same object in change mode.
Example: in HR when we are enter a personal number in master data maintenance screen SAP can't allow to any other
user to use same personal number for changes.
When you create a lock object System automatically create two function module.
1. ENQUEUE_<Lockobject name>. to insert the object in a queue.
2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above FM.
The tables in which data records should be locked with a lock request are defined in a lock object together with their key
fields. When tables are selected, one table (the primary table) is first selected. Further tables (secondary tables) can also
be added using foreign key relationships.
Creating Lock Objects
Step 1 − Go to transaction SE11.
Step 2 − Click ‘Lock Object’ radio button. Enter the name of lock object starting with E and click the Create button. Here we use EZLOCK12.
Step 3 − Enter the short description field and click on Tables tab.
Step 4 − Enter the table name in Name field and select the lock mode as Write Lock.
Step 5 − Click on Lock parameter tab, the following screen will appear.
Step 6 − Save and activate. Automatically 2 function modules will generate. To check function modules, we can use Go to → Lock Modules.
Step 7 − Click Lock Modules and the following screen will open.
INTERNAL TABLES
Internal Tables and Work Areas are temporary memory locations which are used to store the data of database tables at
run time and in other way we can call them as instances of database tables.
Internal tables and Work areas .
Internal Tables Work Areas
•Temporary memory locations which •Temporary memory locations which
are used to store the data of database are used to store the data of database
table. table.
•Work area is an instance of database
•Internal table is an instance of table.
database table.
•By default 8kb memory will be
allocated and it increases dynamically(
+8kb +8kb).
Internal tables can store multiple Work areas can store only one record.
records.
General Syntax : DATA : <ITAB> TYPE General Syntax: DATA : <WA> TYPE
TABLE OF <DBTABLE> . <DBTABLE> .
Internal Table declaration
DATA : <ITAB> TYPE TABLE OF <DBTABLE> .
Example :
DATA : IT_ITAB TYPE TABLE OF MARA .
Example Explanation : Here IT_ITAB is the name of Internal table and MARA is the Database table name, after
declaring, IT_ITAB will be the instance of table MARA.
• APPEND
• INSERT
• SORT
• DESCRIBE TABLE
• READ TABLE WITH KEY
• READ TABLE WITH INDEX
• LOOP....ENDLOOP.
• MODIFY
• DELETE
• DELETE ADJACENT DUPLICATES
• CLEAR, REFRESH, FREE
• APPEND LINES OF
• INSERT LINES OF
• MOVE
• COLLECT
• APPEND statement is used to append or add a record from work area to internal table, the new record will be added at
the end of the internal table.
Syntax: APPEND <WA> TO <ITAB>
• INSERT statement is used to insert or add a record from work area into internal table at the specified location
Syntax: INSERT <WA> INTO <ITAB> INDEX <index>(record position)
• SORT is used to sort a Internal table data in ascending order or descending order, by default it will sort the data in
ascending order. In addition to this we can able to sort data based on specified fields.
Syntax1: SORT <ITAB . "Default sorts data in ascending order
Syntax2 : SORT <ITAB> DESCENDING . " Sort in descending order
Syntax3 : SORT <ITAB> BY <FIELD1> <FIELD2...ASCENDING/DESCENDING ."It sorts data by specified fields
<FIELD1>, <FIELD2>..
• READ TABLE WITH INDEX is used to read a single record from an internal table into work area specified by index.
Syntax: READ TABLE <ITAB> INTO <WA> INDEX <index_no " Read a record into work area using index ( position )
• READ TABLE WITH KEY .. BINARY SEARCH is used to read a single record from an internal table into work area specified by
field name and field value .
Syntax: READ TABLE <ITAB> INTO <WA> WITH KEY <FIELD1> = <FIELD1 VALUE> <FIELD1> = <FIELD1 VALUE>BINARY
SEARCH." Read a record into work area where some field = some value
BINARY SEARCH is a search mechanism which is used to read a record from internal table into work area very fast, the
functionality of binary search it divides the into parts and searches. The internal table must be sorted in ascending
order before using binary search.
• Loop...Endloop. is also used to read data from a internal table into work area, this is used to read multiple records serially
one after one .
Syntax1: LOOP AT <ITAB> INTO <WA> .
ENDLOOP.
TRANSPORTING is a keyword which is used to specify a list of fields to be modified instead of all fields.
Syntax1: MODIFY <ITAB> FROM <WA> INDEX <INDEX NO> TRANSPORTING <FIELD1> <FIELD2>
SY-TABIX is a key word which stores the index no of currently processed record.
• DELETE is used to delete single or multiple records from an internal table from work area based on some
condition.
Syntax1: DELETE <ITAB> INDEX <INDEX NO>.
Syntax2: DELETE <ITAB> WHERE <FIELD1> = <FIELD1 VALUE> <FIELD2> = <FIELD2 VALUE>.
• DELETE ADJACENT DUPLICATES is used to delete delete duplicate records which are adjacent to each-other.Pre-
requisite for this is the internal table must be sorted in ascending order
Syntax1: DELETE ADJACENT DUPLICATED FROM <ITAB> ."adjacent duplicated will be deleted in internal
table comparing all fields
Syntax2: DELETE ADJACENT DUPLICATES FROM <ITAB> COMPARING <FIELD1> <FIELD2> . "adjacent
duplicates will be deleted comparing specified fields
• CLEAR is used to clear a value in a work area or in a variable.
Syntax clear : CLEAR <WA> "CLEAR WORK AREA OR VARIABLE
• FREE is used to clear (free) memory of an internal table or work area. We all know whenever we declare an internal table
or work area, 8kb memory will be allocated. Memory will be there.
Syntax FREE : FREE <WA> "FREE INTERNAL TABLE MEMORY
• APPEND LINES OF is used to append multiple records to an internal table from another internal table.
Syntax : APPEND LINES OF <ITAB1> FROM <index no> TO <index no2> TO <ITAB2>.
• INSERT LINES OF is used to INSERT multiple records to an internal table from another internal table at the specified
location.
Syntax : INSERT LINES OF <ITAB1> FROM <index no> TO <index no2> INTO <ITAB2> INDEX <index no>.
• COLLECT is slimier to APPEND, the difference is it (COLLECT) will check whether the work area record already exists with
the same key (only C, D, N, T), if exists it will add numerical fields (sum) to the existing record, if the work area record does
not exist it will append a new record.
Syntax: COLLECT <WA> INTO <ITAB>.
Internal tables are used for many purposes −
• They can be used to hold results of calculations that could be used later in the program.
• An internal table can also hold records and data so that this can be accessed quickly rather than having to access this data
from database tables.
• They are hugely versatile. They can be defined using any number of other defined structures.