You are on page 1of 57

ABAP Training

Day 1
Introduction to SAP
SAP R/3 General Architecture
Work Processes
Dialog Step
Introduction to ABAP
Introduction to SAPGUI

Introduction to SAP
SAP Systems Applications and Products
ABAP Advanced Business Application Programming
Modules
SD, FI, MM, PP

SAP R/3
SAP 4/HANA
Naming convention
Y* and Z*

SAP R/3 General Architecture

User
Ctx

Roll Area

Components of Work Process


Task Handler All requests are passed through task handler,
then passed to appropriate part of work process
ABAP/4 Interpreter Interprets the ABAP code
Screen Interpreter Processing the screen
Database Interpreter For communicating with database

Types of Work Processes


Dialog(D) Dialog requests
Update(V) Update data in database
Background(B) Background jobs
Spool(S) Print spool requests
Enqueue(E) Logical lock requests
Message(M) Routing the messages between
application servers
Gateway(G) Routing between SAP and other system

Dialog Step
Press Enter
Press a function key
Click on any button on the
screen
Choose
menu
Roll In &aRoll
Outitem
Roll In begins at the start
of the dialog step
In Roll In user context
and roll area are loaded
into work process
Once done with
processing all data rolled
out of work process

User Context & Roll Area


User Context
Users current settings
Users authorizations
Names of currently running program

Roll Area
Values of variables
Dynamic Memory Allocation
Current program pointer

Day 2
Client
ABAP Program Types
Data Types
Programming Constructs
Data Declaration

ABAP Program Types


Executable Programs(Report Programs)
The purpose of a report is to read data from the database and
write it out.
Only two screens (Selection and Output)

Module Pools
Function Groups
Include Programs

Data types
Numeric Types
Integer (I)
Float (F)
Packed (P)

Character Types

Char (C)
Numeric text (N)
Date (D)
Time (T)
Hexadecimal (X)

Programming Constructs
IF(expression).
....
ELSEIF(expression).
...
ENDIF.

CASE(operand).
WHEN(operand1).

[StatementBlock]
WHENOTHERS.
[StatementBlock]
ENDCASE.

DO [n times].
[Statement Block]
END DO.

WHILE (expression).
[Statement Block].
END WHILE.

Data Declaration

Day 3

PBO/PAI
Selection Screen Events
Push buttons
Function keys
Loop at Screen

PBO/PAI
PBO(Process before Output):
Event triggers before the screen will displayed in the screen.

PAI (Process after Input):


Event triggers after the user interaction.
If the user enters any values at the screen and then click any
button means the PAI Event will triggered.

Selection Screen Events


Load of Program: First event to be called before any
other ABAP code is processed.
Initialization: Event to initialize input fields of the
selection screen.
At Selection Screen: Event is called after user has input
the parameters on the selection screen, menu option is
selected or toolbar is pressed.
At Selection Screen Output: Event is triggered before
displaying the Selection Screen
At Selection Screen on help: Triggered when user
presses F1 help,

Selection Screen Events


At Selection Screen on Value request: Triggers when
user presses F4 help to get a possible set of values.
Top of Page: Used to display header list
End of Page Used to display page footer.
Start of Selection: Triggered at the time of data
selection and processing of ABAP code
End of Selection : Triggered after processing of ABAP
code is complete.

Push Buttons and Function keys

Day 4
Memory Organization
Data Dictionary
Data Elements
Domains
Conversion Exits
Check Tables/Value Tables

Tables

Data Class
Size Category
Delivery Class
Buffering
Indexes

Structures

Memory Organization
SAP Memory: Memory area to which all main sessions
within a SAPgui have access.
SET PARAMETER ID 'MEM' FIELD TEXT1.
GET PARAMETER ID 'MEM' FIELD TEXT2.

ABAP Memory: Memory area that all ABAP programs


within the same internal session.
EXPORT text TO memory id iden.
IMPORT text FROM memory id iden.

Domain and Data Element


Domain
Domain is technical
attribute of a field

Data Element
Data element is
semantic attribute of a
field
Domain is used to
Data element
define data type, field determines how field
length etc.
is displayed to the
user.
Domain can be reused Data elements can
by any number of data make use of only one
elements
domain

Conversion Exits
Conversion exits are the method by which SAP uses to
normalise the data held in the various tables.
Conversion_exit<name>_input
Conversion_exit<name>_output

Value Table and Check Table


The check table defines the foreign keys and is part of
the table definition.
The value table is part of the domain definition.

Data Class
Data class corresponds to a physical area in which all the tables
assigned to this data class are stored.
There are the following data classes:
APPL0(master data):
Data that is seldom changed.

APPL1(transaction data):
Data that is frequently changed.

