Vous êtes sur la page 1sur 87

A.V.

Krishna
+91 9704886510
krishna.saptrainer@gmail.com
ABAP Dictionary :
Domain : - describes technical properties like datatype, length , decimal places and
values, intervals, value table )
- is low level component in the hierarchy
- is also independent Repository Object
- it is used while creating Data Element
- One Domain can be used while creating multiple data elements (Reusability)
- it can't be used in tables or structures directly
- Conversion Routine is attached at Domain level
- Domain can be defined directly from ABAP Dictionary initial screen

value ranges ( like fixed

- Custom Domain Creation Steps :


go to transaction code SE11
select Domain Radiobutton
specify Domain name starting with Y or Z
click on create
specify short description
specify datatype, length and value ranges
save, check, activate
- Use Domain while creating data element as data type
Note : for Integer values sign option can be checked , As a result integer

values are displayed with sign

for Char values lower case option can be checked , As a result


lower case characters are displayed in lower case only

- Table can be created as two types


Top-down Approach :
Create table field -> crate Data Element -> Create Domain
Bottom-up Approach :
Create Domain -> Create Data Element -> Create Table Field
- Table field uses data element as data type
Date Element uses domain as datatype
- One Domain can be used while creating multiple data elements
- One Data element can be used while creating multiple table fields
- Conversion Routine converts user display format to internal and internal
format to external
Every Conversion Routine consist of two function modules
- Conversion_exit_<xxxx>_input : this function module converts user
format
- Conversion_exit_<xxxxx>_output : this function modul converts internal
Ex : KUNNR domain uses ALPHA as conversion routine
SPRAS domain uses ISOLA as conversion routine

display format to internal storage


format to external format

- Value Range
- Fixed Values : if the expected values for table field is fixed ,then we can define at domain level.Wherever this
domain is used these fixed values automatically populated as F4 help for input field. If the user chooses a value
from the F4 list, then record is valid, otherwise it is invalid.
- Intervals : if the expected values for table field contains rage of values, then we can define at domain
level.Wherever this domain is used these range of values automatically populated as F4 help for input field.If the
user enters a value from any one of the valid range then record is valid, otherwise system rejects entry (Field
Validation)
*- Where-Used List :
it is SAP provided special feature, used to findout object concern
the result is displayed as List
result is depdend on cursor position (object based)

dependent objects (or) used objects list

*- Table relationship using Foreign Key :


- Requirement :
if at all we want to display two or more than two database tables data as
have relatioship in underlying database.
Tables can be related or integrated using Foreign key.

SAP ABAP Material Soft copy

report, then the base tables must

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

- Definition :
- F.key is keyfield of other table
- F.key servers like interface between two tables
- F.key may consist of duplicate values
- Advantages :
- F.key generates F4 help
- F4 help is useful to enduser while creating current record, with the help of
- Filed Validation ( if the user enters a value from F4 list , then record is valid
system rejects entry)

other table entries.

- New Terminology :
- Check Table : is parent table (or) base table for other tables
- this table works like reference to other tables, after creating
- on successful creation of F.key check table keyfield values
automatically populated as F4 help in F.key field
- Forieng key Table : it is child table (or) dependent table on Check table
it consist of F.key field (or) Check Field
it performs implicit check against check table entries

otherwise

F.key

- Prerequisiste to create F.key :


- At least two table with Active Status
- both tables have some data
- Check table keyfield must have data element
- common filed in both tables required
- Procedere :
- open F.key table in change mode
- clikc on Entry help / Check tab
- place the cursor on F.key field
- click on F.key icon ( F.key creation dialog box opend )
- specify short text and check table
- click on generate proposal
- specify cardinality (optional)
- check and copy
- notice the status message
- notice that F.key check box is checked and notice check table name also
- save, check, activate
- notice the reason of origin of input help
Testing :
- while creating new record in F.key table notice F4 help generated by F.key
- if user chooses a value from F4 help ,then system accepts record
- As a result of F.key activity system enables Check Table button ,which is
table fields immediately.
- Additional Theory :
- F.Key can be two types :
- Generic F.key :
System always proposes all the common fields exist in both tables
System always performs check with check table entries for all fields
if Generic key check box is actvated by the system, system doesn't
( that feild treated as general)

proces
used to cross check with Check

perform check for that field

- Constant F.Key :
we can define constant value for a field
Ex :
'MANDT = 800'
- F.key field type :
- can be key field of F.key table
- can be non-key field of F.key table
- can be keyfield of text table
( Text Table is a foriegn key table which maintains text.
text is always maintained for serverl languages.
if any F.key table one of the key field consist of LANG as datatype
- Cardinality

SAP ABAP Material Soft copy

then it is called as Text Table)

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
- is also called as Multiplicity
- precisely defines the relationship between two tables
- specifies the number of dependent records for a record of check table

- Search Criteria to find out relationship between tables :


- Where-Used List
- open any table in display mode, click on entry help / check tab
observe check table list
- open any table in display mode, click on graphic icon (application tool bar)
- database views
- open any table in display mode
utilities menu -> table contents -> display ->execute
click on check table tab
- search in google ( SAP Table relationship pdf by christophor solomon )
- search in DD08L table
- Value Table :
- Note : Check table keyfield name and Foreign key table Fkey field name
technical attributes should be same.
( Data Element may be different, but domain should be same)

may be same or different , but both

- Value Table is defined at Domain level


wherever this Domain is used system proposes this value table name as check table
It is useful while creating F.key, system automatic proposes this value table name.
- Working Currecny Fields :
While working with SAP, whenever currency values are entered, it must
datatype must followed by CUKY datatype)
we have to provide ref field and ref table for CURR field

followed by currency key ( CURR

- Generating F4 help for Currency key field


open the table in change mode,
click on Entry help/check tab
place the cursor on Currency field
click on F.key icon
- system proposes TCURC as check table
- continue
- copy
- While working with SAP, whenever Quantity values are entered, it must followed by Unit of Measurement ( QUAN
datatype must followed by UNIT datatype)
we have to provide ref field name and ref table name for QUAN field

- Structure :
- is a collection of components
- component uses component type as Data Element, Structure, Table Type
- structure doesn't store data
- structure is included in another structure (or) Database Table
- One Structure can be included in many structures (or) Database Tables
(Reusability)
- We can provide search help and check table for Structure component
- We can provide Ref table and Ref field name for CURR and QUAN
datatype fields.
- it is independent Repository Object
- it is data type defined centrally in ABAP Dictionary
- whenever structure is included in table, structure components becomes
part of table field
- Structures are 3 types :
1.Flat Structure :
is collection of components, Components are created using component type
2. Nested Structure :
one of the structure component is ref to another structure
3.Deep Structure :
one of the structure component is ref to table type

SAP ABAP Material Soft copy

as Data Element

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

Note : Structure component may ref to data element, table type, structure,
may ref to existing Database Table (or) View
may ref to Global Class / Global Interface(Ref checkbox activated )
may ref to object / data ( Ref checkbox activated )
Structure can be included with .include (or) general field name also.
Append Structure :
- is used to add custom fields to standard table (or) structure
- it is implemented as Table Enhancement
- is always adds the fields at the bottom
- is not reusable ( it is applicable to only one table )
- it is special procedure, implemented based on requirement only
- Access key not required to perform table enahcnement
- Append Structure name and its field name should begin with YY or ZZ
- Difference between Include Structrure and Append Structure
Include Structure :
- is used to include fields to table or structure
- is possible at any position
- is reusable
- name begins with Y or Z
- possible for custom tables / structures
Append Structure :
- is used to add fields to table or structure
- is always added at the bottom
- is not reusable
- name begins with YY or ZZ
- possible for both custom / standard tables

- Customizing Includes :
- are called as CI_Includes
- are special includes defined by SAP for some tables
- CI_includes empty includes by default
- User can add additional custom fields to Standard Table using CI_Includes
- are reusable includes
- Ex : PA0002 consist of CI_P0002 as include
AUFK table consist of CI_AUFK as include
*---------------------------------------------------------------*
- Table Type : Global Internal Table Types can be defined in ABAP Dictionary
- are valid for all programs
- are created using structure type as line type
*------------------------------------------------------------------*
- Type Group :
- it is also called as Type-pool
- it belongs to program type 'T'
- it is a collection of Types and Constants
- it consist of elementary types, structure types, and table types
- it is 5 characters length and all components of type group must begin
underscore
- Ex : SLIS
*-------------------------------------------------------------------*
VIEW : is a collection of data from more than one related database tables
Basically View doesn't consist of data, but it contain data at runtime
it is also called as Temporary table (or) imganiry table (or) virtual table
4 types of Views are possible in SAP.
1.Database View :
2.Projection View :
3.Maintenance View :
4.Help View :
- Database View :

SAP ABAP Material Soft copy

with Type group name followed by

(dynamically)

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
- it is a collection of data from more than 1 related tables
- it implements inner join
it fetches the data from two tables based on join condition
Join condition can be defined on keyfields of both tables
- Selection conditions can be defined
- Maintenace Status : Read Only
- DB View can be buffered like Database Tables
- DB views can be used ABAP Programs ( alternative for inner join select
statement )
- Database View can be created on Single table also, then we can create entires
- Custom Database View creation steps :
Execute Tcode SE11
select View Radiobutton
specify view name begins with Y or Z
click on create
select database view and continue
specify short description
specify database tables ( MARA, MARC)
select both tables
click on relationships
system proposes relationship dialogbox
choose correct relationship , continue
click on view fields tab
select key fields from both tables
select required non key fields from both tables
save, check, active
- path to display view content :
Utilities menu -> Content
- path to view system generated Create statement :
Extras -> create statement
- path to set buffer settings
goto menu -> technical settings

*- SAP supports two types of Joins :


1.Inner Join : fetches the data from both tables based on defined join
Join condition defined on key fields exist in both tables

condition.

2.Left Outer Join : fetches all keyfields key information first and later it cross checks with right side table. i.e.,
Leftside entire loaded data is loaded into target area first and later system fetches relevant data from right side
table
- Projection View :
it is used to hide some data and inturn display other data
it is always created on single table only
it can be used in ABAP Programs
Join conditions not possible
Selection condidtions not possible
Maintenance Status : Read Only
System doesn't generate create view statement
Technical settings (buffer settings) not possible
Steps :
- go to Tcode SE11
- select view radiobutton
- specify view name begins with Y or Z
- click on create
- select projection view and continue
- specify short text
- specify BASIS Table name
- choose required fields including key fields
- save, check, activate
- Maintenance View :
it is also used to fetch data from related tables and display
Unlike other views, it also supports to maintain (insert/change/delete) data
- it implements left outer join
- condition based data retrieval is possible

SAP ABAP Material Soft copy

into several tables.

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
- Maintenance Status : read, insert, change, delete
- Working with M.view is 2 step procedure :
Step1 : View creation
Step2 : Table Maintenance Generator
Step1 :
- go to Tcode SE11
- select view radiobutton
- specify view name starting with Y or Z
- click on create
- select M.view and continue
- specify short description
- specify table name(Left side table)
- click on relationships
- select one relatship based on system proposed list
- click on view fields tab ( notice that system proposed left side table
- select right side table keyfields
- select required non key fields from both tables
- save, check, activate it

keyfields)

Step2 : Utilities menu->table maintenace generator (SE55 tcode)


specify Authorization Group (&NC&) - it is used to restrict unautorized
while maintain data
specfiy Function Group(zde_mview) - it is responsible to hold all the
the users thru this view
specify Maintenance Type as Two Step ,specify overview and single screen
number

users
changes done by

Single step uses Overview screen for read,insert,change,delete


Two step uses two screens :
Overview screen for read, change, delete
Single screen for insert
In SAP, every screen is identified by Unique screen number
Screen number valid range is 0001 to 9999
SAP Reserved screen number range is 1000 to 1010
User permited screen number range is 1 to 999 and 1011 to 9999
if standard recording routine is activated, system records all the changes under one workbench request number
- click on generate icon
- to maintain data menu path :
utilities ->contents
- SM30 : tcode is used for Table/View Maintenace
Note : whenever Database Table is created ,immediately maintain Table

Maintenance Generator

Help View :
- it is also used to fetch data from database tables and display
- it implements left outer join
- selection conditions possible
- maintain status : Read only
- it is used as a selection method while creating Elementary Search Help
- Append View is possible for Database View and Projection View
*---------------------------------------------------------------------------------*
Search Help :
Definition :
- it is also called as F4 help (or) Possible Entries (or) Possible value help (or) Input Help (or) Hit List (or) Entry Help
- F4 help provides list of possible values, which is useful to consultant / end
user
- F4 help is useful to end user to select a value from the list (or) to provide a new value
- SAP provides default search help in different ways :
1.Domain - fixed values (or) interval values will automatically populated as
2.Check Table generates F4 help
3.data type DATS generates Calender control as F4 help
4.data type TIMS generates Timer control as F4 help

SAP ABAP Material Soft copy

F4 help

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

- Explicit Search help can be defined in ABAP Dictionary


- Search help can be attached to
- table field ( Entry help/check tab)
- structure component (Entry help/check tab)
- data element(Further Chracterisitics tab ) - high priority
- selection screen field
- dialog screen field
- Search Help can be classified as two types :
1.Elementary Search Help : provides general F4 help
2.Collective Search Help : provides extended search help to field
it provides different alternative search path to user
- Elementary Search Help : generates F4 help based on Selection method
Selection method can be
- Database Table (Fields from single table)
- Database view(Fields from two tables using inner join)
- Projection view(Reduced Fields from single table)
- Help view(Fields from two tables using left outer join)
- Business Requirement : providing F4 help to employee master mobile

number field

- Prerequisites :
- Table must be active status
- Table must have some data
- Table field must have data element
- Procedure :
- goto Tcode SE11
- specify Search help name begins with Y or Z
- click on create
- select Elementary Search help name, continue
- specify selection method as Tablename(ZDE_EMPMASTER)
- specify Search help parameter as Mobileno
- check import and export checkboxes
- specify LPos as 1 and SPos as 1
- save, check, activate, test (F8)
- Search help attachment to table field
open the table in change mode,
click on Entry help/check tab
place the cursor on fieldname
click on search help button
specify search help name and continue, copy
notice the status message and Origin of Search help
While createing entry notice F4 help
- Search help can also be attached to structure component using Entry help /

check tab

- Search help can also be attached to Data Element using Further Characteristics tab
- Note : Search parameter name and field name should be same
Import parameter fetches the field data from database and lates
Export Parameters export the value (choosen by the user) from Hit
LPos specifies ( List Position) field appearing position in the Hit List
SPos specifies Search Position in the internal system generated select

in Hit List
List to Screen field
statement.

Using Modified check box ,we can modify system proposed Data Element
Search Help Exit : is used to change the standard behaviour of Search Help
it is implemented using Function Module
Using this function module , we can deviate standard
behaviour
Hot Key : consist of one character of Elementary Search Help name
it is useful to switch from other elementary search help to current
Collective Search Help )

SAP ABAP Material Soft copy

Search help ( if it is used in

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

Dialog Behaviour :
- Dialog Type :
- Display values immediately : default option, values are dispalyed as soon as
chooses F4 key
- Dialog depends on set of values : set this option, if the values are less than
500
- Dialog with Value Restriction : set this option, if the values are more than
system displays resriction dialog box ,which is useful to
Rescriction can be set by defing condition
conditions can be defined for any field using relational operator (= <> <
<= > >=)
this condition comparision is case sensitive

user

500
set further restrictions

- We can specify default value for particular field, (uncheck import)


As a Result default value displayed in the restriction dialog box
- if SDis is activated for any field, we can't specify conditions in restriction dialog box (this field is disabled)
- Collective Search Help : is a collection of more than one Elementary Search
- it provides different alternative search path for user
- At least two elementary search helps required
- Elementary Search Helps are combined under collective search help

Helps

- Steps :
- create Help View using left outer join
- create Elementary Search help using Help View
- creating Collective Search help :
- goto Tcode : SE11
- select search help radio button
- specify collective search help name begins with Y or Z
- click on create
- specify short description
- specify field names under definition tab
- specify elementary search help names under include search help tab
- select each elementary search help and click on parameter assignment
- copy
save, check, activate,test
- Assign collective search help to Data Element / Table field
- Personal Value List :
- can be created for any F4 help
- it can be created based end user requirement
- system always displays personal value list only
- Data browser Navigation :
se11 : open any table in display mode
Utilities -> table contents -> display
system displays Data browser of selection screen
- this selection screen is used to restrict output list based on user input
- Adding fields to selection screen :
settings menu -> Fields for selection
- Maximum no of Hits = Number of records to display
- width of output list is 250 by default ( can be change settings menu -> user
- displaying required columns in the output
settings menu -> format list -> choose fields
*--------------------------------------------*
Performance Factors on Database Tables :
1.Buffering :
- Every application server consist of local buffer
- Buffers resides behind application server
- Buffer is a small area, which is a part of shared memory

SAP ABAP Material Soft copy

parameters)

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
- Buffer data is volatile ( not fixed, keep on changing )
- while executing select statement, database interface looks for local buffer
content , if the required data is
already avilable in the buffer it reads from
buffer rather than database
- reading from buffer is 100 times faster than reading from databse
- Tables and DB Views can be buffered
- Using Technical settings , we can specify buffer option
- Frequently accessed and rarely updated tables are advisable for buffering
- Buffering not allowed : if this option is set, then table content is not

processed through buffer

- Buffer allowed but switched off : if this option is set, then table content is
not aware of number of records
loaded into buffer then choose this option
- Buffering switch on : if this option is set, table content is processed
buffering type (3 types)

loaded into buffer, if we are

throught buffer , we have to specify

- Fully Buffered :
if fully buffered is selected all the table content is loaded into buffer, even if

we select single record also

- Single Record Buffer :


if single record buffer is selected, only single record is loaded into buffer
select single statement fetches always single record
- Generic Area Buffered :
if it is selected we have to specify no of key fields immediately.
only Generic key matching records are loaded into buffer
Generic key can be defined by specifying key fields
Generic key is part of left justified key fields

2.Logging : - Requirement based this check box is activated by BASIS


- option is avilable under Technical settings
- if this check box is activated system records all the changes
client
- finally system generates a log file as Table History
- Tcode to view table history - SCU3
- we have to specify system profile to log all clients / paricular

3.Index :
- makes faster access of data records from database table
- speeds up the data retrieval from database table
- while activation of database table system creates primary index on all the
- Primary index is always Unique Index
Primary index name is 0
- Indexes are created permanently in the underlying database
- while executing select statement, system uses index of the database table
- Index is a copy of database table with reduced fields
- Index is always created in the sorted order
- system performs binary search while searching for match found record
- Secondary indexes are created on tables based on requirement
- path to view indexes of table
Utilities menu -> database object ->database utility -> indexes tab
- path to create secondary index :
open the table display mode -> click on Indexes tab ->
click on create
index ->
specify short description ->
specify index fileds
save, check, activate,back
*----- DATABASE Utility : SE14 tcode
- is used to perform conversion process ( activate and adjust database)
- Indexes tab displays list of all indexes
- check runtime object is possibe
- check database object is possible
- under storage parameters displays table and indexes of database
- Object log tab displays error log list
*------------------------------------------------------------------------*
LOCK OBJECT :

SAP ABAP Material Soft copy

consultants
(update,delete) done by users of

clients

keyfields

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
- is used to restrict simultanious access of table record by several users at a time.
- SAP supports row level (or) record level locks
- if one user is editing particular table entry, at that of time that entry must be locked - so that other users can't
perform other operation
- way to work with lock object
lock table entry
- perform operation ( insert, update, modify, delete ,select )
unlock table entry(release)
- if at all we want to lock particular table entry, lock object must be defined in ABAP Dictionary
- User defined lock object name begins with Ey (or) Ez
- we can lock primary table entry and dependent table entries also
- lock happens by default using lock argument as table key field
- lock modes (or) lock types classifed as 3 types :
1. Type 'E' - Exclusive Lock (Write Lock) :
if Exclusive lock set by user on table entry, that user only can
perform all operations on table entry.
other shared and execlusive locks are rejcted
it is cumulative ( can be set / released for several times allowed )
2.Type 'S' - Shared Lock (Read Lock) :
if Shared Lock is set by user on table entry, user can only view the
table entry, editing is not allowed.
other shared locks are accepted, but not Exclusive Locks
3.Type 'X' - Extensive Lock (Write Lock) :
it is Exclusive Lock, but not cumulative
Exclusive lock can be set / released by the user for several times.
but Extensive lock can only set / released by the user only one
time.
- Physical lock happens at underlying table
- Logical lock happens at application level
- Lock mechanism is handled by Enqueue Work Process
- Lock Entries are stored in Enqueue Server (or) Lock Table
- using SM12 tcode we can view lock entries
- Upon defining and activating lock object , system generates 2 function modules automatically
Enqueue_<lockobjectname> : this function module is used to set
lock
Dequeue_<lockobjectname> : this function module is used to release
lock
- Steps to Work with Lock Object :
Business Scenario : perform lock operation on zempmaster of

particular employee (0001).

Prerequisite : Table must be active status


Step1 : go to SE11
select lock object radiobutton
specify lock object name begins with Ey or Ez
click on create
specify short description
specify primary table name ( zempmaster )
specify lock mode ( E )
save, check, activate
menu path to view lock modules :
goto menu -> lock modules
notice the system generated function modules
Step2 : go to SE38
create executable program
call enqueue function module using pattern
uncomment exporting, mode, fieldname
pass key field value
save, check, activate, test
- now lock happens on table entry
Step3 : go to tcode : SM12 - to view lock entry
Step4 : peform operation using other program (update, modify,
Step5 : release lock by calling dequeue function module
in ABAP executable program.

SAP ABAP Material Soft copy

delete)

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

ABAP Programming Introduction :


ABAP/4 Features
- Advanced Business Application Programming
- it is 4th generation language
- it is High level prog language
- it is Application programming lang
- it is Structured Programming lang
- it is Procedure oriented programming lang
- it is Event driven programming lang
- it is Object oriented prog lang
- it is not case sensitive lang
Ex : WRITE
write
Write
- ABAP is develop environment , is developed using Assembly language and
- ABAP is used to develop SAP specific in-house applications

C, C++ language

- ABAP Editor Standards :


- ABAP Editor is used to develop abap programs
- is used to specify source code of ABAP
- ABAP Editor is a development tool, which is closely integrated with ABAP Development Workbench
- Tcode : SE38
- ABAP programs are executed by Workprocess Component ABAP Interpreter (or) ABAP Processor
- ABAP program is also Repository Object
- Steps to create ABAP program :
- go to tcode SE38
- specify program name begins with Y or Z
- click on create
- specify meaningful title
- specify program type as 1 Executable Program, continue
- save as local object (or) package
- specify required source code of program
- save, check, activate, test

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

- While activation of program


- runtime object gets generated
- program status becomes : Active
- program is actively avilable, it can be reusable
- it is ready to display output
- it is good practice to activate program for every change
- SE38:
ABAP Editor Initial screen -> program source code screen -> output screen
- SA38 : program execution
program -> output screen
- code can't be seen
- used by functional consultants
- ABAP program rules :
- Every ABAP program begins with REPORT (or) PROGRAM statement
Every program first line must be Report statement
- ABAP program name can be up to 40 characters
Program name may consist of alphanumeric , special symbol underscore is
- Every ABAP program must belongs to one program type
in ABAP program types are 9
1
Type 1
Executable program
2
Type M
Module pool program
3
Type I
Include program
4
Type S Subroutine Pool
5
Type F Function Pool
6
Type T Type Pool
7
Type K Class Pool
8
Type J Interface Pool
9
Type X XSLT program
-

Type
Type
Type
Type
Type

1 program are self execute , and other program types are not self
I,S,F are Modularization Techniques
T is created in ABAP Dictionary
K,J used in Object Oriented ABAP
X - XSLT program is used to convert ABAP Programs to XML and

allowed

executable

XML programs to ABAP

- Every line is called as statement


- Every statement begins with Keyword and ends with period
- Every operator and operand before and after must contain space
c = a + b.
- separators doesn't require space
- separators list
. period
: colon
/ slash
' ' single quotes
~ tilda
-> single arrow
=> double arrow
hyphen
_
underscore
- Increment Notation in ABAP :
i = i + 1.
- Comments :
- increses program redability
- are used for documentation purpose
- comment lines are ignored by ABAP interpreter
- are 3 types
- single line comment - place asterisk at first column position
- multi line comment - select multiple lines
press Ctrl + < for comment
press Ctrl + > for uncomment
- Inline comment - partial string can be commented using double quotes in
- Operators list :

SAP ABAP Material Soft copy

single line

A.V. Krishna
+91 9704886510
Operator denoted by symbol
Operator performs unique operation
Operators need not to be specified with in quotes

krishna.saptrainer@gmail.com

Arithmatic (or) Mathematical Operators : used to perform arithmatic


+
addition
subtraction
*
multiplication
/
division (general division)
DIV
division (integer division)
MOD
Modulus (provides remainder)
**
Power

operations

Logical Operators : are used to specify multiple conditions


AND
- executes by considering both conditions
OR
- executes by considering any one conidtion
NOT
- executes negitive condition
Relational Operators :are used to perform comparision
=
EQ
<> ><
NE
<
LT
<=
LE
>
GT
>=
GE
is initial
between ...and...
like

*-------------------------- keywords------------*
- are
reserved words, which are used for special purpose
- DATA : declaration keyword, which is used to declare variable, structure,
TYPES : keyword is used to define custom elementary data types, structure
CONSTANTS : keyword is used to define constant variable
PARAMETERS : keyword generates selection screen with single input field
SELECT-OPTIONS : keyword generates selection screen with lower and

internal table
types, internal table types
upper limit fields

SELECT : keyword is used to fetch data from database


WRITE : keyword displays output
*------------------------- DATA TYPES ------------*
data types describes data objects , which do not occupy memory
data types are classified as
- ABAP Dictionary DataTypes are 24, which are valid for entire ABAP
Dictionary Global definitions like Dataelement, Structure,
Tabletypes,Type Groups are valid for
complete ABAP
- ABAP Editor data types :
- also called as pre defined data types
- valid in ABAP Programs
- while processing program at runtime, predefined types converts equallent dictionary types
- Local data types :
- can be defined using TYPES keyword, with in the program
- scope is local, valid with in the program
ABAP Editor Data Types - classfication :
- Elementary data types
- Fixed length data types
- Numeric data types
IInteger
F Float
P Packed decimal
- Character data types
C
Character
N Numeric character
D Date
T Time

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
- X - Hexadecimal ( used in SAP Graphics )
- Variable length data types
- Strings ( character sequence)
- Xstrings (byte sequence) - are used in bitwise operations
- Complex data types
- Structure type - Structure
- Table type - Internal Table
- Reference data types
- Data Ref - using LIKE
- Object ref - using TYPE REF TO
- classes
- interfaces
- Data Objects : are instances of data types, which occupy memory.
- are 7 types
1.Literals : are named data objects, used to assign value to data objects
- Numeric Literals : consist of numbers
Ex : '123'
-456
specifying single quotes are optional
- Character Literals : consist of characters
Ex : 'RAVI'
'AP11Z 4282'
specifying single quotes is mandatory
2.String : - is a collection of characters
- must be placed with single quotes
Ex :
write 'Welcome to SAP R/3'.
3.Constants : are data objects consist of fixed values
4.Interface Work Areas : Tables (or) Nodes
5.System Fields :
- also called as System Variables
- are predefined data objects
- are SYST structure components
- are specified using prefix syst-<component>.
- can be printed along with write statement
Ex :
sy-datum : displays current application server date
sy-uzeit : displays current application server time
sy-uname : displays current logon user name
sy-subrc : displays return code of operation
sy-dbcnt : displays record count , as a result of SQL operation
6.Variable : is data object which holds the value at runtime
7.Text Symbol : is a part of text pool and text element
supports to write language independent program
are used to avoid hard coded text
are used for reusable text
are displayed along with write statement
write / text-<nnn>.
<nnn> specifies the text symbol name.
*---------------------------------------------------------------------*
- ABAP supports to print 7 background color IDs
- /
prints output in new line
- /<col_pos>
prints output at specified column position
- ULINE statement prints under line
- ULINE /<col_pos(<length>).
it prints underline for specific word
- ULINE AT /col(pos).
it prints underline at specified column position
- SKIP statement provides one blank line in the output
- SKIP <n> statement provides <n> blank lines in the output
- SKIP to line <line no>. it skips <line no> in the output, this works on line
NOTE : ULINE and SKIP statements are printed individually,
can't be used along with WRITE statement

SAP ABAP Material Soft copy

count basis

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

*- variable declaration syntax -*


DATA <data object>(length) TYPE <data type>.
Ex :
DATA n1 type i.
n1 is data object (variable) declared by DATA keyword
n1 belongs to data type integer
data object : variable
- declared using syntax by DATA keyword
- created at runtime at particular memory address on RAM
- holds value assigned to (either static or dynamic)
- it always holds one value at a time
- its value can be changed ( varies)
data type :
- describes data object
- do not occupy memory
- specifies initial memory allocated to data object
- specified initial value (or) default value assigned to data object
- specifies the type of expected data
Typical structure of ABAP Program is
- declaration section
- operation section
- output section
Chain Operator - colon is chain operator
it is used to concatenate multiple statements using comma
ends with period
= is used assign value to variable
<field> = '<val>'.
Assignment is always right to left.
VALUE keyword is used to assign the value to variable while declaration
data <data obj> type <data type> VALUE '<val>'.
MOVE keyword is used to assign value to variable
MOVE '<val>' to <data obj>.
Static value assignment can be 3 types :
- VALUE keyword is used to assign value immediately
- = MOVE are used to assign values later
- Multiple variables can be declared using single statement
data : n1,
n2,
n3 type i.
default data type is char
n1 and n2 belongs to char type
n3 belongs to integer type
- we can assign common value to multiple variables using single statement
n1 = n2 = n3 = 10.
- CLEAR statement resets variable value to its initial value (or) default value
Default value depends on data type
Default value for char is space and other data types is zero
syntax :
clear <data obj>.
- Constant variables are always defined , immediate value assignement is
required.
constants variables have fixed value in the entire program
CLEAR statement is used for general data objects, not for constants
- if the variable is created using predefined type, then length specification is allowed
- if the vairable is created using Global Dictionary Type ( Data Element,
structure-component, table-field ), then specification is not allowed
As a result, data type and length copied from Dictionary

SAP ABAP Material Soft copy

and finally statements

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
- if the variable is created using custom data type , then length specification is not allowed
- syntax to define custom data type :
TYPES <custom data type> type <predefined type> length <len>.
- value addition is not possible for types
- Tcode : ABAPHELP - provides keyword documentation (F1 help)
- Tcode : ABAPDOCU - provides list of predefined example programs

- IS INITIAL : is used to check the status of data object, wheather it is empty


if <data obj> is initial.
if not <data obj> is initial.
- LIKE operator is used refering existing data object
As a result, data type and length of existing data object will copied to current

or not

data object.

Difference between Type and Like :


Type followed by data type
- data objects are created by making use of data types
Like followed by existing data object
- data objects are created with ref to data object
Exploring Data types :
- Numeric data types :
- Integer :
- accepts whole numbers with sign
- it is converting internal as Dictionary type INT4
- it occupies 4 bytes ( 11 places including sign )
- it doesn't accepts alphanumeric values
- it rounds to nearest integer value
- it doesn't accept decimal value
Note : SAP uses Unicode character set.
Unicode point of view 1 character occupies either 2 bytes (or) 4 bytes
- Float :
- accepts decimal value
- it occupies 8 bytes
- values are displayed in scientific format
- exact value display not possible
- decimals addition not possible
- <mantissa>E+01
- arithmatic operations not possible
- float values can't be accepted from user
- Packed Decimal :
- accepts decimal value
- it occupies 8 bytes
- it displays exact values
- decimals addition is possible
- default decimal notation can be set under user profile
( system menu -> user profile -> own data -> defaults tab )
- arithmatic operations are possible
- packed values can be accepted from user
- Character types :
- char : is default data type
default length is 1 place
accepts alphanumeric values
length specification is allowed
- numc : numeric character
it is special character data type , which is used to display postal
- default length is 1 place
- length specification is allowed
- it accepts only numbers
- arithmatic operations not possible

SAP ABAP Material Soft copy

codes or zip codes

A.V. Krishna
+91 9704886510
- D : is used to display date
YYYYMMDD -> DDMMYYYY
(sourcecode)
(output)
it is fixed length 8 places
default saparater .
- T : is used to display time
TIMS displays dictionary format
it is fixed length 6 places
default separater :
HHMMSS -> HHMMSS

krishna.saptrainer@gmail.com

Note : when we are accepting values from user using selection screen,
by default.
if the input is wrong system throws error message

system performs validations

- Local date and Local time is caluculated based on Time Zone


Under User profile , we can set time zones
- Text Elements are sub object of Program
Text Elements are program dependent
Text Elements are classified as
- Text Symbol : is classified as Symbol and Text
Symbol is represented as 3 characters
using symbol we can print its corresponding text
text can be up to 72 characters length
- Selection Text : is alternative long text provided for parameter field (or)
- List Heading : we can provide custom List Heading & column heading
- menu path : goto menu -> text elements -> text symbols
- from ABAP Editor initial screen : specify program name & select text
create
- double click on program text in the source code , then system automatically
- Trasnlating Text symbol
goto menu -> translation -> specify equallent german words
activate
if the login lang is En then output is English
if the login lang is DE then output displayed in German
-

- String : is a collection of characters


string values must be placed with in single quotes
Difference between Char and string data type
Char :
- fixed length data type
- static memory allocation
- length specification is allowed
- default value for char is space
String :
- variable length data type
- dynamic memory allocation
- length specification is not allowed
- default value for string is space
- String Operations :
- 1.Shift : it is used to shift the sting character by character

SAP ABAP Material Soft copy

select-options field
using this option

element radiobutton -> click on


assign text symbol

A.V. Krishna
+91 9704886510
Syntax :
shift <string> [by <n> places] [<mode>].
<n> specifies number of places to be shifted
by default 1 place of left side is shifted

krishna.saptrainer@gmail.com

<mode> values are


- left
- right
- left circular
- right circular
2.Translate : it is used to translate string into specified case
Syntax :
Translate <string> to <case>.
3.STRLEN() : function is used to calculate length of the string.
we have to capture the length into one variable ( integer type)
and display variable
Syntax :
<var> = strlen( <str1> ).
4.SERACH : is used to find a character in a string.
Syntax :
SERACH <string> for '<character>'.
sy-subrc is a system field , used to check any operation result in ABAP
if the operation is success , then subrc return as 0.
if the operation is fail, then system returns subrc value as non zero.
sy-fdpos is a system field, which displays found position of chracter in chracter
it is generally used to find the location of chacter in string.
zero.
search criteria is not case sensitive
5.REPLACE : is used to replace existing character by current character
Syntax :
REPLACE '<existing character>' in <string> with '<new character>'.
- this syntax replaces first occurence of character
REPLACE all occurrences of '<existing character>' in <string> with '<new
chracter>'.
- this syntax replaces all occurrences of existing chracter.

6.CONDENSE : it removes redundent space with in the string


Syntax :
CONDENSE <string>.
- above syntax removes many gaps with in string and
displays with one gap
condense <string> no-gaps.
- no-gaps addition removes all gaps with in the string.
7.Concatenate : is used to join multiple strings into one string
target string must have length to accomidate two strings
Syntax :
concatenate <str1> <str2> into <target string> [separated by '<character>'].

8. SPLIT : is used to devide large string into sub strings at particular delimeter
Syntax :
SPLIT <string> at '<delimeter>' into <sub string1> <sub string2>.
9.OVERLAY : is used to overwrite one string with other string.
Syntax :
OVERLAY <string1> with <string2>.

SAP ABAP Material Soft copy

sring
fdpos values begins with

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
String Comparision Operators :
CO
Contains only
CN
Contains not only
CA
Contains any
NA
Contains not any
- above operations are case sensitive
CS
NS
CP
NP

Contain String
Not contain String
Contain Pattern
Not contain Pattern
- above operations are not case sensitive

*--------------- Conditional based programming---------*


- is possible using constructs like IF and CASE
- IF syntax :
Simple IF Syntax :
IF <condition>.
-----<statement block>-----.
ENDIF.
IF <condition>.
-----<statement block>-----.
ELSE.
-----<statement block>-----.
ENDIF.
Nested IF syntax : we can check multiple conditions
IF <condition1>.
-----<statement block>-----.
ELSEIF <condition2>.
-----<statement block>-----.
ELSEIF <condition3>.
-----<statement block>-----.
ELSE.
-----<statement block>-----.
ENDIF.
- CASE construct : Syntax :
CASE <field>.
when 'val1'.
-----<st block>----.
when 'val2'.
-----<st block>----.
when 'val3'.
-----<st block>----.
------------------------.
------------------------.
when others.
------<statement>----.
ENDCASE.
-

it is also called as match found structure


it is used to compare field concern multiple values
whenever matchfound it executes statement block
this comparision is case sensitive

LOOPS : - also called as iterations (or) repititive programming


1.Do loop - uncoditional loop
2.While loop - conditional loop
3.Select...endselect loop - which is used to retrive data base table data
4.Loop...endloop - is used to read records from internal table
Do Loop :
Syntax :
Do <n> times.
--<statement block>---.
Enddo.

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
- this loop repeats for <n> times
- <n> is counter, which consit of integer value
- if <n> times addition is not specified , it repeats for infite loop
and finally terminates as runtime error
- sy-index is a system field using in loops
sy-index prints current loop index number
sy-index default value is zero, when it comes to first iteration it is incremented as 1 and next iterations its value
incremented by 1..and so on..
- Terminating Loops :
Loop can be terminated conditionally using CHECK statement
and unconditionally using CONTINUE , EXIT statement.

- While LOOP :
- conditional loop, which checks the condition first, if the condition is true it
Syntax :
While <condition>.
----<statement block>----.
Endwhile.
*- Working with Date and Time calculations -*
Standard SAP date format is : YYYYMMDD
1234 56 78
- using offset we can perform operations
date+6(2) = 'DD'.
date+4(2) = 'MM'.
date+0(4) = 'YYYY'.
Standard TIME format is : HHMMSS
12 34 56
time+4(2) = 'SS'.
time+2(2) = 'MM'.
time+0(2) = 'HH'.
- Complex data types
- Structure :
- it is collection of components
- it is complex data object, which is declared by DATA keyword
- it will create at runtime on RAM (dynamic object)
- it holds only one record at a time
- syntax to declare struture :
DATA : begin of <structure>,
<comp1> type <data type>,
<comp2> type <data type>,
--------------------------------,
-------------------------------,
end of <structure>.
- DATA keyword creates data object
begin of keyword starts structure, end of keyword ends structure
structure is created with specified components
- Syntax to address structure component
<structure>-<component>.
- we can assign value to structure to components in 3 ways :
- using VALUE keyword
- using = operator
- using MOVE keyword
- structure is also called as Field string

- Program consist 2 types of Errors


- Static Erros : are displayed while comping program (or) while checking
must be correted
are two types
- Syntax errors ( errors with respect to syntax)
- Simantic erros( typing mistakes,English kind of mistakes)

SAP ABAP Material Soft copy

repeats (Entry Checking )

A.V. Krishna

+91 9704886510
krishna.saptrainer@gmail.com
- Warnings ( can be ignored )
- Dynamic Erros
- also called as Runtime Errors
- are displayed as short dump
- while processing programming if system across typical situation then it leads to runtime error
REPORT ZDE_PROGRAM.
*-------------------------------------program for color and uline
*write / 'Welcome to SAP R/3' COLOR 1.
*uline.
*write /5 'Welcome to SAP R/3' COLOR 2.
*uline 25(18).
*uline at /5(18) .
**write /10 'Welcome to SAP R/3' COLOR 3.
**uline /10(7).
**write /15 'Welcome to SAP R/3' COLOR 4.
**uline /26(3).
*
**----------------------------------------program for write and skip statement
*write / 'Welcome to SAP R/3' COLOR 1.
*skip.
*write /5 'Welcome to SAP R/3' COLOR 2.
*skip.
*write /10 'Welcome to SAP R/3' COLOR 3.
*skip 2.
*write /15 'Welcome to SAP R/3' COLOR 4.
*skip 3.
*write /20 'Welcome to SAP R/3' COLOR 5.
**skip to line 25.
*write /25 'Welcome to SAP R/3' COLOR 6.
*write /30 'Welcome to SAP R/3' COLOR 7.
*write / 'Reddy''s Lab'.
*write : / 'cap', '$', 'gemini' .
*write sy-vline.
*write '|'.
*write '/'.
*-----------------first program(static assignment using = operator)----------------------*
*data n1 type i.
*data n2 type i.
*data res type i.
*
**n1 = 10.
**n2 = 20.
**res = n1 + n2.
*res = 10 + 20.
*
*write / n1.
*write / n2.
*write / RES.
*--------------chain operator-----------*
*data : n1 type i,
*
n2 type i,
*
res type i.
*
*n1 = 10.
*n2 = 20.
*res = n1 + n2.
*
*write : / 'N1 value is', n1,
*
/ 'N2 value is', n2,
*
/ 'Res value is',RES.
*------------Static value assignement using VALUE keyword-------------*
*data : n1 type i value 25,
*
n2 type i value 35,
*
res type i.
*
*

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
*res = n1 + n2.
*
*write : / 'N1 value is', n1,
*
/ 'N2 value is', n2,
*
/ 'Res value is',RES.

krishna.saptrainer@gmail.com

*-----------Static value assignement using MOVE keyword--------------*


*data : n1 type i,
*
n2 type i,
*
res type i.
*
*move 20 to n1.
*move 30 to n2.
*compute res = n1 + n2.
*
*write : / 'N1 value is', n1,
*
/ 'N2 value is', n2,
*
/ 'Res value is',res.
*
*data : n1 , n2, n3 .
*-----------dynamic value assignment -----*
*parameters num1 type i.
*write : 'User entered value for num1 is', num1.
*---------CLEAR statement-----*
* data n1 type i value 10.
* write / n1.
* clear n1.
* write / n1.
*-------- CONSTANTS-----*
* constants add(15) type c value 'Secunderabad'.
* write / add.
* clear add.
* write / add.
*---------------------------declaring variables using data elements -*
*data custno(4) type c.
*custno = '1234'.
*write: 'Custno is', custno.
*data v_custno type kunnr.
" declaring variable using data element
*data v_custno type KNA1-KUNNR.
" declaring variable using table field
*v_custno = '123abc'.
*write / v_custno.
*------------------------declaring variable using custom data type
*types hello(5) type c.
" defining custom data type
types hello type c length 5.
*
*data name type hello.
" declaring data object using custom data type
*data name1 type hello.
*data name2 type hello.
*data name3(10) type c.
*
*name = 'Reddy'.
*write name.
*clear name.
*uline.
*write name.
*------------------------IS INITIAL
*data n1 type i value 10.
*
**if n1 is initial.
* if not n1 is initial.
* write / 'n1 is initial'.
*else.
* write / 'n1 is not initial'.
*endif.

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

*----------------------LIKE
*data : n1 type i,
*
n2 type i,
*
n3 like n2.
*
*n1 = 10.
*n2 = 20.
*n3 = 30.
*
*write : / n1,
*
/ n2,
*
/ n3.
*data v_lifnr type lfa1-lifnr. " data obj creation by making use of table field
*data v_lifnr like lfa1-lifnr. " data obj creation with ref to existing table field
*data v_nam1 type name1_gp.
*data v_name1 like kna1-name1.
**------------------working with data types
* data : n1 type i,
*
num1 type f ,
*
number1 type p decimals 2,
*
*
name(8) type c,
*
add(6) type n,
*
date type dats,
*
time type tims.
*
* n1 = '45.47'.
* num1 = '12.34'.
* number1 = 25000.
*
* name = 'Satish01'.
* add = '-US789'.
* date = '12345678'.
* time = '160433'.
*
* write : / 'n1 value is', n1,
*
/ 'num1 value is', num1,
*
/ 'number1 value is', number1,
*
/ 'name is', name,
*
/ 'add is', add,
*
/ 'date is', date,
*
/ 'time is', time.
*------------------working with data types accepting user input
*parameters : n1 type i,
**
num1 type f ,
*
number1 type p decimals 2,
*
*
name(6) type c,
*
add type n,
*
date type d,
*
time type tims.
*
*
* write : / 'n1 value is', n1,
**
/ 'num1 value is', num1,
*
/ 'number1 value is', number1,
*
/ 'name is', name,
*
/ 'add is', add,
*
/ 'date is', date,
*
/ 'time is', time.
*---------working with system fields ------------------*
*write : / 'Current Application Server Date is', syst-datum,
*
/ 'Current Local date is', sy-datlo,
*
/ 'Current Application Server Time is', sy-uzeit,

SAP ABAP Material Soft copy

A.V. Krishna
*
/ 'Current
*
/ 'Current
*
/ 'Current
*
/ 'Current
*
/ 'Current

+91 9704886510
Local time is', sy-timlo,
User name is', sy-uname,
logon client is', sy-mandt,
operating system is', sy-opsys,
database is',sy-dbsys.

krishna.saptrainer@gmail.com

*-----------working with Text Symbols----------*


* write / 'Wipro Technologies'(001).
* write / text-002.
* write / text-003.
* write / 'Appliend Innovation'(004).
*
* uline.
* write : / text-001,
*
text-002,
*
text-003,
*
text-004,
*
text-mon.
*write / 'DesIDEA Pvt Ltd'(005).
*write / text-005.
*write / 'Good Morning'(006).
*parameters name(9) type c.
*write name.
*write : / 'Customer no' , 20 'Custoername' ,
55 'Country key'.
*&---------------------------------------------------------------------*
*& Report ZDE_PROGRAM2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZDE_PROGRAM2.
*---------------------simple IF-------------*
* parameters n1 type i.
* data n2 type i.
*
* n2 = n1 mod 2.
*
* if n2 = 0.
* write : / 'User entered Even number'.
* else.
* write : / 'User entered Odd number'.
* endif.
*------------------nested IF -------------*
* PARAMETERS marks type i.
*
* if ( marks >= 75 ) and ( marks <= 100 ).
* elseif marks >= 60 and marks < 75.
* write : / 'First division'.
* elseif marks >= 50 and marks < 60.
* write : / 'Second division'.
* elseif marks >= 35 and marks < 50.
* write : / 'Third division'.
* elseif marks >= 1 and marks < 35.
* write : / 'Fail'.
* else.
* write : / 'Enter valid range between 1 to 100'.
* endif.
*
**------------------CASE----------------*
**parameters alphabet type c.
**case alphabet.
** when 'A'.
** write / 'Vowel'.
** when 'E'.

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
** write / 'Vowel'.
** when 'I'.
** write / 'Vowel'.
** when 'O'.
** write / 'Vowel'.
** when 'U'.
** write / 'Vowel'.
** when others.
** write / 'Consonent'.
**endcase.
*
**parameters alphabet type c.
**case alphabet.
** when 'A' or 'E' or 'I' or 'O' or 'U'.
** write / 'Vowel'.
** when others.
** write / 'Consonent'.
**endcase.
*
**-----------------------------DO---------------------*
**do 5 times.
** write : / sy-index, 'Welcome'.
**enddo.
*
**do.
** write : / 'Welcome'.
**enddo.

krishna.saptrainer@gmail.com

*-------------CHECK statement is used to terminate loop conditionally---------*


*do 5 times.
* check sy-index between 2 and 3.
* write : / sy-index.
*enddo.
*
*" this loop repeats for 5 times, but whenver condition is true system priting sy-index
* value
*----------- CONTINUE statement is used to terminate loop unconditionally-------*
* do 5 times.
* if sy-index = 3.
*
continue.
* endif.
* write : / sy-index.
* enddo.
*
*" this loop repeats for 5 times, but whenever condition is true it consider
* continue statement , then it continues to further iterations
* CONTINUE statement is used to skip particular loop pass
*----------EXIT statement is used to terminate loop unconditionally ---------------*
* do 5 times.
* if sy-index = 3.
*
exit.
* endif.
* write : / sy-index.
* enddo.
*" this loop repeats for 3 times, whenever condition is true it considers EXIT statement.
* it terminates loop permanent immediately and control comes out of loop
* if EXIT is used in inner loop, then inner loop terminates immediately
DO 1 TIMES.
WRITE : / 'ERP'.
DO 1 TIMES.
WRITE : / 'SAP'.
exit .
WRITE : / 'ABAP'.
ENDDO.
WRITE : / 'test'.

SAP ABAP Material Soft copy

A.V. Krishna
ENDDO.
WRITE : / 'program'.

+91 9704886510

krishna.saptrainer@gmail.com

*----------------------------------------------------------- WHILE
*data n1 type i value 1.
* write : / 'sy-index value', 'N1 value'.
*while n1 <= 10.
* write : / sy-index, n1.
* n1 = n1 + 1.
*endwhile.
*data n1 type i value 10.
* write : / 'sy-index value', 'N1 value'.
*while n1 >= 1.
* write : / sy-index, n1.
* n1 = n1 - 1.
*endwhile.
*------------------------------DATE calculations---------------*
*data date type sy-datum value '99991122'.
*write : / date.
*uline.
**- changing date
*write : / 'Changing Date' color 3.
*date+6(2) = '01'.
*write / date.
*
*uline.
**- changing month
*write : / 'Changing Month' color 4.
*date+4(2) = '04'.
*write / date.
*
*uline.
**- changing year
*write : / 'Changing Year' color 5.
*date+0(4) = '2013'.
*write / date.
*
*
*uline.
*data date1 type dats.
*date1 = sy-datum.
*write : / date1.
*skip.
*date1 = date1 - 1.
*write : / date1.
*parameters date2 type dats.
*&---------------------------------------------------------------------*
*& Report ZDE_PROGRAM1
*&
*&---------------------------------------------------------------------*
*&
*& working with strings
*&---------------------------------------------------------------------*
REPORT ZDE_PROGRAM1.
*-------------------string comparisions ------------*
if 'SAP AG' CO 'SAP AG'.
* if 'SAP ag' CO 'SAP AG'.
* if 'SAP AG' CO 'SAP AG Ltd'.
* if 'SAP AG Ltd1' cn 'SAP AG Ltd'.
* if 'city' ca 'Ramoji Film city'.
* if ' ' ca 'Ramoji Film city'.
* if 'Z' ca 'Ramoji Film city'.
*if 'Welcome to SAP' cs 'come'.
* if 'SAP R/3' cp 'SAP +/3'.
* if 'SAP R/3' cp 'SAP +/+'.

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
* if 'SAP R/3' cp '*/3'.
* if 'SAP R/3' cp 'SAP */*'.
* if 'SAP R/3' cp 'SAP +++'.

krishna.saptrainer@gmail.com

write : / 'True'.
else.
write : / 'False'.
endif.

*data name1 type string.


**name1 = 'Jagan Mohan Reddy'.
*write : 'name1 value is', name1.
*parameters name2 type string.
*write name2.
*data : str1 type string,
*
str2 type string.
*
* str1 = 'HYTECH CITY'.
* str2 = 'Cyber City'.
*
*write : / str1 color 3,
*
str2 color 3.
*
*uline.
*
**----------------------------shift
**shift str1.
"default left side 1 character is shifted
**shift str1 by 2 places.
"left side 2 characters are shifted
**shift str1 by 3 places left. "left side 3 characters are shifted
**shift str1 by 3 places right. "string value moved 3 characters right
**shift str1 by 2 places left circular.
**shift str1 by 2 places right circular.
**write / str1.
*
*
**--------------------------translate
** translate str2 to lower case.
** write : / str2.
** uline.
** translate str2 to upper case.
** write : / str2.
*
*
**--------------------strlen()
** data v_length type i.
** v_length = strlen( str2 ).
** write / v_length.
*
**-------------------- SEARCH
** search str1 for 'city'.
** search str1 for '.T.'.
** if sy-subrc = 0.
**
write : / 'Character Found', sy-fdpos.
** else.
**
write : / 'Chracter not found',sy-fdpos.
** endif.
*
**data string type string.
**string = 'Welcome to Hyderabad'.
**search string for 'z'.
** if sy-subrc = 0.
** write : / 'Character found', sy-fdpos.
** else.
** write : / 'Character not found', sy-fdpos.

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
** endif.
*
**---------------- REPLACE
** replace 'Y' in str1 with 'A'.
** write / str1.
** replace all OCCURRENCES OF 'Y' in str1 with 'A'.
** write / str1.
*
**----------------CONDENSE
** data string1 type string value 'Des
IDEA Pvt ltd'.
** write / string1.
** skip.
** condense string1.
** write / string1.
** skip.
** condense string1 no-gaps.
** write / string1.
*
**----------------------------------------------------------CONCATENATE
** data str3 type string.
*** concatenate str1 str2 into str3.
** concatenate str1 str2 into str3 separated by '*'.
** write : / str3.
*
**--------------------------------------------------------SPLIT
** data : var1 type string value 'ABCD,EFG',
**
var2 type string,
**
var3 type string.
**
** write / var1.
** uline.
** split var1 at ',' into var2 var3.
** write : / var2,
**
/ var3.
*
**-------------------------------------------------OVERLAY
data : name1 type string value 'ABCDEFG',
name2 type string value 'a c e g'.
overlay name2 with name1.
*overlay name2 with name1 ONLY ''.
write : / name1,
/ name2.
*&---------------------------------------------------------------------*
*& Report ZDE_PROGRAM3
*&
*&---------------------------------------------------------------------*
*&
*& working with structures
*&---------------------------------------------------------------------*
REPORT ZDE_PROGRAM3.
*--- declaring structure
data : begin of emp,
no type i value 15,
name(5) type c value 'Kiran',
add(10) type c value 'UK',
doj type dats value '20130215',
end of emp.
*---- assigning value to structure
emp-no = 10.
emp-name = 'Ravi'.
emp-add = 'USA'.
move 20 to emp-no.
move 'Reddy' to emp-name.
move 'India' to emp-add.
*--- display structure content

SAP ABAP Material Soft copy

A.V. Krishna
write : / emp-no,
emp-name,
emp-add,
emp-doj.

+91 9704886510

krishna.saptrainer@gmail.com

Complex Data Types :


Table types -> Internal Tables
(Datatype)
(Data Object)
Internal Tables :
- are intermediate tables which are created at Application layer
- are temporary tables which are created on RAM
- are data objects , which are declared by syntax and DATA keyword
- are runtime objects, which are created at particular memory address on RAM
while executing program
- are dynamic data objects, which holds multiple records at a time
- are extension to structures, which holds records row by row
- it is also table, which is collection of rows(records) and
columns(field names)
- are used to perform open SQL operations on Database Tables
SELECT statement fetches the data and populates into internal table
INSERT / UPDATE / DELETE operations also possible
- Working with internal tables is 3 step procedure :
1.declare internal table
2.populate internal table
3.display output using internal table ( operations on internal tables )
- Direct interaction with Database tables is not advisable, thatswhy SAP introduced internal tables
- based on Syntaxes internal tables can be classified as
- Internal Table with header line
- Internal Table without header line
Internal Table with Header line :
- it consist of two components
- Header line: is implicit work area, which holds only one record
Always Header line holds last operation record
operations can be performed on body using Header line
- Body : is storage area, which stores many records at a time
it maintains records as row by row (without overwritting)
Note : - Header line created by default
- Header line and body consist of same structure and memory address and names
- if the internal table name is itab, then header line name and body name is itab
- header line can be addressed by internal table name directly
- inorder to address body we have to use body operator
itab[]

Internal Table without Header line :


- it also consist of two components :
- Explicit Work area : it is created explicitly using syntax
it holds only one record at a time
it always holds last operation record
it is used to perform operations on body
- Body area : is storage area, which stores many records at a time.
it maintains records as line by line
Note : Workarea and body area structure is same, but memory
- we can address work area and body area with its name

address and names are different


directly

Difference between with and with out header line syntaxs :


- with header line :
- old syntax
- ooabap program doesn't support this syntax
- nested internal tables not possible
- occurs 0
- like
- with out header line :
- new syntax

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
- ooabap program support this syntax
- nested internal tables are possible
- initial size 0
- type

krishna.saptrainer@gmail.com

- Internal tables classification ( new terminology used in internal tables )


- 1.Table Types are two types ( Table type specifies type of internal
- Index
- Standard Index internal tables
- Sorted Index internal tables
- Hashed internal tables
- 2.Key Type : can be Unique (or) Non-Unique
specifies weather system uses key field of database

tables)

table (or) non-key field of database table

if system uses Keyfield of Database table(UNIQUE Key),


delayed., but no duplicate
records exist
if system uses non key field of Database table(non-unique
but duplicate
records expected

then internal table is populated

key) , then internal table is populated fast,

- 3.Line Type : specifies the internal table created on which data type
internal table is created using line type
the components specified in the line type becomes

internal table columns.

- 4.Row Type : specifies the structure of internal table body


- Working with Ineternal Table with Header line :
- creation
- population
- operations
- creation of internal table with header line syntax :
- Internal table creation with required Database table fields
Syntax :
DATA : begin of <internal table> occurs <m>,
<field1> like <DB table>-<f1>,
<field2> like <DB table>-<f2>,
------------------------------------,
------------------------------------,
end of <internal table>.
Data keyword creates data object as internal table
begin of keyword creates header line
occurs keyword creates body with the same structure
<m> specifies memory parameter
if <m> value is zero, initial 8kb memory allocated to internal table
once 8Kb is filled system allocates 12 kb
if 12kb also filled system allocates another 12 kb and so
on..
Maximum internal table can hold 2GB data.
we can specify non-zero value also.
if it is occurs 4, then system allocates by default memory to hold 4
entries and next time system allocates
memory to hold another 4
entries and so on..
Ex :
DATA : begin of itab occurs 0,
kunnr like kna1-kunnr,
land1 like kna1-land1,
name1 like kna1-name1,
end of itab.
DATA : begin of itab1 occurs 0,
no type i,
name(15) type c,
add(15) type c,
doj type d,
end of itab1.

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
- internal table creation using two table fields
Base Tables must have relationship
Syntax :
DATA : begin of <i table> occurs <m>,
<f1> like <DB table1>-<f1>,
<f2> like <DB table1>-<f2>,
<f3> like <DB table2>-<f1>,
<f4> like <DB table2>-<f2>,
end of <i table>.

krishna.saptrainer@gmail.com

Ex :
DATA : begin of itab occurs 0,
kunnr like kna1-kunnr,
land1 like kna1-land1,
bukrs like knb1-bukrs,
erdat like knb1-erdat,
end of itab.
- internal table creation with ref to entire database table
Syntax :
data <i. table> like <DB table> occurs <m> with header line.
with header line addition creates header line
Ex :
data itab like kna1 occurs 0 with header line.
*--------------------------------------------------------------------------------------*
Standard Index internal table :
- records are mainted in the standard index
- operations can be performed using index
- system uses linear search (or) sequential search to find a record
- always uses non-unique key field of database table
- default and mostly used internal tables
- response time is propotional to the number of entries
- Syntax :
data itab type standard table of kna1 with non-unique key land1 initial size 0 with header line.
Sorted Index internal table :
- records are mainted in the sorted index
- operations can be performed using index
- system uses binary search to find a record
- uses either unique key (or) non-unique key field of database table
- are used if the internal table to be created in sorted order
- response time is propotional to the number of entries
- Restrictions : sort operation is not possible
- Syntax :
data itab type sorted table of kna1 with non-unique key land1 initial size 0 with header line.
Hased internal table :
- records are not maintained using index ( only key )
- operations are possible using only Hashed key
- system uses Hash Algorithem to find a record
- always uses Unique key field of database table
- are used to store large amount of data
- response time is constant regardless of number of entries
- Restrictions : index based operations not possible
- Syntax :
data itab type hashed table of kna1 with unique key kunnr initial size 0 with header line.
- operations on internal table :
1.select
2.append
3.insert
- to fill (or) populate internal table
4.read
5.loop..endloop
- to read records from internal table

SAP ABAP Material Soft copy

A.V. Krishna
6.modify
7.collect
8.sort
9.delete
10.clear
11.clear[]
12.refresh
13.free

+91 9704886510

krishna.saptrainer@gmail.com

- special operations

- to delete internal table and its content

*-------------------------------------------------------*
SELECT statement is used to fetch (or) retrieve data from database table and populate into target internal table
using SY-SUBRC system field , we can check SELECT statement result immediately
if the SELECT operation is success then sy-subrc value is zero, otherwise 4.
*-----LOOP...Endloop :
- it is a loop used to read multiple records from internal table body
- it reads record by record from body to header line
- Syntax :
LOOP at <body> into <header line>.
"this loop reads all the
records in the body
LOOP at <body> into <header line> from <index> to <index>. "this loop reads records
index based
Loop at <body> into <header line> where <condition>.
" this loop only reads all
conditiona matching records
----<write statement>-----.
Endloop.
*-----------append operation :
- it is used to add additional records at the bottom of internal table
- records are always added at the last (without interrupting existing
- it adds the record from header to body
- Syntax :
APPEND <header line> to <body>.
*-----------insert operation
- it is used to insert particular record at any index
- record gets inserted at the specified index position (it interrupts the
- this operation also happens from header to body
- Syntax :
INSERT <header line> INTO <body> INDEX <index no>.
Note : Insert must followed by Index number, otherwise it leads to

entires)

index of existing entries)

runtime error

*------------READ operation-----------*
it is used to read single record from internal table body.
it is good practice to check read statement result using subrc statement
- Syntax :
READ TABLE <body> into <header line> INDEX <index no>.
this syntax is used to read a record based on index
- Syntax :
READ TABLE <body> into <header line> with key <condition>.
this syntax reads first occurance of condition matching entry.
condition comparision is case sensitive
- Syntax :
SORT <body> by <field>.
READ Table <body> into <header line> with key <condition> binary
search.
Read statement supports binary search addition
Binary search finds the record quickly
Inorder to use Binary Search addition, table must be sorted first.
- SORT statement is used to sort internal table entries in the specified sorted order
Syntax :

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
SORT <body>.
SORT <body> by <f> <mode>.
SORT <body> by <f1> <f2> <mode>.

krishna.saptrainer@gmail.com

Sort operation happens directly on internal table body


Sort always by specifing the fieldname
<mode> specifies sorted mode ie., Ascending / Descending
default mode is Ascending
- MODIFY statement is used to modify existing record by current

record

syntax : index based modification


MODIFY <body> from <headerline> index <indexno>.
this syntax replaces index record by header line record
syntax : transporting addition
MODIFY <body> from <header line> TRANSPORTING <f1> <f2>
where <condition>.
this syntax replaces current values for all condition matching
records.
- DELETE : statement is used to remove records from internal table
this operation happens directly on internal table body

body

syntax :
DELETE <body> index <indexno>.
this syntax delete specified index record
syntax :
DELETE <body> from <index> to <index>.
this syntax deletes index matching records
syntax :
DELETE <body> where <condition>.
this syntax delete condition matching records
syntax :
sort <body> by <field>.
DELETE adjacent duplicates from <body>.
this syntax delete duplicate records from the internal table body
Inorder to use this syntax sort internal table first
- COLLECT : statement compares current record with existing record, if system finds any duplicate record ( data
type C must match ), then it removes all duplicate records and also sums up non key field concern ( data type
I,F,P,CURR ) values .
it is useful to elimate duplicates while summing up numeric values.
if system doesn't find duplicate record , it performs append operation
Syntax :
COLLECT <header line> into <body>.
- CLEAR : statement reset record to intial value
Syntax :
CLEAR <header line>.
it is always good practice to clear header line
- CLEAR [] : removes internal table body content
Syntax :
CLEAR <body>[].
- REFRESH : statement removes internal table body content, but
Syntax :
REFRESH <body>.
- FREE : statement removes internal table body content and
Syntax :
FREE <body>.

allocated memory retains

allocated memory also.

Note : REFRESH and FREE statements works on internal table body

SAP ABAP Material Soft copy

only

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
*- creating internal table with ref to existing internal table -*
syntax :
data <new itab> like <existing itab> occurs <m> with header line.
*- moving existing internal table content to new internal table -*
move <source itab>[] to <target itab>[].
<target itab>[] = <source itab>[].
*- Appending multiple records from one internal table to another
internal table -*
Syntax :
Append lines of <exisiting itab> from <index> to <index> to <target
itab>.
*- Inserting multiple records from one internal table to another internal table -*
Syntax :
Insert lines of <existing itab> from <index> to <index> into <targe itab> index <index no>.

*- cheking itab status using is initial -*


if not <internal table>[] is initial.
<st>.
else.
<st>.
endif.

*- DESCRIBE table statement describes internal table attributes


using system fields we can provide internal table attributes
*- Describe table new syntax :
DESCRIBE TABLE <internal table> lines <parameter>
occurs <parameter>
kind <parameter>.
lines parameter specifies total number of records in internal table
occurs parameter specifies initial memory allocated to internal table
kind parameter specifies type of internal table
T for Standard Index internal table
S for Sorted Index internal table
H for Hashed internal table
*---------------------------------------------------------------------------------*
Working with Internal Table without Header line :
- creation syntaxes :
- Internal Table creation with required fields :
step1 : create line type using TYPES keyword
step2 : create internal table and work area using DATA keyword
types : begin of <st_type>,
<comp1> type <DB table>-<f1>,
<comp2> type <DB table>-<f2>,
---------------------------------------,
---------------------------------------,
end of <st_type>.
*

data : <itab> type table of <st_type>,


<wa> type <st_type>.
<wa> like line of <itab>.
in the above syntax, we have to create a strucutre type(components)
declare internal table and work area using structure type
here structure type is called as line type

*- Syntax : Internal table creation with complete database table


types <table type> type table of <DB Table>.

SAP ABAP Material Soft copy

using required database table fields

A.V. Krishna
+91 9704886510
data : <itab> type <table type>,
<wa> type <DB Table>.
*
<wa> like line of <itab>.

krishna.saptrainer@gmail.com

TAW10_1 - ABAP Workbench Fundamentals


(programming)
TAW10_2 - Data Dictionary
TAW10_3 - Dialog Prog
TAW12_1 - OOABAP
TAW12_2 - Enhancements & Modifications
*-------------------------------------------------------------------*
TAW10_1 - ABAP Workbench Fundamentals
(programming)
TAW10_2 - Data Dictionary and Dialog Prog
TAW11
- Unicode, Data types, open SQL, Update techniques
TAW12_1 - OOABAP
TAW12_2 - Enhancements & Modifications
Web Dynpro
- creation of internal table with header line syntax :
*---------------------------------------------------------------------------------*
Working with Internal Table without Header line :
- creation syntax :
- Internal Table creation with required fields :
step1 : create line type using TYPES keyword
step2 : create internal table and work area using DATA keyword
types : begin of <st_type>,
<comp1> type <DB table>-<f1>,
<comp2> type <DB table>-<f2>,
---------------------------------------,
---------------------------------------,
end of <st_type>.
*

data : <itab> type table of <st_type>,


<wa> type <st_type>.
<wa> like line of <itab>.
in the above syntax, we have to create a strucutre type(components)
declare internal table and work area using structure type
here structure type is called as line type

*- Syntax : Internal table creation with complete database table


types <table type> type table of <DB Table>.
data : <itab> type <table type>,
<wa> type <DB Table>.

SAP ABAP Material Soft copy

using required database table fields

A.V. Krishna
+91 9704886510
*
<wa> like line of <itab>.

krishna.saptrainer@gmail.com

*--------------------------------------------------------------------------------------*
- operations on internal table :
1.select
2.append
3.insert
- to fill (or) populate internal table
4.read
5.loop..endloop
- to read records from internal table
6.modify
7.collect
8.sort
9.delete
10.clear
11.refresh
12.free

- special operations

- to delete internal table and its content

*-----LOOP...Endloop :
- it is a loop used to read multiple records from internal table body
- it reads record by record from body to work area
- Syntax :
LOOP at <body> into <work area>. "this loop reads all the
records in the body
LOOP at <body> into <work area> from <index> to <index>. "this
based
Loop at <body> into <work area> where <condition>.
" this
matching records
----<write statement>-----.
Endloop.

loop reads records index


loop only reads all conditions

*-----------append operation :
- it is used to add additional records at the bottom of internal table
- records are always added at the last (without interrupting existing
- it adds the record from work area to body
- Syntax :
APPEND <work area> to <body>.
*-----------insert operation
- it is used to insert particular record at any index
- record gets inserted at the specified index position (it interrupts the
- this operation also happens from work area to internal table
- Syntax :
INSERT <work area> INTO <internal table> INDEX <index no>.

entires)

index of existing entries)

Note : Insert must followed by Index number, otherwise it leads to

runtime error

*------------READ operation-----------*
it is used to read single record from internal table body.
it is good practice to check read statement result using sy-subrc

statement

- Syntax :
READ TABLE <itab> into <work area> INDEX <index no>.
this syntax is used to read a record based on index
- Syntax :
READ TABLE <itab> into <work area> with key <condition>.
this syntax reads first occurance of condition matching entry.
condition comparision is case sensitive
- Syntax :
SORT <body> by <field>.

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
READ Table <itab> into <work area> with key <condition> binary
search.
Read statement supports binary search addition
Binary search finds the record quickly
Inorder to use Binary Search addition, table must be sorted first.
- SORT statement is used to sort internal table entries in the specified sorted order
Syntax :
SORT <itab>.
SORT <itab> by <f> <mode>.
SORT <itab> by <f1> <f2> <mode>.
Sort operation happens directly on internal table body
Sort always by specifing the fieldname
<mode> specifies sorted mode ie., Ascending / Descending
default mode is Ascending
- MODIFY statement is used to modify existing record by current

record

syntax : index based modification


MODIFY <itab> from <work area> index <indexno>.
this syntax replaces index record by work area record
syntax : transporting addition
MODIFY <itab> from <work area> TRANSPORTING <f1> <f2>
where <condition>.
this syntax replaces current values for all condition matching
records.
- DELETE : statement is used to remove records from internal table
this operation happens directly on internal table body

body

syntax :
DELETE <body> index <indexno>.
this syntax delete specified index record
syntax :
DELETE <body> from <index> to <index>.
this syntax deletes index matching records
syntax :
DELETE <body> where <condition>.
this syntax delete condition matching records
syntax :
sort <body> by <field>.
DELETE adjacent duplicates from <body>.
this syntax delete duplicate records from the internal table body
Inorder to use this syntax sort internal table first
- COLLECT : statement compares current record with existing record, if system finds any duplicate record ( data
type C must match ), then it removes all duplicate records and also sums up non key field concern ( data type
I,F,P,CURR ) values .
it is useful to elimate duplicates while summing up numeric values.
if system doesn't find duplicate record , it performs append operation
Syntax :
COLLECT <work area> into <itab>.
- CLEAR : statement reset record to intial value
Syntax :
CLEAR <work area>.
it is always good practice to clear work area content
- CLEAR <itab> : removes internal table body content
Syntax :
CLEAR <itab>.
- REFRESH : statement removes internal table body content, but

allocated memory retains

SAP ABAP Material Soft copy

A.V. Krishna
Syntax :
REFRESH <itab>.

+91 9704886510

krishna.saptrainer@gmail.com

- FREE : statement removes internal table body content and


Syntax :
FREE <itab>.

allocated memory also.

Note : REFRESH and FREE statements works on internal table body

only

*- creating internal table with ref to existing internal table -*


syntax :
data : <new itab> like <existing itab>,
<new wa> like <existing wa>.
*- moving existing internal table content to new internal table -*
move <source itab> to <target itab>.
<target itab> = <source itab>.
*- Appending multiple records from one internal table to another
internal table -*
Syntax :
Append lines of <exisiting itab> from <index> to <index> to <target
itab>.
*- Inserting multiple records from one internal table to another internal table -*
Syntax :
Insert lines of <existing itab> from <index> to <index> into <targe itab> index <index no>.

*- cheking itab status using is initial -*


if not <internal table> is initial.
<st>.
else.
<st>.
endif.

*- DESCRIBE table statement describes internal table attributes


using system fields we can provide internal table attributes
*- Describe table new syntax :
DESCRIBE TABLE <internal table> lines <parameter>
occurs <parameter>
kind <parameter>.
lines parameter specifies total number of records in internal table
occurs parameter specifies initial memory allocated to internal table
kind parameter specifies type of internal table
T for Standard Index internal table
S for Sorted Index internal table
H for Hashed internal table
*-----------------------------------------------------------*
Difference between Views and Internal Tables :
Views :
- is dictionary object
- is created using navigation in ABAP Dictionary
- is permanent object in Underlying database as Repository Object
Internal Tables :
- is program object
- is declared using syntax in ABAP Program
- is temporary dynamic object which will be created at runtime

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

TAW10_1 - ABAP Workbench Fundamentals


(programming)
TAW10_2 - Data Dictionary
TAW10_3 - Dialog Prog
TAW12_1 - OOABAP
TAW12_2 - Enhancements & Modifications
*-------------------------------------------------------------------*
TAW10_1 - ABAP Workbench Fundamentals
(programming)
TAW10_2 - Data Dictionary and Dialog Prog
TAW11
- Unicode, Data types, open SQL, Update techniques
TAW12_1 - OOABAP
TAW12_2 - Enhancements & Modifications
Web Dynpro

data : itab type standard table of kna1 with non-unique key land1 initial
wa type kna1.

size 0,

data : itab type sorted table of kna1 with non-unique key land1 initial
wa type kna1.

size 0,

data : itab type hashed table of kna1 with unique key kunnr initial size
wa type kna1.
Syntax :
data : <internal table> type [<tabletype>] table of <linetype> [with
<work area> type <line type>.

0,

<keytype> <f>] [initial size <m>],

Simplified syntax for Standard index internal table :


data : <internal table> type table of <line type>,
<work area> type <line type>.

TABLE TYPE :
- specifies classfication of internal table
- can be Standard Index, Sorted Index, and Hased
- can be defined as local (or) global
- local table types are defined by TYPES keyword (datatype)
local table types are defined with in the program and used with in
local table types scope is local
local table types are used while creating data object , internal table
- global table types are created by navigation in ABAP Dictionary
global table types are defined centrally in DDIC and it is valid for all
global table types scope is global
global table types are used while creating data object, internal table
- Data types
Data Objects
- elementary data types -> variables
- structure types
-> structure
- table type
-> internal table
are defined by TYPES
are declared by DATA keyword
keyword
no memory allocated

memory allocated immediately

data type are used


data objects are created using
while creating data objects
-> dictionary types
-> predefined types
-> local types

SAP ABAP Material Soft copy

the program

programs

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

*--------------------------------------------------------------------------------------*
Type Group :
- is also called as Type Pool
- belongs to program type 'T'
- is a collection of Types and Constants
- is also Repository Object
- User defined Type Group name begins with Y or Z
- Type group name can be maximum 5 characters
- All the Type group components name should begin with 'Type group name_'
- Type Group defined and activated as global in ABAP Dictionary
which is valid to use in any program (or) global class
- Inorder to use global type group in ABAP Program, we have to introduce type grop name in the declaration
section using syntax :
Type-pools <Type group>.
- we can create data objects(variables, structure, internal tables) in the program using Type group components
- Steps to create Type group
- go to SE11
- select Type group radiobutton
- specify type group name begins with Y or Z
- click on create
- specify short description
- save as local object ( editor appears )
- define required elementary data types, structures types, table types
and constants
- save, check, activate

Note : Using ABAP Editor , we can create program type 1,M,I,S


Program Type 'T' can be defined in ABAP Dicationary
Program Type 'F' is defined using Function Builder
Program Type 'K' and 'J' can be defined using Class Builder

- Steps to create Global Table Type :


go to SE11
select data type radiobutton
specify table type name begins with Y or Z
click on create
specify short description
specify line type (as Data Element / Structure / Table Type )
Under initiliaztion and access tab, we can specify initial line number
and internal table type
Under key tab, we can specify key catagory and key components
save, check,activate
*----------------------------------------------------------------------------------*
Control Level Processing :
- it is also called control report (or) control break report
- Control break report is possible using control break statements
- it is used to print summarized report, ( we can print sub total or grand
total for numeric values )
- All the control break statements must be placed between loop...endloop
- sort internal table before displaying output
- Contror break statements (or) Internal table events :
1.At First.
----<statement block>.
Endat.
this statement initializes the loop
it provides header information for list
it exist only one time with in the loop
2.At New <field>.
-----<st block>----.
Endat.
it executes whenever the field value changes
it may exist multiple times with in the loop
3.At End of <field>.

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
-----<st block>-----.
Endat.
it executes end of particular field value
it may exist multiple times with in the loop
it is used to print sub total

krishna.saptrainer@gmail.com

4.At last.
-----<st block>----.
Endat.
it executes end of the report
it terminates the loop
it is used to print grand total of field
it exist only one time
5.SUM.
it is used to calculate sub total (or) grand total for numeric
it can be used for multiple times
6. on change of <field>.
-----<statement>-----.
else.
------<statement>-----.
endon.
this is alternative for at new
it also executes whenever the field value changes
Difference between At new and On Change .
At New :
- doesn't support else part
- only used in loop...endloop
On Change :
- support else part
- can be used in any loop

SAP ABAP Material Soft copy

columns

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

Note : indexes only possible for Transparent Table


Modularization Techniques :
- Modularity is a programming technique, where we devide large size program into small modules (or) blocks and
deal with modules independently.
Advantages of Modularity :
- it avoids code redundency
- it improves program redability
- it increases program reusability
M.Techniques are classified as
- Source Code Modules:
- Macros
- Includes
- Procedures:
- Subroutines
- Function Modules
- Methods (Object oriented procedure)
- Macors :
- Macro is a set of statements (or) collection of statements , which
END-OF-DEFINITION

begins with DEFINE keyword and ends with

- Syntax to define Macro


DEFINE <macro>.
----<statement block>----.
END-OF-DEFINITION.
-

Macro can be called with its name directly


nested macros are not allowed, but one macro definition may call
Macros are mostly used in ABAP-HR programming
Recursive macros are not possible

another macro.

- Macros can be defined as local (or) global


Local Macros can be defined and used with in the program
Scope is local , valid with in the program
Global Macros can be defined in TRMAC pooled table in ABAP Dictionary
Scope is global, valid for all programs
- Macro can be defined with place holders also
Maximum 9 place holders are allowed along with macro definition
(&1........&9)
place holders holds the value at runtime, which is passed by calling
place holders acts like formal parameters

statement.

- calling statement may defined along with actual parameters


calling statement passes the value to macro to perform operation
Note : the number of actual and formal parameters should be same.
- INCLUDE Program :
- Include program consist of collection of statements (or) set of
statements
- Include program belongs to program type 'I'
- Include programs are not self executable
- Include programs are used in another include program (or) another
executable program
- syntax to use include program :
INCLUDE <include prog>.
- one include program may used in many executable program
(Reusability)
- Include programs are defined as global independent Repository
Object
- nested includes not possible

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
- recursive includes not possible
- parameter passing not possible between include and calling
- Includes classification :
Include <program>top.
"global declarations
Include <program>i01.
"PAI modules
Include <program>o01.
"PBO modules
Include <program>f01.
"subroutines
Include <program>e01.
"events
Include <program>u01.
"user-exits

program

- Main advantage of include is source code reusability

- Procedures :
Procedures contain a set of statements, and are called from other ABAP programs
- Subroutine :
- is also called as routines (or) forms
- it is a set of statements, which performs unique operation
- it is a procedure, mainly used for local modularization
- Subrouitne definition begins with FORM keyword and ends with
- Syntax to define Subroutine :
FORM <subroutine>.
-----<statement block>----.
ENDFORM.
- Subroutines are called by PERFORM statement
Syntax of PERFORM statement :
PERFORM <subroutine>.

ENDFORM keyword.

- As a Rule, Perform statement must exist , before subroutine


definition.
- nested subroutines are not possible
- recursive subroutines are possible, but which leads to runtime error finally
- system executes all the statements written between form ..endform.
endform terminates subroutine.
we can terminate subroutine conditionally using CHECK statement
and unconditionally using EXIT statement.
- subroutines can be created using forward navigation also
- one subroutine definition may call another subroutine
- As a standard Approach , all the perform statements exist top of the
end of the program.
- because after subroutine definition , another subroutine definitions
not accepted
- Subroutines are two types :
1.Internal Subroutine : perform statement and subroutine definition
program.
2.External Subroutine :
subroutine definition exist in program type 'S'
perform statement exist in program type '1'.
Syntax to call External subroutine :
Perform <subroutine>(programname).

program and subroutine definitions exist


are accepted, but general statements are

both exist in ABAP Executable

Subroutine pool is a collection of many subroutine definitions


which can be called by any executable program individually.
Working with Subroutines :
- we can define subroutines using parameters
using parameter interface we can perform operations
- The parameters which are defined along with PERFORM statement is called as Actual Parameters
- The parameters which are defined along with Subroutine is called as Formal Parameters
- As a Rule, number and data type of Actual and Formal parameters should be same.
- USING and CHANGING keywords are used to define parameters
- We can perform 3 types of operations using Subroutines :
1.Pass by Reference
2.Pass by Value
3.Pass by Value and Result

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

1.Pass by Reference :
In case of pass by reference, while subroutine call formal parameters are created as a copy of actual
parameters.
Formal parameters doesn't contain special memory, but inturn they points to the address of actual parameters
Any changes done to formal parameters have immediate effect on
actual parameters
USING and CHANGING keywords acts like same.
2. Pass by Value :
In case of pass by value, while subroutine call formal parameters
are created with its own memory.
Formal parameters have separate memory.VALUE keyword creates
separate memory
Any changes done to formal parameters have effect on formal
parameters only ( no effect on actuals )
3. Pass by Value and Result :
this is also pass by value, but it is used to return the operation result

value back to calling statement.

*- Passing Internal Tables to Subroutine :


Internal Tables can be passed to subroutine as Pass by Reference
TABLES keyword is used to pass internal tables to subroutine
syntax :
perform <subroutine> tables <itab>.
*- we can define local variables with in the subroutine with DATA,

STATICS, LOCAL keyword

global variables are defined in top include of program, which are


if the local variable is defined using DATA keyword , it holds the
only.
if the local variable is defined using STATICS keyword, it
scope is global.

retains

if the local variable is defined using LOCAL keyword , its scope is


subroutine
it is used to protect changes of local variable.

valid for entire program, (scope is global)


value with in the subroutine, its scope is local

the value in the subroutine call also, its

local , it holds the value with in the

*--------------------------------------------------------------------------------------*
Function Module :
- is a procedure, which accepts (imports) values and perform operation and returns(exports) values to calling
program.
- SE37 : tcode for Function Builder
- Using Function Builder Function Groups and Function Modules are
created
- Function Builder is closely integrated with ABAP Development Workbench
- Step1 : Function Group Creation
Step2 : Function Module Creation
- Function Group :
- is also called as Function Pool (or) Function Library
- it belongs to program type 'F'
- F.Group is not self executable
- F.Group is independent Repository Object
- F.Group is a collection of similar functionality of Function Modules
- F.Group is also collection of Screens, Modules,
Includes,Subroutines...etc.,
- path to create function group :
go to tcode SE37
goto menu -> Function Group -> create group
specify function group name begins with Y or Z
specify short description
save as local object
Activating Function Group :
goto menu ->Function Group -> Display Group
notice that Function Group status is inactive
click on main program
double click on top include , activate it, back
activate functionpool program, back
now notice that Function Group is Active

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
- Function Module :
it is an independent program, which performs unique operation
F.Module also independent Repository Object
Every F.Module belongs to one Function Group
Similary Functionality of Function Modules logically grouped under
Function Group
F.Module can be created, activated, released
F.Modules are implemented as External Subroutines
F.Modules are mainly used for Global Modularization
F.Modules are created independetly under F.Group, which are valid to call and use in any program
One F.Module can be called in multiple programs (Reusablity)
Once F.Module is created and activated , it can be called in any Executable program.
- Syntax to call Function Module :
call function '<function module>'
.
- Function Modules are used to perform operations
we can perform simple and complex operations using parameter

interface.

While defining function module , we can define import, export,changing parameters and tables, exceptions also
Business Scenario1 : working with Import and Export tabs
- specify function module name begins with Y or Z
- click on create
- specify function group and short text , continue
- define import parameters under import tab
n1 type i
n2 type i
- define export parameters under export tab
res type i
- specify logic under source code tab ( between function
...endfunction)
res = n1 + n2.
- save, check, activate, test Function Module.
- Usage of Function Module in ABAP Executable Program :
- declare actual parameters
- call function module
- pass actual parameters
- display output
Note : Function Module can be defined with out interface also
if F.Module consist of Write statement, its result is displayed in

list screen.

Function Modules :
zde_fmodule - pass by ref example
zde_fmodule1 - pass by value example
zde_fmodule2 - no parameter interface (write statement)
zde_fmodule3 - working with changing tab (pass by value and result)
zde_fmodule4 - tables tab with all table fields , with select statement
zde_fmodule5 - tables tab with all table fields, without select , only
zde_fmodule6 - tables tab with required fields

- Function Module Tabwise Theory :


Attributes tab : consist of function module short description and
Based on Processing type Function Modules are 3 types :
1.Normal FM : by default all F.Modules are Normal FM.
it can be called by any program with in the server
2.Remote Function Module : are special function modules which
from any server
it supports remote capability
Syntax to call RFC FM
call function '<f module>' destination 'RFC Destination'

SAP ABAP Material Soft copy

display

fucntion group name

can be called

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
3.Update Function Module : is used to modified record to database
table, while updating it uses VB*
temporary tables
Update can be done - immediately
- delayed
- collective update
Import tab : is used to define import parameter
import parameters acts like formal parameters, which
imports(accepts) the value from calling program and
pass to
source code
import parameter name should begin with ip_
import parameter can be defined using associate type as
- predefined type
- dicationary type
- data element / structure-component / table type
- database table-field / view-field
- global class / global interface
if optional check box is checked , this parameter appears as
comment , wherever it is called
we can provide default value, short text and long text also
Export Tab : is used to declare export parameter
export parameters acts like formal parameters, which
program

exports(returns) the result value back to calling

export parameter name should begin with ep_


no default value for export parameters
Note : Import and Export tabs are used as Pass by Value by default,

but they can be used as Pass by Ref also

- Nested Function Modules are not possible, but one function module can call another function module
- Recursive Function Module leads to runtime error
- Changing Tab : is used to declare both import and export parameters
it is used for pass by value and result
- Tables Tab : is used to define internal table with in the function
Internal Tables can be defined as Formal parameters using
Internal Tables can be passed to Function Modules always as

module
Tables tab
Pass by Ref

- Exceptions Tab : is used to define exceptions with in function


these exceptions can be raised while maintaining source
- Source Code tab : consist of main functionality (or) source code logic
Code must be maintined with the help of local interface ,
we can define local types ( elementary datatypes, structure types ,
variable,structure, internal table )

modules
code logic
of function module
between function .....endfunction.
table types) and declare local data objects (

- Documentation tab provides in detail documentation of Function module parameters


*- Working with Exceptions -*
- Exceptions are used to handle runtime erros (or) dynamic errors
- While executing function modules, if any error occurs, it can be handled by Exceptions
- Working with Exceptions is 2 step procedure :
Step1 : define Exceptions in Exceptions tab
Step2 : Raise Exceptions in the source code tab under certain
conditions
- Syntax to raise exception :
RAISE <exception>.
- Exceptions are handled by Messages
Syntax to raise exception with message statement :
Message <msgtype><msgno>(msgclass) raising <exception>.
- While calling this function module in ABAP program, system inserts exceptions also.
exceptions are displayed with return code values
based on return code value, we can provide appropriate messages usgin sy-subrc condition.
- Business Scenairo :

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
Develop a FM which accpets S.org,Dist.Channel, Division ,fetches its corrsponding data from knvv database table
and display output
- Exploring Function Module :
date_to_day : it provides name of the day for the given date
spell_amount : it converts currency values into corresponding text
Amount_string_convert : it converts amount string into currency
convert_to_local_currency : it translate foreign currency amount to
convert_to_foreign_currency : it Translate local currency amount
currency
calculate_exchange_rate : Find Rate Based on Amounts, Currency

(in words)
values
local currency
into foreign
Keys and Date

- Searching for Function Modules :


- All ALV related function module names begins with REUSE_ALV_
- All BAPI related function module names begins with BAPI_
- can be searched based on
- name
- short text
- function group
- package
- application component
- All function modules are stored in TFDIR transpart table

- Difference between Subroutines and Function Modules :


Subroutines :
- are mainly used for local modularization
- doesn't support exception handling
- are created in ABAP program ( f01 includes )
- called by perform statement
Function Modules :
- are mainly used for global modularization
- supports exception handling
- are created in Funtion Builder
- called by call function statement
**************
Macros are mianly used in ABAP HR programming
Includes can be used in any program with in the server ( parameter
possible)
Subroutines mainly used for local modularization ( parameter interface
Normal FM can be called by any program with in server(parameter
possible)
Remote-Enabled FM can be called by any program any server
possible)

interface not
possible)
interface
(parameter passing

***********************************
Messages : are used to know any operation result , while working with
SAP
Messages are created under message class
Message class tcode : SE91
Message class is independent Repository Object
Message class is a collection of messages
M.Class consist of Message number and corresponding Message Text
Message Number is represented as 3 digit number
Valid Message Number range is 000 to 999
we can create 1000 messages per class
Message Text can be 73 characters length, which consist of
alphanumeric and special symbols also.
Text Symbols are program dependent, but Message class messages are created as Global independent objects,
which are valid to use in ABAP Programs, Function Modules, Forms, Screens,Global Classes and Global Interfaces
- Types of Messages :
Type I - Information Message
Type S - Success (or) Status Message
Type E - Error Message
Type W - Warning Message

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
Type A - Abort (or) Abend Message
Type X - Termination Message

krishna.saptrainer@gmail.com

- Inorder to use Message class messages in ABAP Program, we have


Report Statement.
Report <program name> message-id <message class>.

to declare message class name along with

- Messages are classified as


- Static Message :
displays fixed hard coded text
- Dynamic Message
is used to display context dependent
- creating custom message class
go to tcode : SE91
specify message class name begins with Y or Z
click on create
specify short description
specify required meaningful messages in the messages tab
save, check.
- Syntax to specify message with out message class :
message '-------<msg text>-----------' type '<msg typ>'.
- Dialog behaviour of messages :
Information Message : appers in information dialog box with special
message to user
and it will allow user to proceed further.
Status Message : is displayed in status bar of same screen with

screen.it informs with some

green

Error Message : is displayed in the status bar of special screen with


proceed further
screen.

color tick mark

red color , it doesn't allow to

Warning Message : is also displayed in the status bar of special screen with red color, it doesn't allow to proceed
futher screen.
Abort Message : is displayed as cancel dialog box with stop red color icon, it stops process, and exit the process
control
transfer to SAP Easy Access.
it restarts whole process
Termination Message : leads to runtime error
it abnormally stops processing and system
Short dump is a special screen, which displays runtime error
ST22 tcode to analyse short dump

leads to short dump

- Syntax to specify message with message class :


message <msg typ><msgno>.
Ex :
message i000.
(message class must be specified along with report statement)
- Syntax to specify message with message class
message <msg type><msgno>(msgclass).
(no need to specify message class name along with report
this is useful to display multiple message class messages

statement)

message classes can be created using forward navigation also.


- Dynamic Message :
- is mainly used for reusability
- program sends value / values to message class message
- to hold that values message is defined with place holders
- Syntax of Dynamic Message :
message <msgtyp><msgno>(messageclass) with <f1> <f2>....<fn>.

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

message statement sends field values to message class message

while executing program.

message statement filed numbers must match with message place

holders in message class

- System Messages used for Message class :


sy-msgid : name of the message class
sy-msgty : name of message type
sy-msgno : message number
sy-msgv1 : message varirable
- All the messages are stored in T100 table
- Syntax to Raise Exception with message statement
message <msgtyp><msgno>(msgcls) raising <exception>.
- ABAP Editor Theory :
pattern tab is used for insert statements like message, select,

authority check, function modules etc.,

Pretty print tab is used to set program indetation , code gets modied

as per standard

Advantages of New ABAP Editor :


- auto proposal of keywords and syntaxes
- color display
- code can be compressed
- line numbers display
- status bar options provides several options to changes like
display, font and colors, code templets, keyboard and print settings
SE80 - ABAP Development Workbench (or) Object Navigator
- it is important developement tool , used by ABAP Consultant
- operations( create, change, display ) can be performed using right
- it is closely integrated with
- Application Hierarchy
- Repository Browser
- Repository Information System
- Tag Browser
- Transport Organizer
- Test Repository
- Enterprise Service Browser
- Web Dynpro Text Browser
- Enhancement Information System

click (context menu)

- ABAP Dictionary,
Data Browser,
BAdI builder,
Function Builder,
Logical database Builder,
Class Builder,
Adobe forms builder
..etc.,
- it is used to navigate object to object ( using Edit object option )
- using one screen, we can view all pacakges concern objects,
all function group concern objects, and local objects...etc.,
- objects can be created, changed, displayed, and deleted also.
- it supports to develop BSP / Web Dynpro Applications

- Package : is a collection of objects


default package is $tmp, which holds all local objects
SAP defined objects belongs to SAP Package
User defined objects belongs to User defined Package (or) $tmp
Package also Repository Object

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
Packages can be created by BASIS consultant , using Package
Builder(SE21) (or) ABAP Development Workbench
Custom Package creation :
- go to tcode SE21
- specify package name begins with Y or Z
- click on create
- specify short description
- specify application compont and software component ( HOME )
- speciy transpor layer
- specify package type ( not a main package )
continue
system proposes local workbench request dialog box
click on create request
system opens another screen ( specify current activity concern
client)
save
continue.
Note : now on wards , we can save developed objects in Custom
Quality (or)
Production box.

short text ,project, traget

Package so that it can be transported to

Objects can be moved from one package to another pacakge


but one object belongs to one pacakge at a time

- moving object from $tmp to custom pacakge :


go to tcode SE11
specify table name avilable in $tmp package
goto menu -> object directry entry
click on pensil(change mode)
change package / username
save, continue with request.
- Create Request / Change Request (CR) :
is generated and proposed by the system
it is 2 types :
1.Workbench Request :
it is generated at ABAP level
whenever object is saved in Custom Pakcage, then system

proposes local workbench Request.

2.Customizing Request :
it is generated at Fucntional level
while configuration, whenever new data is created in SAP, then

system proposes Customizing Request.

- Request Number represented as below :


<INSTANCE>K9<nnnnn>.
Ex :
EC6K900170
EC6 is instance
K is constant
900170 is request number
which always begins with 9, having 6 digit number
Request number is useful to track / trace object status
While working in the Implementation project, objects are initially developed(save, check,activate,test,release) in
the Developement box.
ABAP consultant is responsible to test and release
Released objects are ready to transport
Transport done by
BASIS consultnats using TMS (STMS tcode)
Transport is moving one copy of object from one instance to another
instance.
W.B.Request number is useful to identify object as Unique
it is useful to aware of project status.

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

Transport Organizer : is a tool used to release objects


Tcode for Transport Organizer SE09.
whenever system proposes workbench request dialog box , consultant can perform 3 type of activity :
system proposes request number based on internal sequence
number
1.continue with system proposed request number and description
2.create request : option is used to create new request number by
3.own request : option is used to choose existing request numbers

specifying description

- As a Standard Approach , Reqeust is created and released by Lead,


Task is created and released by team member ( consultant )
Task must be released before relasing Request.
we have to release task first and finally request is released.
once the request is relased object is moved from Modifiable section to Released section.
In general modifications are allowed to object, before release
If we modify released object, then system proposes new workbench request.
Steps :
go to Tcode : SE09
click on display
place the cursor on task , click on release icon
place the cursor on request, click on relase icon
(Request menu -> release -> directly)
*---------------------------------------------------*
Version Management :
- is useful to maintain several copies of object in the version database
- Whenever object is activated system generates by default current
version at developement database
( application level )
- Requirement specific we can modify existing object
- by default version database is empty
- before modifying existing object , we can generate version in the version database.
- Advantage of Version management :
- we can retrieve old version object
- we can compare two different version objects
- Script Form and Smartforms doesn't support version management
- menu path to generate version :
Utilities menu -> versions -> generate version
- to view versions of the object :
Utilities menu -> versions -> version management
*----------------------------------------------------*

open SQL :
-

statements are sub set of standard SQL


processed through ABAP Workbench and buffer
are converted to native SQL by database interface
are database independent statements
are ABAP specific statements, mostly used commands
are SELECT, INSERT, UPDATE, MODIFY, DELETE statements
statements must follow ABAP Editor standard rules

Native SQL :
- statements are special commands written with respect to database
- statements by pass ABAP Workbench and buffer (Application layer)
- are not converted by database interface
- are database dependent statements
- are so powerful, and rarely used commands
- syntax to define native SQL statements
EXEC <SQL>.
---<native SQL>---.
Endexec.
- statements doesn't follow ABAP Editor standard rules
- SELECT statement basic syntax :
SELECT <required fields>
INTO <target area>
FROM <database table>
[ where <condition1>]

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
[ group by <field>]
[ having <condition2>
[ order by <field> <mode>].

krishna.saptrainer@gmail.com

- select...endselect loop is used to fetch the data directly from


database table
this loop hits the database number of times, which creates lot of
load on system and network traffic increses
Performance point of view hitting the database table number of
times is not advisable
thatswhy SAP advises to use internal table
- select * from <DB Table> into table <itab>.
above syntax hit the database only one time, and fetches all records
to internal table
this special operation is called as Arry Fetch operation
it always bypass work area ( with out header line )
header line ( with header line)

data from database and directly appends

- it is always good practice to check sy-subrc statment immediately after every open SQL operation
if the open SQL operation is success then system return code value 0, otherwise 4.
- sy-dbcnt system field provides count of database records
which can be used to check open SQL statment result.
- select * statement
fetches all rows and all columns from the database table
- select <f1> <f2> <f3> statement
fetches required fields from database table
specify field order as per the database table order ( sequence ) , to
addition
into corresponding fields - it fetches the data from database table
fields
( it compares source field name and target field name )

avoid using of into corresponding fields

and places into target for identical named

- where clause is to fetch condition based records


condition can be specified as <field> <relation operator> 'value'.
this comparision is case sensitive
multiple conditions can be specified using logical operators ( AND,

OR, NOT)

- order by addition to fetch the data in the specified mode


default mode is ascending
we can specify decending
- up to <n> rows addition is used to fetch records based on index of database table
<n> value must be positive integer
whenever up to <n> rows is used , specify primary key addition in order to get exact values
- distinct addition is used to fetch unique records from database
it elimates duplicate records while fetching the data
- by default system fetches the data from local login client
inorder to fetch data from other clients we have to use CLIENT SPECIFIED addition along with select statement
- Aggregate functions are used along with select statement to perform arithmatic operations
Max( <f> ) : it returns maximum field value
Min( <f> ) : it returns minimum field value
Avg( <f> ) : it returns average value of field
Sum( <f> ) : it returns sum of fieldvalue
Count( <f> ) : it returns the count number
- using select single <f> , we can fetch single field value from database table
target area must be declared as variable
- Field List :
we can fetch requried single field values from data base table entry
- in this case target area should be field list
syntax :

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
select <f1> <f2> <f3> from <DB table> into ( f1, f2, f3 ) where
<conidtion>.
if condition is not specified system fetches first record values
- select single * :
is used to fetch single record from database table
if condition is not specified it fetches first record
- if at all we want to fetch data from more than 1 database table,
we can use
- inner join
- left outer join
- inner join fetches the common data exist in both tables
it fetches data based on join condition
join condition is defined using common keyfields of both tables
- left outer join fetches entire left side table entries , irrespective of

right side table into target area.

Syntax :
select <alias>~<field1>
<alias>~<field2>
------------------------------------into table <target internal table>
from <DB table1> AS <alias>
inner join
<DB table2> AS <alias>
ON <alias>-<keyfield> = <alias>-<keyfield>.
we can use table names directly instead of using Alias
Alias is alternative name for Database Table

- Alternative for inner join select statement is, usage of Database View
- we can internal table on Database Views
- FOR ALL ENTRIES :
it is alternative for nested select statement
it is used while populating current internal table by comparing existing
internal table entries
it is special select statement, where it compares database table
entries are compared with internal table
entires.
it can't be used to fill first internal table
it is used to fill other internal tables while comparing with existing
internal table
it must followed by where condition
condition must be specified by keyfield comparision
Prerequisite : initial internal table should not be empty
check the status of initial internal table
- Working with Complex Report (or) Working with many database
Steps :
- Identify the data (fields) required by End user
- Identify the data from single database table (or) multiple tables
- Identify table relationship

tables :

- Declare required internal tables, to hold database tables data


Declare Final internal table , which is used to display final output
- Populate first internal table using normal select statement (or) inner
join select statment , by considering user
input in the
selection-screen.
- populate other internal tables using for all entries select statement
- move all the entries from first internal table to final internal table using loop statement.
- with in the loop , use read table statement to single records from other internal tables , if corresponding entries
are avilable move second internal table entries also to final internal table
- display final output using final internal table

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
*********************************************************************
INSERT open SQL statement :
- it is used to create a new record in the database table
- we can check the result using sy-subrc statement immediately
- inserting single record using work area
work area must be declared using database table.
specify new record using work area components
Use below syntax to insert record :
INSERT <Database Table> from <work area>.
Insert into <Database Table> values <work area>.
- Inserting several records in the database table
declare internal table and work area in the program
append new records to internal table
Use following syntax to insert records from internal table :
INSERT <Database Table> from table <Internal Table>.
*********************************************************************
UPDATE open SQL statement :
- it is used to update database table records
- if existing database table consist of blank values (or) incorrect values,
using UPDATE statement we can enter new values for blank records,
we can rectify incorrect values.
- MODIFY is also another open SQL statement, which also used for update purpose.
it will update if record found, otherwise it creates new record
Syntax :
UPDATE <Database table> SET <field> = 'value' where <condition>.
matching records

this syntax sets new values for condition

Syntax :
UPDATE <Database table> from <work area>.
this syntax is used to update single record
Syntax :
UPDATE <Database table> from table <internal table>.
this syntax is used to update several database records.
*********************************************************************
DELETE open SQL operation :
- is used to delete records from underlying database table
Syntax :
DELETE FROM <Database Table> WHERE <cond> .
this syntax delete condition matching records
Syntax :
DELETE <Database Table> from <work area>.
this syntax is used to delete single record from database table
Syntax :
DELETE <Database Table> from table <internal table>.
this syntax is used to delete severl records from database table
***********************************************************************
The SELECT statement bypasses the buffer when you use any of the following:
The BYPASSING BUFFER addition in the FROM clause
The DISTINCT addition in the SELECT clause
Aggregate expressions in the SELECT clause
Joins in the FROM clause
The IS NULL condition in the WHERE clause
Subqueries in the WHERE clause
The ORDER BY clause
The GROUP BY clause
The FOR UPDATE addition
*********************************************
Mathematical Functions
Function

SAP ABAP Material Soft copy

A.V. Krishna
Result

+91 9704886510

krishna.saptrainer@gmail.com

ABS
Absolute value of argument.
SIGN
Sign of argument:

1X>0
SIGN( X) = 0 if X = 0
-1 X < 0

CEIL
Smallest integer value not smaller than the argument.
FLOOR
Largest integer value not larger than the argument.
TRUNC
Integer part of argument.
FRAC
Fraction part of argument.
************************************************************************
Field-Symbol :
- are place holders for data objects
- doesn't reserve memory , but they points to existing variables
- implements dereferenced pointer concept of 'C' language
- points to the value of variable, which is assigned to it.
- Syntax to declare Field-Symbols :
Field-Symbols <FS>.
Angle brackets are part of syntax
- using ASSIGN keyword we can assign variable to Field Symbol
Syntax to assign variable to field symbol
ASSIGN var to <FS>.
then <FS> points to the value of var at runtime.
- Field Symbols are mainly used for Dynamic Memory Management
- we can assign data objects ( variables, structures, internal tables ) to field symbols.
**************************************************************************

***********************************************************************
- write is used to display output
- Syntax :
write : /<col_pos> '------<text>----------'.
- write statement supports color addition
7 color ids are possible (1...7)
- skip statement provide one blank line in the output
- uline statement provides under line the output
- sy-vline system field provide verticle line
- write statement with left-justified addition provides output as left
centered addition display output as centered
right-justified display output as right justified
- Syntax :
write : / <var> [left-justified][centered][right-justified].

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
- providing output without gap
write : / <var1> no-gap, <var2>.
it displays two variable values with out gap
no-gap addition removes explicit gap between strings
- providing output one under another
Syntax :
write : /<col_pos> <var1>,
/ <var2> under <var1>.
- no-sign addition removes sign for integer values
- no-zero removes leading zeros for character values
- no-decimal removes decimals
- printing date as per our own format using syntax :
write / <date> using edit mask '__/__/____'.
- printing time as per own own format using syntax :
write / <time> using edit mask '__/__/__'.
FORMAT color <id>.
this syntax provides specified color <id> for followed by write

statements.

FORMAT hotspot on.


this syntax provides hyperlink (hand symbol) for followed by write

statements.

FORMAT intensified on.


this syntax provides intensity to followed by write statements.
FORMAT inverse on.
this syntax applies back ground color to text color and vice versa
FORMAT input on.
this syntax generates write statement output, which can be editable in the output
- using PATTERN we can insert several write statements
we can print symbols, icons, lines,check boxes also.
specify include statement as
include <list>.
============
-

ABAP is mainly used for Reporting purpose


Report is output of executable program
Reports are displayed in List screen, thatswhy reports also called as List
Reports are to display output(data) in structured format
End Users (Managers) require Reports for different reasons :
- Reports are useful for information purpose, analysis, decision
purpose,
- Strategy to work with Reports :
- Use SAP provided Standard Reports
- Enhance Standard Report
- Modify Standard Report
- Develop Custom Report under customer namespace
- Standard Reports which are developed by SAP are avilable under Information System
- SIS - Sales Information System
- LIS - Logistics Information System
- HIS - HR Information System
- path to view Standard Reports :
SAP Easy Access -> SAP Menu -> Information Systems
- Working with Task/Object( RICEFW) in SAP :
Phase1 Activities
: Understand Business Requirement (or) Client
Analyse the flow or sequence
Design Flow Diagram (or) UML Diagram
Design pseudo code
demostrate to lead and get approval
Phase2 Activites
: Start typing source code in ABAP Editor as per Basic ABAP
save,check, activate, test(unit testing) program

SAP ABAP Material Soft copy

Requirement ( FS)

Programming standards

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

Phase3 Activities
: Check Performance Tuning
-> output must meet business requirement
-> check performance with system point of view
-> check your program against check list ( Code Review Lead)
follow coding standards, naming
creation
-> relase task/object

done by
conventions,modularity, tcode

- Types of Reports avilable in ABAP


1.Classical List (or) Classical Report
2.Interactive List (or) Interactive Report
3.ALV Report
4.LDB Report - used in ABAP HR programming
5.ABAP Query (or) SAP Query Report - used by Functional
6.Ad Hoc Query - used by SAP HR Consultant
7.Report Painter - (tcode GRR2) , used by Co consultants
8.BW Reports - Multi dimentional reports
- in ABAP Reporting is generated using Events
- ABAP is Event driven programming language
Events are triggered by System, based on user actions
Events are two types :
Implicit Events : which are triggered and processed by system
Explicit Events : which are triggered by user actions
user can perform actions on selection screen, list
screen.
Event names and Event behind respective source code is written in

Consultant

screen, dialog
the program

system (ABAP processor) gives top priority to events over general statements
Events are executed by the system on priority basis
Events are not processed as per the typed sequence
- Selection-screen events :
1.LOAD-OF-PROGRAM.
- is implicit event triggered by the system while executing program
- it loads program into context area
2.INITIALIZATION.
- it is triggered by the system , before displaying selections-screen
- using this event, we can provide default values to selection-screen fields
3.AT SELECTION-SCREEN OUTPUT.
- it is triggered by the system,after INITIALIZATION event and
before displaying selection-screen
- it provides default different attributes to selection-screen fields
4.AT SELECTION-SCREEN.
- it triggers after user interaction on selection screen
- it performs two activities
- autorization checking
- validate user input
5.AT SELECTION-SCREEN ON <f>.
- it triggers when the user interacts with particular field in the
- it is used to validate particular field

selection screen.

6.AT SELECTION-SCREEN ON <seltab>.


- it triggers when the user interacts on selection table
- it consist of logic to process select-options
7.AT SELECTION-SCREEN ON END OF <seltab>.
- This event block cheks the whole selection table <seltab>.
8.AT SELECTION-SCREEN ON BLOCK <block>.
- it is triggered when the contents of all of the fields in a block are
ABAP program.
- it is PAI event of selection-screen

SAP ABAP Material Soft copy

passed from the selection screen to the

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
9.AT SELECTION-SCREEN ON RADIOBUTTON GROUP <radi>.
- In the PAI event of the selection screen
- it is triggered when the contents of all of the fields in a radio button
group are passed from the selection
screen to the ABAP program.
10.AT SELECTION-SCREEN ON HELP-REQUEST FOR <field>.
- it is used to provide F1 help docuementation to selection-screen
- it triggers , when the user press F1 key of field

field.

11.AT SELECTION-SCREEN ON VALUE-REQUEST FOR <field>


- it is used to provide F4 help to selection-screen field.
- it triggers , when the user press F4 key of field

- **********************
List Screen Events :
1. START-OF-SELECTION.
- it is implicit default event, triggred by system for all executable
- it triggers before displaying list screen
- it consist of data fetching logic

programs

2.END-OF-SELECTION.
- it is triggered after START-OF-SELECTION event
- it triggers once the data selection is over
- it is used to display output to list screen
3.TOP-OF-PAGE.
- it provides header information to list screen
- it is triggered by first write statement,skip (or) uline statement.
4.END-OF-PAGE.
- it provides footer information for page
- it is triggered by LINE-COUNT addition along with REPORT

statement.

sy-linct system field displays totol number of lines(rows) per page.


LINE-COUNT 20(1).
system displays total 20 rows per page, out of 1 row is reserved for footer
To increase output list width, we have to use line-size <n> addition along with REPORT statement.
sy-linsz system field provides list screen width.
By default, whatever the title we provided in the attribute screen will apper as list screen heading and title.
we can provide custom list heading and column heading using Text Element.
Standard page heading can be suppressed using addition NO STANDARD PAGE HEADING along with Report
statement.
REPORT Transaction :
- can be created in SE93 tcode
- using SE93 custom tcodes can be created
- it is used to assign Reports to end users
- it combines program name and standard selection screen (1000)
- End user access the report using Report Transaction
Steps :
go to SE93.
specify tcode name staring with Y or Z
click on create
specify short text
select report transaction
continue
specify executable program name and selection screen 1000
check GUI support for windows
save, check.
Finally execute Tcode from Easy Access
*---------------------------------------------implementin authorization object

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
- created a program (zde_classical_list)
created tcode (zclist_tcode)
tested tcode

krishna.saptrainer@gmail.com

- step1 : SU21 - > Authorization Class(zaoc) and Authorization object(zauthobj) creation


- step2 : go to tcode : se93 -> open existing tcode -> assign
authoriztion object and assign values
(ex : bukrs ->1000
actvt -> 01 - create authorization
02 - change authorization
03 - display authorization )
- step3 : role creation using PFCG tcode
create custom role (zrole)
assign tcode : ZCLIST_TCODE
save
- step4 : user creation using SU01 tcode
assign role in the role tab(zrole)
- step5 : go to se38 ,open program in change mode, implement authorization object under AT SELECTION-SCREEN
on <f> event.

Example Standard program for Interactive list :


Easy Access -> SAP Menu -> Information Systems ->Logistics -> sd ->customer -> incoming orders ( Tcode MC(A )

While Working with SAP, we come across 3 types of screens,


1.Selection-screen
2.List screen
3.Dialog Screen
Selection screen and list screens are used in Reporting
Dialog screens are used to accept value from user(input) / display
value to user(output)
Dialog Screens are special screens, which are designed using Screen Painter (SE51)
List screens are used to display program output
Main functionality of List screen is to display
At least one write statement is required to display list screen
Selection-Screen :
- it is intermediate screen between program and list screen
- it is interface between user and program
- Main functionality of selection-screen is to accept input from the user
- it is used to control the output , based on input provided by the user
- 3 keywords generates selection screens :
1.Parameters keyword genereates selection screen with single input
2.Select-options keyword generates selection-screen with range of
3.Selection-screen keyword is used to design block with frame, title,
custom selection screens ..etc.,

SAP ABAP Material Soft copy

field
input fields

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

- parameters doesn't support float data type, we can't accept float data type values from user.
- Basic Syntax of Parameters Keyword
Parameters <f> type <data type>.
Parameters <f> like <DB Table>-<field>.
parameter field name should begin with p_
parameter field name can be up to 8 characters
Alternative Long text can be provided for parameter field using
Selection text is a part of Text Element

selection text

default addition along with parameters is used to provide default value to selection screen field
syntax :
parameters <f> type <data type> default 'value'.
parameters with obligatory addition is used to make selection screen field as required entry (or) mandatory field.
syntax :
parameters <f> type <data type> obligatory
In general user entered character values are converted to upper case
by default.
but parameters with lower case addition is used to suppress auto conversion of lower case values to upper case.
As a result, lower case values are displayed in lower case only.
syntax :
parameters <f> type <data type> lower case.
parameters with no-display addition is used to suppress particular field in the selection screen. that field is not
visible in the selection screen.
syntax :
parameters <f> type <data type> no-display.

parameters with visible length addition is used to specify input field length to be displayed in selection screen.
syntax :
parameters <f> type <data type> visible length '<len>'.

- generating check box :


syntax :
parameters <f> as checkbox.
checkbox name begins with cb_
single checkbox is allowed
using default 'X' , we can check the checks while loading the

selection screen.

- generating radiobuttons :
syntax :
parameters : <f1> radiobutton group <grp>,
<f2> radiobutton group <grp>.
radiobutton name begins with rb_
at least two radiobuttons defined under one group
using default 'X' , we can select that radiobutton while loading the

selection screen.

- Note :
check boxes are provided to user, where user can check nothing (or) user can check all (or) user can check any
one or required options
radiobuttons are provided to user, where user can select one option out of several options under one group
by default first radiobutton is selected by system automaticaly.
VARIANT : is used to provide default values to selection screen.

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
pre defined (or) pre configured values of selection screen can be saved as Variant.
we can create one or many variants to selection screen
Each variant provides different set of values.
Selection screen is required to create variant
Standard Selection screen number is 1000.
Steps to create variant :
- execute program
- specify different values to selection screen fields
- click on save
- specify name and meaning , type of variant
save, back
- notice that system enabled get variant option in selection screen
- using get variant option, we can choose any variant from the list of
variants
Syntax :
parameters <f> like <DBtable>-<f>.
parameter field is created with ref to DB Table field, As a result technical attributes(data type, length) and semantic
attributes ( field label, F1 help documentation, F4 help) are copied selection screen field.
Alternative syntax ;
parameters <f> type <DBtable>-<f>.

SELECTION-SCREEN keyword is used to format selection screen.


- generating blocks with frame and title
Syntax :
selection-screen : begin of block <blockname> with frame[title <tit>].
--- <declare elements using parameters (or) select-options>---.
selection-screen : end of block <blockname>.
using text symbols we can provide title for block and frame.
using INITIALIZATION event we can provide default title for block
- syntax to provide blank lines with in frame.
selection-screen skip <n>.
- syntax to provide underline with in frame.
selection-screen uline /<pos>(length).
- syntax to place elements in single line.
selection-screen begin of line.
selection-screen end of line.
- syntax to place the cursor position at specified positon.
selection-screen position <pos>.
- syntax to provide comment lines for single line elements with in block
selection-screen comment <pos>(len) text-<nnn> for field <f>.
- syntax to define custom selection-screen
selection-screen : begin of screen <scrno>.
selection-screen : end of screen <scrno>.
syntax to call custom selection-screen :
call selection-screen <scrno> [starting at <col> <row>]
[ending at <col> <row>.

system display standard screen first and custom selection screen

next

- Screen Field Attributes :


Screen field consist of different attributes like
- active
- invisible
- required

SAP ABAP Material Soft copy

A.V. Krishna
- F4 help
- output only
- intensified
etc.,

+91 9704886510

krishna.saptrainer@gmail.com

- SCREEN is built-in global structure which provides different attributes screen fields.
- SCREEN is built-in internal table ( system data object ) ,which
provides different attributes to screen fields
- SCREEN is like an internal table with a header line.
using following syntax we can set default attributes to screen fields
under AT SELECTION-SCREEN OUTPUT event.
loop at screen.
if screen-name = '<field>'.
screen-<attribute> = '1' or '0'.
modify screen.
endif.
endloop.
- by specifying loop statement for SCREEN internal table, we can
fields.

modify condition based attributes of screen

- <field> can be name of the screen field


- inorder to apply attribute for screen field specify value as 1
to reset (or) not apply attribute to screen field specify value as 0.
- syntax :
parameters <f1> type <data type> modif id <GRP>.
using modify id addition we can set common default attribute to group fields.
modif id followed by group name, which consist of 3 characters
maximum 4 groups are allowed.
syntax for loop statement .
loop at screen.
if screen-group1 = '<GRP>'.
screen-<attribute> = '1' or '0'.
modify screen.
endif.
endloop.
As a result, common attribute is applyed to fields of the group.
- syntax :
parameters <f> type <data type> matchcode object <search help>.
Elementary search help (or) match code object can be attached to selection screen field using this syntax.
- syntax :
parameters <f> type <DB table>-<field> value check .
value check addition generates F4 help, and perform field validation
( if the user choose a value from F4 list, then entry is valid otherwise it is invalid)
- syntax :
parameters <f> type <DB table>-<field> memory id <pid>.
using memory id addition we can display default value ( as per user
- SELECT-OPTIONS :
- generates selection screen with lower and upper input field
- using SELECT-OPTIONS , we can accept range of values from
- syntax :
Select-options <f> for <DBtable>-<field>.

profile )

user

select-options <f> must begins with SO_

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
select-options <f> length can be up to 8 characters
using Selection Text , we can provide alternative long text for
options <f>.
- system(ABAP interpreter) can't recognize table field automatically
- Inorder to tell the system regarding table field, we have to declare
keyword.
- syntax :
Tables : <DBtable1>, <DBtable2>.
- Tables keyword works like interface work area
- Tables keyword loads the Data Dictionary Structure as work area
- As a result, One work area gets created on RAM, with the database

select-

database table name using TABLES

table name

- performance point of view, Tables keyword is not recommended(


because it creates entire work area with all
fields by default)
- we can create variable with ref to table field, use this variable while
creating select-options statement.
- while ref to table field, system copies field label, F1 help
field

documentation and F4 help to selection screen

- SELECT-OPTIONS syntax creates internally one special internal


table with the <f> name
- this special internal table is always created as with header line.
- this special internal table is also called as selection table
- this special internal table consist of 4 fields
sign
option
low
high
- sign specifies wheather Include range (or) Exclude range
sign values can be
'I' - Inclusive (default)
'E' - Exclusive
- option specifies the relational operator
option values can be
BT - between (default)
NB - not between
EQ
equall to
NE not equalls to
GT
greater than
GE greater than or equalls to
LT
less than
LE less than or equalls to
- low specifies lower limit value
low value appears as lower input field
- high specifies upper limit value
high value appers as upper input field
- using INITIALIZATION event we can provide default values to
as hardcoded value

selection table (or) select options internal table

- Advantage of select-options :
system displays multiple selection icon in the selection screen, which is useful to set include single / range of
values, to set exclude single / range of values according user choice. (without changing select
query in the
source code )
- default addition along with select-options is used to provide default values to selection screen field
- no-display addition along with select-options is used to suppress the visibility of field in the selection screen
- no-extension addition along with select-options is used to suppress
screen
As a result , user always select only one range of values.
extended selection is not possible

multiple selection option in the selection

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
- no intervals addition along with select-options is used to suppress
upper limit value, but multiple selection icon
is avilable
As a result, user can choose single (or) range of values of field
range of values can be set using multiple selection option
*****************************************************************************
write statement, uline, and skip statement generates list screen

NOTE :
- RANGES keyword also used to create internal table with sign,option, low and high values.
- RANGES keyword doesn't generate selection screen
- Push buttons, Tab strip control , subscreens also possible Selection screen.
Inter program communication :
- this topic deals with program to program communication
- SUBMIT statement is used to executable program in another
Syntax :
SUBMIT <program>.

executable program ( report in report)

- Syntax :
SUBMIT <program> and return.
this statement calls executable program and while returning it

display current program output in separate list

- Synatx :
SUBMIT <program> via selection-screen.
this statement calls executable program and its selection screen also.
- Syntax :
call transaction '<tcode>'.
this statement is used to call any existing tcode
while executing this statement, control transfer to specified
current program.

transaction and while returning system executes

- Syntax :
leave to transaction '<tcode>'.
this statement calls specified tcode and while returning control

transfer to SAP Easy Access.

- SAP Memory :
it is common memory shared by all external sessions
SAP Memory can be shared using SET / GET parameter statements ( SPA and GPA staments )
SET parameter statement reads a value from one session and places into SAP Memory
GET parameter statement reads a value from SAP Memory to
another session.
Syntax :
SET parameter id '<PID>' field <f>.
GET parameter id '<PID>' field <f>.
parameter id can be defined at DATA Element level :
path to view parameter id :
go to tcode : SE11 -> open data element in display mode -> further
parameter id
Field name
KUNNR
MATNR
LIFNR
VBELN
EBELN
BUKRS
Werks_d

characteristics tab -> notice

Parameter Id
KUN
MAT
LIF
AUN
BES
BUK
WRK

- Using parameter ID ,we can provide default value to dialog screen, under user profile.
menu path to set default value for parameter ID :
system menu -> user profile -> own data
-> parameters tab
specify parameter ID and its value
BUK - 1000

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

EKO - 0001
KGK - 0002
- TPARA table consist of all Parameter ID
- custom parameter ID also possible
while creating Custom data element we can create custom
specify custom parameter ID name begins with Y or Z
EX : ZEID
double click on parameter id , specify short text
activate data element.

parameter ID

- ABAP Memory : is a common memory , shared by all internal sessions of an external session
using EXPORT and IMPORT statement ABAP memory can be shared between session.
EXPORT statement exports the field value from one internal session to ABAP Memory
IMPORT statement imports the field value from ABAP Memory to

another internal session.

Syntax :
EXPORT <f> [FROM <gs>] TO MEMORY ID <key>.
IMPORT <f1> [TO <gs>] FROM MEMORY ID <key>.

Interactive List :
- Classical List is used to display required all columns in the list screen
- Interactive List is used to display required columns in the basic list, and based on user interaction it displays
corresponding details in the detail list
- 1 basic list + 20 secondary lists are possible
- it is also called as Drill down list (or) detail list (or) secondary list
- sy-lsind is a system field , which provides index of interactive list
- sy-lsind value for basic list is zero and for secondary list1 is 1 and so on....
- Secondary lists are genererated by Events
- Events used in Interactive List :
1.AT LINE-SELECTION.
it triggers after user interaction on basic list (when user interacts
on a
row)
it consist of logic to generate secondary list
2.TOP-OF-PAGE during LINE-SELECTION.
it also triggers when user interacts on basic list
it provides header information to secondary lists
3.AT USER-COMMAND.
it triggers when the user issue commands on basic list ( using
it also triggers when user interacts on STATUS(menu) of list
it also consist respective logic to handle user action

command field)
screen

Standard demo program : demo_list_at_user_command

4.AT Pf<n>. "press function key


it also triggers when the user press function keys on basic list
it generates secondary list based on user interaction
it is obsolete event.
Standard demo program for AT PF<n> :

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510
demo_list_at_pf

krishna.saptrainer@gmail.com

HIDE :
- is a statement
- it hides the row information (which is interacted by the user)
into HIDE area , to display further details in
the next list
- it must be used with in loop
- it muse be after write statement
- syntax :
HIDE <f>.
- Hide must followed by key field
- it moves the user interacted row information from internal table to work area
- it works on row basis ( regardless of cursor position )
when user interacted on a row of basic list ( double click (or) F2 )
then PICK function code triggeres AT Line Selection event.
GET Cursor :
- statement is alternative for HIDE
- it also used to generate interactive list
- it works on cursor position based
- it is used to read particular column(field) value
- syntax :
GET CURSOR FIELD <f> [OFFSET <off>]
[LINE <lin>]
[VALUE <val>]
[LENGTH <len>].
- System Fields used in Interactive List :
sy-lilli : provides absolute line number where user interacted
sy-lisel : provides the content user interacted line
sy-ucomm : it consist of command enterd by the user
sy-pfkey : provides current GUI status
sy-title : provides title of current program
sy-linno : current line number
sy-colno : current column number
sy-listi : provides index of list, where last user interacted
ALV :
- ABAP List Viewer
- it is also called as SAP List Viewer
- it is reporting technique used in ABAP
- using ALV, we can display simple and complex reports also
- ALV Reporting is possible as two ways :
- Procedural ALV :
- reports are generated by using Globle Type Group(SLIS)
and Function Modules( REUSE_ALV )
- OOALV :
- reports are generated using Global Class ( CL_GUI_ALV_GRID )
and Methods ( Set_table )
- Limitations of Classical Reporting :
- automatic column heading display not possible
- automatic back ground color display not possible
- output display column positions must be specified
- automatic column width is not possible
- automatic all columns display not possible
- Advantage of ALV :
- ALV output is displayed with special application tool bar
which consist of severla options like
- sorting (ascending/ descending)
- detail display
- save output as Excel / word / RTF format / HTML / clipboard
- change layout settings (hide columns / display columns)
- perform grand total and sub total
- navigation buttons
- first column

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

- previous column
- next column
- last column
- set filter ( specify required values )
- Types of Possible Reports using Procedural ALV
1.Simple ALV List
2.Simple ALV Grid
3.ALV Fieldcat List
4.ALV Fieldcat Grid
5.ALV List - Fieldcatalog merge
6.ALV Grid - Fieldcatalog merge
7.ALV Event List
8.ALV Event Grid
9.ALV Block List
10.ALV Hierarchical List
11.ALV Interactive List
12. ALV Interactive Grid
1.Simple ALV List :
it is used to display database table data(all columns) in list screen
steps :
1.declare internal table and selection screen
2.populate internal table using select statement
and
3. to display final output call SAP defined function module
'REUSE_ALV_LIST_DISPLAY'.
uncomment exporting and pass database table
name as
i_structurename
pass internal table name for tables parameter
this function module functionality is , it writes either single line or

multi line output in the list screen.

in Final output system generates a structure for database table


( structure specifies how to write output )
in Final output system writes rows or records from internal table
( internal table specifies what to write in the output )
2.Simple ALV Grid :
it is also used to display database table data(all columns) in list

screen, which is displayed in Grid format

- to display final output call SAP defined function module


uncomment exporting and pass database table
name as
pass internal table name for tables parameter

'REUSE_ALV_GRID_DISPLAY'.
i_structurename

this function module functionality is , it writes either single line or

multi line output in the list screen.

in Final output system generates a structure for database table


( structure specifies how to write output )
in Final output system writes rows or records from internal table
( internal table specifies what to write in the output )

- Advantages(features) of ALV Reporting :


- output is desplayed as modern design
- redusing programmer efferts
- Output is displayed in different formats using SAP provided function
- it display special tool bar with several options
filter and sorting is possible by end user with out changing source

module
code of program

*- ALV Fieldcat List :


- Fieldcat is used to display required columns(data) of database table
- Fieldcat suppot several formatting options, which can be applied on
any column
- As per the Function Module , Fieldcat is always passed as internal
table.
- thatswhy declare fieldcat as per associate type of import parameter
of function module (to avoid type conflict
errors)
- We can Prepare (or) Build fieldcat internal table can be 3 ways :
- using DDIC Structure ( part of DD02L table )
- prepare manually by writting code as per requirement

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

- using Built-in Function module

krishna.saptrainer@gmail.com
'REUSE_ALV_FIELDCATALOG_MERGE'.

- Steps of ALV Fieldcat List :


-

declare SLIS type group ( it allow us to use SLIS component )


declare internal table with requried fields to hold database table
declare fieldcat internal table to display required fields and
design selection screen

data
required format

- validate selection screen field


- prepare fieldcat internal table manually
- populate internal table using select statement
- display final output by calling function module
uncomment exporting
pass sy-cprog as I_callback_program
pass fieldcat internal table as IT_FIELDCAT
pass internal table for tables tab

'REUSE_ALV_LIST_DISPLAY'

Note : this function module consist of some exit routines ,


inorder to display current program output in list screen we have

to pass sy-cprog as callback program

*- ALV Fieldcat Grid :


to display output call function 'REUSE_ALV_GRID_DISPLAY'

*- ALV FIELDCATALOGMERGE LIST :


- it is used to display two or more database table required fields(data)
in the output
- Prerequisite : Database tables must have relationship in the
underlying database
- Step1 : declare global structure in ABAP Dictionay with two table
fields
- Step2 : declare internal table in ABAP Program using global structure
populate it using inner join select statement
pass it to final function module
- Step3 : declare fieldcat internal table
prepare it by calling function module
'REUSE_ALV_FIELDCATALOG_MERGE'
pass it to final function module
Note : 'REUSE_ALV_FIELDCATALOG_MERGE' function module is used to merge global structure fields and return
prepared
field
catalog internal table
uncomment exporting
pass global structure name as I_STRUCTURE_NAME
pass internal table to hold prepared fieldcatalog
*- ALV Event List :
- TOP_OF_LIST event provides header information for list
- END_OF_LIST event provides footer information for list
- TOP_OF_PAGE event provides header information for page
- END_OF_PAGE event provides footer information for page
OOALV supports above all events
Procedural ALV supports TOP_OF_PAGE event
Working with Event list
- declare internal table and work area using SLIS component
- prepare (or) build Event internal table
- pass event name and form name (subroutine)
- pass event internal table to final function module
- declare subroutine finally.
While executing program the write statement avilable in the subroutine, will be displayed as Header
- ALV_EVENT_GRID :
in ALV Grid output, we can provide header information using TOP_OF_PAGE event.
in subroutine definition we have to call function module 'REUSE_ALV_COMMENTARY_WRITE'

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

this function module is used to pass logo ( using this option we can

print logo in the output header)

- header information can be printed using internal table


- internal table must be declared with SLIS_T_LISTHEADER associated type
we can pass typ values as H - heading
A - action
S - selection
key value can character , 20 is allowed
info value can be character , 60 is allowed
*-----ALV Block List :
it is used to print output with several blocks
several blocks can be allowed in list format only (not as grid format)
each block prints independent information
several blocks can be printed with in one layout
we can navigate using system generated buttons at application tool bar
Function modules used in Block List
'REUSE_ALV_BLOCK_LIST_INIT' - this function module initilizes

block list output

'REUSE_ALV_BLOCK_LIST_APPEND' - this function modules

appends values to specified block

'REUSE_ALV_BLOCK_LIST_DISPLAY' - this function module

displays output in block mode

*------ALV Hierarchial List


it is used to display data as hierarchical format
Hierarchy can be generated up to 5 levels
Inorder to generate hierarchy Header and Item tables must have relationship in the underlying database
Both header and item internal tables must have common key field
using one fieldcat we will display both tables data.
keyinfo can be declared as work area using SLIS component SLIS_KEYINFO_ALV.
pass common keyfield values to keyinfo
finally display output by calling function module 'REUSE_ALV_HIERSEQ_LIST_DISPLAY.
*-----display logo in ALV Grid ----*
Assume that logo is avilable at Desktop
Step1 : importing logo from Desktop Business Document Navigator
- go to tcode OAER
- specify class name : pictures
class type : OT (other objects)
object key : mylogo(name of the logo)
- execute
- select document type as Screen
- double click on screen (file manager appears)
- select desktop logo, open
- continue
notice that Document stored successfully
Step2 : in ALV Program, pass logo name to
'REUSE_ALV_COMMENTARY_WRITE' function module

*-----displaying checkbox as leftside for every record


it is possible for list only
while declaring internal table declare one flag with data type c.(as first column)
while populating internal table use into corresponding fields addition along with select statement
pass this flag name as box_fieldname for layout.
*----pass sy-title as i_grid_title to display title as grid header
*----pass some subroutine name as i_callback_top_of_page to print

header information and logo in ALV Grid

*---in hierarchical sequential list , we can display expand icon also.


*-----ALV Interactive List :

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

it is used display required data on basic list, based on interaction on basic list it generates secondary list (or) detail
list
detail list displays user interacted row corresponding data
to handle user interaction on basic ALV list, we have to use USER_COMMAND event.
when this event triggers control transfer to corresponding subroutine.
we can generate detail list as 3 ways
- user interacted index based
- user interacted fieldname based
- user interactef field value based
Syntax of subroutine to be passed for USER_COMMAND event.
form <subroutine> using rs_ucomm like sy-ucomm
rs_selfield type slis_selfield.
endform.
this subroutine is defined with 2 formal parameters
rs_ucomm is declared with sy-ucomm, which is used to handle user command ( double click - F2 )
rs_selfield is is declared with SLIS component SLIS_SELFIELD
- SLIS_SELFIELD consist of
tabindex - is used to read record based on internal table index
value - is used to read record based on field value , where user
fieldname - is used to read record based on fieldname, where

interacted
user interacted.

SLIS package consist of ALV related Function M


odules
SALV function group consist of ALV related Function Modules
All ALV related function modules names begins with 'REUSE_ALV'
ALV related function modules are avilable as
- block list concern
- list concern
- grid concern
- event concern
- extract management concern
- variant concern
Exploring ALV Function module
- import parameters are declared with slis components and default

values, short description, long descriptions

while working with function modules read documenation ( goto menu -> documenation) and implement
SAP provided description and possible values as do
cumentation

Fieldcat options :
col_pos : field appearing column position in the list
value set : 0, 1-60

fieldname : internal output table field name (required parameter)


Fieldname to be displayed at column position
it must be passed with in quotes and uppercase
Filedname can be up to 30 characters
tabname : internal output table name
it is passed as Internal table name
it can be upto 30 characters
ref_tabname : ref to Data Dictionary Structure / Table

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

as a reference , column heading is displayed form data

element

emphasize : highlight columns in color


expected values 'X' or Cxyz
C - color
x - 1 to 9 color
y- bold
z - inverse
hotspot : is used to provide hyperlink option for particular column
: values : 'X' or SPACE
do_sum : is used to perform sum over column
it is used on currency / quantity values to be displayed with

grand total

seltext_l : displays long field label


seltext_m : displays medium field label
seltext_s : displays short field lable
seltext is used to provide custom column ( ref_tabname is not required)
Layout options :
- colwidth_optimize
value set: SPACE, 'X'
'X' = optimzes the column width so that all contents are displayed

completely.

- zebra
value set: SPACE, 'X'
'X' = striped pattern (e.g. for wide lists)
- box_fieldname
value set: SPACE, internal output table field name
to display checkbox for all the rows
NOTE : ALV output supports Layout Management
while displaying final output by function module
we have to specify i_save as 'X' , to enable save layout option
-

As a result, user can save several layouts as several variants


Each variant provides specific layout
path to save layout : settings menu -> layout -> saving
user can change the column display sequence
( in grid mode - using drag & drop )
( in list mode - change display column position )

************************** ABAP Query


- it is also called as SAP Query
- it is used by functional consultants / endusers
- it is used to generate report without programming
- Step1 : tcode - SQ03 - User Group creation
- Step2 : tcode - SQ02 - Infoset / Functional Area creation
- Step3 : tcode - SQ01 - Query creation
- User Group is a collection of Users under one department
- Infoset is created and finally assigned to User group
- Infoset consist of data source from
- single table
- join tables
- LDB
- external program
- Query uses User group and Infoset
final output can be displayed as - Basic List
- Statistics
- Ranked List
- Path form Easy Access :
SAP Menu -> Tools -> Utilites -> SAP Query
- Step1 : User Group creation : tcode : SQ03
Specify user group starting with Y or Z
Click on create

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

Specify short text


Save as local object
Specify username as SAPUSER
click on change
select our user group and save
- Step2 : Infoset creation : tcode : SQ02
specify infoset name starting with Y or Z
click on create
specify name ( Title of Report )
specify data source
- Table join using basis table as KNA1
continue
- select kunnr (key field) , click on insert table icon
- specify knb1 , continue
click on infoset tab
- select include key fields (as fieldgroup)
drag and drop (left to right) required fields from database
save, check, generate infoset
click on User Group Assignment tab , select our User Group ,
- Step3 : tcode : SQ01 - Query creation
Edit menu -> other user group -> choose our user group ->
specify the query name starting with Y or Z, create
select our infoset , continue
specify title
click on next screen - select field groups
click on next screen - select required fields
click on next screen icon - select fields for selection screen
click on basic list
select required fields to be displayed , as required sequence to
observer preview at right side, we can provide header , footer
save,check, test
*************************************************
QuickViewer :
- tcode : SQVI
- it is used to generate and view report quickly
- system generates code for our fields and navigation
report can be displayed using - table
- table join
- LDB
- SAP Query infoset
***************************************************
Ad Hoc Query is used HR, it generates report based on infotypes

SAP ABAP Material Soft copy

table to respective field group


save
continue

display
information also

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

LDB : Logical Database


- it is an independent program,which is used to fetch large amount of
data
- Using Logical Database Builder, we can define custom LDB
- tcode for LDB Builder : SE36
- path from Easy Access : tools -> ABAP Workbench -> development -> programming environment -> logical
databases
- LDBs are mostly used in ABAP HR programming
Ex : pnp, pch, pap
- LDB is created as Hierarchical
Advantages of LDB :
- it can be used in multiple ABAP programs (reusability)
- it performs implicit Authorization Check
- it fetches huge quantity of data
- system generates code for our navigation
- Dynamic selection screens generated by LDB
Disadvantages of LDB :
- it uses select...endselect loop, thats why data selection is delayed
Components of LDB :
- Structure
- Selections
- Database Program
- Structure specifies the nodes of LDB
Nodes can be defined as hierarchical
Root node -> sub node -> subnode
Node can be a Database Table / Dictionary Structure
- Selections tab is used to design selection screen
- Database Program consist of system generated includes and
routines consist of system generated select statements.
- Usage of LDB :
LDB can be used in ABAP Executable program

routines

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
LDB name can be attached in Attribute screen of ABAP program

Custom LDB creation steps :


- execute tcode SE36
- specify LDB name begins with Y or Z
- click on create
- specify short text, continue
- save as local object
- specify root node as MARA ,short text,
database table as MARA - create
- select root node,
- click on insert node
- specify table as MARC, short text, database table as MARC - create
- select MARC, click on insert node
- specify node name as MARD,short text, database table as MARD - save structure

create

- click on selections tab


yes ->
select free selections and transfer
( free selections are used to fetch complete data - system generates
code as select * from <db table> )
( field selections are used to fetch required data of database - sytem
<DB table>)
- uncomment select-options and replace ? by suitable names
select-options : so_matnr for mara-matnr.
select-options : so_werks for marc-werks.
select-options : so_lgort for mard-lgort.
save, activate include,back
- click on database program
yes -> double click on nxx include
notice that system generated 3 includes for 3 nodes
double click on 001 node (node MARA)
uncomment select statement as below
select * from mara
into mara
where matnr in so_matnr.
put mara.
endselect.
save, check, activate , back
double click on 002 node(node MARC)
uncomment select statement as below
SELECT * FROM MARC
INTO MARC
WHERE MATNR = MARA-MATNR
AND WERKS IN so_werks.
PUT MARC.
ENDSELECT.
save, check, activate, back
double click on 003 node (node MARD)
uncomment select statement as below
SELECT * FROM MARD
INTO MARD
WHERE MATNR = MARC-MATNR
AND WERKS = MARC-WERKS
AND LGORT IN so_lgort.
PUT MARD.
ENDSELECT.
save, check, activate, back
test LDB
- Usage of LDB in ABAP Program
go to tcode SE38

SAP ABAP Material Soft copy

generates code as select <f1> <f2> ..from

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
specify program name starting with Y or Z
click on create
specify title , type as Executable , specify LDB name
save as local object
- Sequence of events in LDB program :
start-of-selection.
get
get late
end-of-selection.
- get <node>.
this event triggers corresponding subroutine exist in LDB database program.
PUT statement reads the data from database node
and sends to work areas defined in program
- get <node> late.
this event triggers late, after processing all subnodes under main node and before branching to another main
node
this is useful to calculate sub total / grand total
- LDB nodes can be terminated conditionlly using CHECK statement
and uncoditionally using STOP statement.
- Difference between Exit and Stop ?
Exit is used to terminate loop
Exit always terminates current loop and procedes further
Stop is used to terminate LDB Nodes
Stop stops the processing immediately, and control transfer to End-of-selection.
- Note : using LDB_PROCESS function module , we can use several LDBs in one executable program

- Reporting Standards / Coding Standards


- naming conventions
program / report name :
ZRL_MM_PUR_ALV_LIST
z - custom report
RL - Reddy's Lab ( client name )
MM - Application
PUR - component
ALV_LIST - type of report
table types - t_
line types - ty_
work area - wa_
internal table - it_
global variable -gv_
local variable lv_
constants
c_
global flag
gf_
local flag
lf_
parameter fieldname pa_
select-options fieldname so_
radiobutton name
rb_
checkbox name
pushbutton name
object
o_
ref variable
rvar_
local class
lcl_
global class
gcl_
local interface
lif_
global interface

cb_
pb_

gif_

SAP ABAP Material Soft copy

A.V. Krishna
import parameter
import structure
import internal table
export parameter
-

+91 9704886510

it_

krishna.saptrainer@gmail.com

i_
is_
e_

provide meaningful title for program


save under package
contiue with workbench request
Maintian Global comment section as below
Program name : XXXXXX
Author
: xxxxxxxxx
Function consultant : xxxxxxx
Date :
xxxxxxx
Package : xxx
Application Area : xxx
Workbench Request : xxxxxxxxxxx
Description :
Modification Log : xxxxx
date xxxxx
maintain comments for each block of statements
Use events explicity
maintain selection text for parameter field and select-options field
Use text symbols to avoid hard coded text and reusable text
Use message class messages
Use dynamic messages
Design selection screen as block with frame and title
create required variants
validate all selection-screen fields
Use pretty printer once finally ( for indentation )
modularize source code finally using includes, subroutines
use as many function modules as possible
generate version for object before modification
refer ABAP HELP / ABAP DOCUMENTATION examples
Verify program using tools like
- ABAP Debugger
- Extended Program Check
- Runtime Analysis
- SQL Trace
- Code Inspector
- Memory Inspector
- Runtime Monitor
- Coverage Analyser

- Performance Factors on Database Tables


- specify correct buffering type
- create secondary indexes on non key fields
- log data changes
- Performance Factors Internal Tables :
- Use Internal tables instead of select...endselect
- Use as many internal tables as possible
- always declare internal tables with required fields
- Use always internal table with out header line syntaxes
(explicit work aera)
- instead of occurs use initial size
- instead of like use type
- specify memory parameter appropriate
- delcare internal table fields as per database table field order
- whenever read statement is used, check with sy-subrc immediately
- always use binary search addition along with read statement
- sort internal table before using binary search
- Always sort internal table using fieldname
- Modify internal table using transporting addition
- use Free statement if the internal table is not required
- use clear statement for workarea immediately
- do not nested loop...endloop statement
- do not use select statement with in loop
- avoid type casing
- always use move-corresponding

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

- Performance Factors on open SQL statements


- use open SQL rather than Native SQL
- use sy-subrc statement for each open SQL statement
- use select into table addition , instead of select...endselect loop(
Array Fetch operation)
- use select <f> instead of select *
- select single statement must consist of where condition with key
fields
- whenever up to rows addition is used, use order by
<keyfield> addition
- use as many condition as possible along with select statement
- instead of sorting at itab level, use order by addition along with
select statement
- instead of performing arithmatic operations at itab level, use select
with aggregate functions
- instread of removing duplicate records at itab level, use select with
distinct addition
- use having addition, whenver group by is used
- use inner joins (or) Database Views while fetching data from more
than 1 table
- use for all entries , instead of nested select statements
- avoid using into corresponding fields of addition ( specify field
sequence as per the database table )
- deal with separate internal table , if the source table is cluster /
pooled table
Performance Tools :
- Extended Program Check :
- it is also called as Extended Syntax Check
- tcode : slin
- menu path from ABAP Editor : program ->check ->extended
- it is used to perform additional checks (or) detail check of any
- the result is displayed as erros, warnings, messages
- it performs several checks like
- call function interfaces
- perform/ form interfaces
- autorization checks
- character strings
- messages
- obsolete statements, problematic statements, superflous
- syntax check
- package check

program

statements

*******************************************************************
- Runtime Analysis :
- tcode : SE30
- menu path from any screen : system menu -> utilities -> runtime
- menu path from ABAP Editor : program menu -> execute ->
- it is used to analyse the performance of Tcode (or)Function
- Steps :
specify program name
click on execute button
system executes program output, back
As a result, this tool measures the program parameters at

program check

analysis -> execute


runtime analysis

Module (or) Program dynamically (at runtime)

runtime and finally it generates a File in kb

Using Evaluate Tab, we can analyse the program performance


this tool generates load on CPU as bar graph with system,
database, ABAP levels
execution time in micro seconds
- Tips & Tricks tab provides several exmple comparitive select

statements with documentation

***********************************************************
SQL Trace :
- Tcode : ST05
- Menu path from any screen : system menu -> utilities -> performance trace
- it is used to analyse SQL statements involved in program
- by default all traces are switched off
- we can activte trace for user specific and program specific
- Steps :
Activate Trace with filter
- execute program parallel
Deactivate trace
and display trace
result is displayed as trace

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

- place the cursor on any SQL statement


click on DDIC information - it provides Data Dictionary information of
involved in the select query

table/view

Explain SQL tab - provides the system execution plan internally


- SQL Trace: This allows you to monitor the database access of

reports and transactions.

- Enqueue Trace: This allows you to monitor the locking system.


- RFC Trace: This provides information about Remote Function Calls

between instances.

**********************************************
SAP Code Inspector :
- tcode : SCI
- menu path from Easy Access : SAP Menu -> Tools -> ABAP Workbench -> Test -> SCI
- menu path from any ABAP Editor screen : program menu -> check
-> code inspector
->
->
->
->

this tool is avilable from 4.7EE onwards


this tool also used to perform checks on WebDynpro application
it is used to perform several checks of any program
it carry out checks like
- performance checks ( select statements ,itab operations
- security checks ( system calls, native SQL statements etc )
- syntax check / extended syntax check
-> result list is dispalyed as errors, warnings, info
-> Steps to work with SCI
-go to tcode : SCI
- Step1 : create checkvariant
specify checkvariant name starting with Y or Z
click on create
select list of checks to carry out
( Check variant consist of list of possible checks )
- Step2 : create objectset
specify objectset name begins with Y or Z
click on create
specify object set ( programs / classes )
( Object set specifies list of objects )
- Step3 : create Inspection
specify inspection name starting with Y or Z
click on create
specify object set and check variant
execute
system carry out checks and displays result
( Inspection combines object set and check variant )
**************************************************************
Memory Inspector :
- tcode : s_memory_inspector
- menu path from any screen :system menu -> utitlites ->memory analysis -> compare memory snapshot
- it is used to analyse memory parameters of a program
- it displays roll area, programs list, classes list,...etc.,
- Step1 : execute any program
generate memory snapshot
menu path : system menu -> utitlies -> memory analysis ->
create memory snapshot
As a result system generates a File
- Step2 : go to tcode : s_memory_inspector
double click on file
analyse memory parameters
******************************************************************
ABAP Debugger :
- it is important tool , used to debug ABAP Programs, Function Modules, Global classes..etc.,
- it is integrated with ABAP Editor, Function Builder, Class Builder..etc
( ABAP Development Workbench )
Advantages of Debuger :
- it is useful to analyse the program behind the screen (background)
- we can analyse

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510
krishna.saptrainer@gmail.com
- sequence of program execution steps,
- sequence of events triggering,
- how values are passed to variables, work areas
- how internal tables are populated
- values of system fields
- it is useful tool to resolve runtime errors and configuration errors
Different Ways of calling Debugger :
- /h in command field
- break-point statement in program
- menu path from any screen :
system menu -> utilities -> debug screen/ program
- menu path from ABAP Editor initial screen :
program -> execute -> debugging
(or) click on Debugging tab
- path form ABAP Program screen :
program -> test -> debugging
Types of Debugger :
1.Classic Debugger
2.New Debugger
- menu path to set default debugger from Editor
utilities menu -> settings -> ABAP Editor -> Debugging tab -> choose classic/ new debugger
- we can swith between classic to new debugger and vice versa using menu path
- debugging menu -> debugging off
-> exit debugger
this path is used to close debugging
- Classic Debugger :
Common options (icons) for all tabs
F5 - Single Step : it is used to analyse program code as step by step
F6 - (Execute) : it is used to execute modularization units (

(line by line)

subroutines, function modules, methods) at a time

F7 - (Return) : is used to return the control back to Main program


it is also used to navigate from one break point to another break point
F8 - Run : it is used to stop debugger and call list screen
it is useful to execute rest of the code at a time and

display output

Watch Point : tab is used to create Watch point


1.Fields tab :
it is used to analyse system fields, variables, work area components
we can analyse 8 fields at a time
system displays fields properties field datatype, length, output length,decimal places
we can change field content with in debug
double click on field value ,
change field content
click on pencil
changes are reflected immediately
but this changes are temporary, and applicable to that time
execution only
- Fields tab displays main program, source code name, current
triggering event name, program section,
analysis section
- default system displays 4 system fields
sy-subrc, sy-tabix, sy-dbcnt, sy-dynnr(1000)
2.Table tab : it is used to analyse internal tabe
system displays internal table content along with index number
internal table type and format also displayed
we can change internal table field content
we can insert a row at any index
we can append a row at bottom
we can delete a row with in debug
3. Break point :

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
krishna.saptrainer@gmail.com
it is a signal in the source code, where system stops execution and
starts debugger
once system come across break point , system enables debugger
and rest of code executed in debugging
mode
Break point can be set as 2 types :
Static Break Point
Dynamic Break point
Static Break point can be set using below syntax :
break-point.
break-point <n>.
break-point <username>.
Ex :
break SAPUSER.
break-point sy-uname.
break-point 'SAPUSER'.
static break points are user speicific
Static break points are not advisable, because they are hard coded
permanent

syntax. it is a part of source code as

static break points can be set only for custom programs


- Dynamic break points can be set using stop icon (or) menu path
place the cursor on any statement , utilities menu -> break point

->set/delete

Maximum 30 dynamic break points are allowed per program


Dynamic break points can be set as highlight the statement ( grey

color )

Dynamic Break points can be set/delete in debug mode


it can be set of locked object also
it can be used to for standard SAP programs also ( in Display mode
only )
All dynamic break points are deleted automatically while log off SAP R/3
Session Break point can be set using Stop icon, which is applicable to current session
External Session Break point also can be set using another Stop icon,
(which is user specific, valid for 2 hours)
it is effected if the current program is used as parallel session

Watch Point :
- can only be created in Debug Mode
- maximum 10 watch points are allowed per program
- it is used to interrupt program, when particular field value changes
- Watch point can be created as local (or) global
local watch points are valid for specific program
global watch points are valid ,if this program is used in another
program
- Watch point consist of a field name, whenever the field content changes system prompts with a message "watch
point reached"
- Watch point can be defined with condition also, whenever system meets the condition, it prompts with a message
"watch point is reached"
- Multiple Watch points can be created using logical operators (AND /
- Watch points are deleted automatically once program is closed
(debugger is closed)

OR)

- calls tab displays active class list as stack


it consist of all the events, forms, modules list in chronological order
- overview tab displays only events list of current program
- settings tab consist of additional debugger settings

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

New Debugger :
- is avilable from ECC 5.0 onwards
- it consist of 11 tabs
- it is extension to Classic Debugger
- New Debugger supports to debug WebDynpro Application
- Separate tab provide to analyse objects,structures, internal tables, ..etc.,
- when new debugger started, program is locked for the user,
debugger is opened as parallel session
- it consist of Desktop1, 2, 3, Standard with different views
- we can increase program section or analysis section
- we can swap program section with analysis section
- program and analysis sections can be displayed as horizonal (or)
verticle comparision
- it supports to save layout also
- local and global variables can be displayed separate
-

Structures tab is used to analyse structures (or) workareas (or)


Tables tab is used to analyse internal tables
Objects tab is used to analyse object oriented objects
Details display tab is used to analyse variables / Field values
Data Explorer tab is used to analyse any data object
Break point/ Watch points tab : is used to analyse breakpoints,
Under checkpoint, we can create log-point, asset log also
- Diff tab is used to compare ABAP variables

fieldstring

watchpoints,checkpoint activation

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

Note : indexes only possible for Transparent Table

Material creation :
Execute Tcode : MM01
Specify Material Number( alphanumeric) fanta
Specify Industry sector (F- food and related product)
Specify Material type(Fert-finished product)
Click on select views
Select basic data1 and sales organization1
Click on organizational levels(specify plant-1000,
Sales org 0001, division -01) and continue
-

Basic Data1 tab :


Specify material description(fanta material creation)
Specify base UoM(EA)
Specify material group (0001)
Specify gross weight (2)
Specify net weight (1)
Sales org data1 tab :
Specify tax classification as 0
Enter
Sales: general/plant tab :
Specify transporting group(0001- on pallets)
Specify loading group(0001-crane)
Finally Click on Save
Notice the status message
G/L Master data creation
Execute tcode : FS00
Click on create
Specify G/L account : (20099)
Specify company code :( rnrl )
Type /Description tab Choose Accout Group from F4 help ( Assets )
Select balance sheet account
Specify short text
Control data tab
Check only balances in local currency
Check line item display
Create/Bank/Interest tab
Specify field status group : G001
Continue
Save and notice the status message
(check in SKA1 G/L Account master data)

SAP ABAP Material Soft copy

A.V. Krishna
-

+91 9704886510

krishna.saptrainer@gmail.com

Maintain HR Master Data (Tcode : PA30)


Scenario : maintain address of an employee(infotype-0006)
Execute tcode : PA30
Specify pernr as 17
Select personal data (0002)
Click on execute
Specify title(Mr)
Specify Last name(kumar)
Specify first name(vinay)
Specify birth date,
Mariatal status
Birthplace
Specify nationality
Save
In the same manner maintain address infotype details also

Sales Order Creation :


Execute tcode : va01
Specify order type (or standard order)
Specify s.org(0001), dist.ch(01), division(01)
Press enter
Specify customer number(99), press enter
System displays customer details , continue
Specify material number, press enter
Specify order quantity, unit of measurement
Specify plant
Specify amount and currency
In the same manner specify required materials
with required quantity.
Finally save.
VL01N Delivery document creation(tables: likp-lips)
Vf01 create billing document(tables: vbrk-vbrp)

Purchase Document :
Tcode to create Purchase Requisition(ME51)
/Purchase order ME21N
Table related to P.Requisition : eban
Tables related to P.order : EKKO/ EKPO
Execute Tcode : ME21N
Choose document type : NB Standard PO
Specify vendor number : 400000
Press enter
Maintain org data tab : ( Purchase org -0001
Purchasing Group 001
Company code 0001)
Delivery/Invoice tab :
Maintain payment terms(0001) and currency(inr)
Enter item as Material number (RAMX), press Enter
Maintain PO quantity(15) PC
Maintain plant (P10)
Maintain delivery date
Click on save finally
*-----------------*
AS01 Create Asset Master Record
F-01 Create Accounting Document
F-02 Enter G/L Account Posting
KS01 Create Cost Center
FB50 Enter G/L Acct Posting(Enter single screen posting)
FB60 Enter incoming invoice(vendor)
FB70 Enter outgoing invoice(customer)
FBL1N Vendor line items

SAP ABAP Material Soft copy

A.V. Krishna
+91 9704886510
FBL3N - G/L Account Line Items
FBL5N - Customer Line Items

krishna.saptrainer@gmail.com

Create profit center


CO01 - Create production order
CS01 - Create Material BOM
CR01 create work center
CA01 - Create Routing
CJ01 - Create Work Breakdown Structure

Transaction Recorder :
Tcode : SHDB
Path from any screen : system menu -> services
-> Batch Input -> Recorder
It is SAP proprietary tool used to record any
Transaction
It records entire transaction concern screens and
Fields, finally it generates code as per user
Navigation
It captures technical information of screens and
Fields as per user navigation
This recoding code is used, while developing Call
Transaction / Session method program
Prerequisite : Awareness of entire transaction
Steps :
Go to tcode : SHDB
Click on New recording
Specify recording name, tcode
Click on start recording
Enter valid values and create sample record while
Calling sequential screens.
Finally save system generated code
Business Scenario : Uploading Vendor master data
Using CALL Transaction method :
Prerequisites :
o
Flat file with vendor data
o
Recorded code of XK01 tcode

Steps : SE38 ABAP executable program


Step1 : declare 3 internal tables
First internal table to hold flat file entries
( flat file order <-> internal table order should be same)
Declare second internal table to specify tcode
Concern screens and fields technical information
Daclare third internal table to handle errors in Call Transaction

SAP ABAP Material Soft copy

A.V. Krishna

+91 9704886510

krishna.saptrainer@gmail.com

Interview Questions :
Explain Architecture Software oriented view and User oriented view ?
Advantages of R/3 over R/2 architecture?
Explian 3 tier (or) 3 layr architecture?
What is Repository ? Explain Repository object features ?
Explain the functionality of message server, gateway server and enqueue server?
What are application server components ?
what are the work process components ?
Difference between open SQL and native SQL ?
What is ESOA , explain?

SAP ABAP Material Soft copy

Vous aimerez peut-être aussi