APPL2(organizational data):
Customizing data that is defined when the system is installed and seldom
changed.

Customer Managed and SAP Managed

Size Category
Size category is used to define the expected space
required for the table in the database.
It can be chosen from 0 to 4 for any-table.

Delivery Class
Delivery class is used to control the transport of table data for an installation,
upgrade, or client copy and transports between customer systems.
A: Application table (master and transaction data).
C: Customer table, data is maintained by the customer only.
L: Table for storing temporary data.
G: Customer table, SAP may insert new data records, but may not overwrite or
delete existing data records.
E: System table with its own namespaces for customer entries.
S: System table, data changes have the same status as program changes.
W: System table (e.g. table of the development environment) whose data is
transported with its own transport objects (e.g. R3TR PROG, R3TR TABL, etc.).

Buffering
Single-record buffering
With this kind of buffering, only the records of a table which
are actually accessed are loaded into the buffer.

Generic buffering
In a read access to a record of a generically buffered table, all
the records whose left-justified part of the key (generic area)
corresponds are loaded into the buffer.

Full buffering
With full buffering, either the complete table or none of the
table is in the buffer. If a read access is made to a record, all
records of the table are transferred to the buffer.

Indexes
Primary Index
Theprimary indexcontains the key fields of the table and a
pointer to the non-key fields of the table.
The primary index is created automatically when the table is
created in the database.

Secondary Index
The secondary index is created by developer.
This is necessary if the table is frequently accessed in a way
that does not take advantage of the sorting of the primary
index for the access.

Structures
Logical Elements
Do not exist at Database layer

Append
Creates a new structure

Include
Imports an existing structure

Day 5
Types of tables
Views
Search Helps
Lock Objects

Types of Tables
Transparent Table : Exists with the same structure both in
dictionary as well as
data and fields.

in database exactly with the same

Pooled Table/Table Pool: A table pool corresponds to a table in

the
database
in which all
records from the pooled tables assigned
Field
Data type
Description
to
the table CHAR(10)
pool are stored.
Tabname
Name of pooled table
Varkey

CHAR (n)

Contains the entries from all key fields of the pooled table record as a
string. The maximum length for n is 110.

Dataln

INT2(5)

Length of the string in Vardata

Vardata

RAW (n)

Contains the entries from all data fields of the pooled table record as a
string. The maximum length n depends on the database system used.

Pooled Table/Table Pool

Cluster Table/Table Cluster


Cluster Table/Table Cluster: Several logical data records from
different cluster tables can be stored together in one physical
record in a table cluster.

Field

Data type

Description

CLKEY1

First key field

CLKEY2

Second key field

...

...

...

CLKEYn

nth key field

Pageno

INT2(5)

Number of the continuation record

Timestamp

CHAR(14)

Time stamps

Pagelg

INT2(5)

Length of the string in Vardata

Vardata

RAW (n)

Contains the entries from the data fields of the assigned cluster tables as a
string. The maximum length n depends on the database system used.

Cluster Table/Table Cluster

Views
Its a virtual table containing the fields from one or more tables.
Types
Database views They are implemented with an equivalent view on
the database.
Projection views Projection views are used to suppress or mask
certain fields in a table (projection), thus minimizing the number of
interfaces.
Help views They can be used as a selection method in search helps.
Maintenance view It permits you to maintain the data distributed on
several tables for one application object at one time.
Database views implement aninner join. The other view types
implement anouter join

Search Helps
Search helps are objects to assign input help (F4 Help)
to screen fields.
It displays the list of all possible input values for a
screen field using input help.
Simple and Collective Helps

Types of Search Helps


Elementary search helps: They describe a search path. The elementary
search help must define the following:
Where the data of the hit list must be read from (the selection
method)
How the exchange of values between the screen template and
selection method is implemented (the interface of the search help)
How the online input help must be defined (online behavior of the
search help).
Collective search helps Collective search helps combine several
elementary search helps. A collective search help can offer several
alternative search paths.

Lock Objects
Lock objects are use in SAP to avoid the inconsistency at the time
of data is being insert/change into database.
Types of lock objects
Read Lock(Shared Locked) - It protects read access to an
object. The read lock allows othertransactions read access but
not write access tothe locked area of the table.
Write Lock(exclusive lock) - It protects write access to an
object. The write lock allows othertransactions neither read
nor write access to the locked area of the table.
Enhanced write lock (exclusive lock without cumulating) It
works like a write lock except that the enhanced write lock
also protects from further accesses from thesame transaction.

Day 6
Open SQL

For all entries


Loops
Read Tables, Sort and Search
Select Options
Internal Tables
Types of Internal Tables
Table / Work Area and Header Lines

Joins
Bypassing Buffer

Usage best practices for FAE and


SO
Initial Check
And ignorance of Where clause

Suppressing of duplicate values while using FAE


Initial check on Select Options
IN operator in the where clause while using Select
options

Types of Internal Tables


Standard Internal Tables:These tables have a linear index and
can be accessed using the index or the key. The response time is
in linear relationship with number of table entries. These tables
are useful when user wants to address individual table entries
using the index.
Sorted Internal Tables:These tables also have an index and
the key. But, the response time is in logarithmic relationship with
number of table entries, since it uses binary search algorithm
instead of linear search. These tables are useful when user wants
the table to be sorted while additional entries have to be added.
Hashed Internal Tables:These tables have no index, but have
the key. The response time is constant irrespective of number of
table entries, since it uses a Hash algorithm. These tables are
useful when user wants to access the entries with key only.

Loops
Looping on Internal Tables
Nested Loops
Better practices to looping
Cautions to be exercised when looping (mxn)

Single Line Processing


Read Table
Sort Table
Binary Search
Performance
Nested Loops Order (mxn)
Read Table Order (n)
Binary Search Order (ln n)

Ways to Bypass Buffer


Select using JOINS
Use the aggregated functions
Select DISTINCT
ORDER BY / GROUP BY / HAVING clause
Any WHERE clause that contains a subquery or IS NULL
expression
Using keyword BYPASSING BUFFER

Day 7
Control Break Processing
Include program
Subroutines
Function Modules

Control Break Statements


Control break statements are like events inside the loop.
Types of control break statements in ABAP.
AT FIRST ENDAT:

Will trigger at the first run of the loop.

AT NEW ENDAT: Will trigger at the last run of the loop.

Control Break Statements


The below 3 events are normally used when the table is sorted.
AT END OF : It will trigger whenever there is any change in any
of the fields from
the left to that of the particular field. The
trigger point will be the at
the last occurrence of the same
value for the field.
AT NEW:
It will trigger whenever there is any change in any of
the fields from
the left to that of the particular field. The
trigger point will be the at
the first occurrence of the new
value for the field.
ON CHANGE OF: It triggers only when there is any change in the
particular field.
On change of can be used outside the

Include Program
Aninclude programis a program in which the contents
are designed to be used by another program.
It is not usually complete all by itself. Instead, other
programs use the code the include program contains by
copying the lines of code from the include program into
themselves.
The copy is performed at runtime via
theincludestatement.

Include Program
The following is the syntax for theincludestatement.
INCLUDE ipgm.
where ipgmis a typeiprogram.

Subroutines
Subroutines are procedures that we define in an ABAP program and
can be called from any program.
Subroutines are normally called internally, i.e. called from the same
program in which it is defined. But it is also possible to call a
subroutine from an external program.
A subroutine can be defined using FORM and ENDFORM statements.
FORM <subroutine name>
...
ENDFORM.

A subroutine can be called using PERFORM statement.


PERFORM <subroutine name>.

Passing parameters to Subroutine


Using, Changing
Simple, Array Types
There are three ways of passing parameters to a
Method
Description
subroutine:
By reference
By value

By value and result

Passes a pointer to the original memory


location.
Allocates a new memory location for use
within the subroutine. The memory is freed
when the subroutine ends.
Similar to pass by value, but the contents of
the new memory is copied back into the
original memory before returning.

Function Modules
Function modules have a special screen used for
defining parameters-parameters are not defined via
ABAP/4 statements.

Function modules gets created in function group which


consists of :
A main program
A topinclude
A UXXinclude

Passing Parameters to FM
Import parameters: Variables or field strings that
contain values passed into the function module from the
calling program. These values originate outside of the
function module and they are imported into it.
Export parameters:Variables or field strings that
contain values returned from the function module.
These values originate within the function module and
they are exported out of it.

Passing Parameters to FM
Changing parameters:Variables or field strings that
contain values that are passed into the function module,
changed by the code within the function module, and
then returned. These values originate outside the
function module. They are passed into it, changed, and
passed back.
Table parameters: Internal tables that are passed to the
function module, changed within it, and returned. The
internal tables must be defined in the calling program.

Day 8
Change Request
Authorization

Change Request
Customizing request
Workbench request
Checks before releasing the CR
Consistency Check
Inactive objects check

Authorization
Authorization objects are used check whether the user
is having an authorization to runa particular
transaction.
We assign authorization objects to a role with specific
ACTVT type.
AUTHORITY-CHECK is the statement used in an ABAP
Program to perform an authorization check against an
authorization object.
PFCG - ROLE MAINTENANCE
Tcode to manage roles and authorization data

You might also like