We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 361
About the Author
Ganapati Adimulam is an SAP Technical Consultant. Having nearly
Five years of Experience in the SAP Domain, several successful
implementation, and a background in training and technical documentation
has afforded him many opportunities to observe all aspects of SAP
implementation.
Mr. Ganapati did his M.C.A in 2002. He started his SAP career in
2003 March. He has worked for corporate giants like CGEY (CapGemini
Emest & Young), Infosys and Satyam Computers and also for many other
international clients as both onsite and off-shore Technical consultant.
As his basic interest is in SAP training domain, he has turned into SAP
training services after relieving from the corporate biggies. He is presently
offering excellent training services in SAP through eMax Technologies. He
is also a cynosure for imparting SAP training ‘to the corporate consultants.
He is a big talk among the corporate as a very good SAP corporate trainer.
From eMAX Technologies.ACKNOWLEDGEMENTS
Doing a book of this magnitude requies a team effort.
Every task is completely successful if and only if we acknowledge the effosts contributed
by the individual personnel.
We acknowledge our sincere thanks to our Honorable Director, eMax Technologies,
Mr. Rama Rao for his continuous guidance, support and co-operation throught this
project.
I want to take this opportunity to thank the entire management, beloved students and My
friend and Classmate Mr.Bhaskar and several other individuals of Max Technologies in
reviewing and assuring the quality checks of the accomplishments at every stage of this
project.
Finally I would like to extend my sincere thanks to my family members from the bottom
of my heart.
Ganapati Adimulam.ACE
Building the Career in SAP is not SO Difficult but it depends on two facts.
i.e. the place where you get trained and also how seriously you put your
efforts. Now a days, all the training centers improve the Quality in Training,
but there is No quality in the People who attend for the training. Le. Only 10
to 20 Percentage Trainees are serious and the rest is just passing the Time.
My Sincere advise is , Please think of SAP if you are really serious because
now a days the Competition is also High but as long as you put your Efforts
seriously, the Competition doesn’t matter.
This is book is Prepared Only to keep the ABAP trainees from Hyderabad in
mind,where the students don’t know much Exposure on the ADVANCED.
TOPICs Such as ABAP OBJETCs,ALVs,BADIs,BAPIs .... Because Now a
Days Learning ONLY the BASIC ABAP is not enough to work on ABAP .
Think Of ADVANCED Topics them think of Interview Calls.
It is brought into. Our notice, people are‘expetting the Material For Cross
Application, Thé Material is ready: Except ALE/EDI 1DOCs and I suggest
you to go for ALE/EDI Idoe by:Arvind Nagpaul , the best book for Cross
‘Apps and very soon I am going to add the Same If Possible.
Please forward yout. comments and _—_— suggestion —_to
[email protected] and also for further help in attending
interviews .
ALL THE BEST
Ganapati Adimulam.INDEX
1. ABAP OBJECTS ( 00-ABAP)
2. ENHANCEMENTS
a).Introudcution
b).customer Exists
c).BADI
3. BAPIs
4. ALV
a) Using Funetion Modules
b) Using ABAP Objects
1-134
01
1-47
1-60
1-112
1-44
1-70ABAP Objects(OQO-ABAP)
Duration -4Days(2Hrs)
Introduction to Object Orientation
OO-Concepts
= DATA Abstraction
= Encapsulation
= Inheritance
= Polymorphism
Working With Local Classes
= Define & Implement Classes
= Define & Implement
Methods
= Inheritance
= Interfaces
= Events
Working With Global Classes
= Define & Implement Classes
= Define & Implement Methods
= Inheritance
= InterfacesABAP Objects
We Never Compromise in Quality. Would You?
What is Object Orientation? DAY-1
Object orientation (0), or to be more precise, object-oriented programming, is a problem-solving
‘method in which the software solution reflects objects in the real world.
Definitions of Some Object Oriented Concepts (Terms).
Encapsulation: Objects restrict the visibility of their resources (attributes and methods) to other users.
Every object has an interface, which determines how other objects can interact with it, The
implementation of the object is encapsulated, that is, invisible outside the object itself
Classes : Class is a section af source code that contains data and provides services into a Single Unit.
The data forms the attributes and the services are known as methods (also known a5 operations or
functions). Typically, methods operate on private data (the atibtes, oF state of the object), which is
only visible to the methods of the Class. Thus the attributestof a cannot be changed directly by
the user, but only by the methods of the Class. This guaranteds the internal consistency of the
Ohio re"
<>,
Note:
ncapsulation is Supported through Classes.
Objects : From a technical point of view, objects are runtime instances of a class. you can create
any number of objects based on a single class. Each instance (object) of a class has a unique
identity and its own set of values for its attribute:
Polymorphism : Identical (identically-named) methods behave differently in different classes. Object
‘oriented programming contains constructions called interfaces. They enable you to address methods with
the same name in different objects, Although the form of address is always the same, the
implementation of the method is specific to a particular class.
Inheritance : You can use an existing class to derive a new class. Derived classes inherit the data and
methods of the superclass. However, they can overwrite existing methods, and also add new ones.
Uses of Object Orientation
as B
Below are. some of the advantages of object-oriented programming:
ee ee
Jeottware systems become easier to understand, since object-oriented
oud Fea fes a closer representation of reality than other programming techniques.
. In a well-designed object-oriented system, it should be possible to implement changes at
class level, without having to make alterations af other points in the system. This reduces the
overall amount of maintenance required.
. Through polymorphism and inheritance, object-oriented prograrvming allows you to
reuse individual components,
. In an object-oriented system, the amount of work involved in revising and maintaining the
system is reduced, since many problems can be detected and corrected in the design phase.
Page 1 of 134 Compiled By: Ganapati Adimulamn
‘Max Technologies, Ameerpet,Hyderabad
Ph No: +91 40 68976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.comABAP Objects
We Never Compromise in Quality. Would You?
What Is ABAP Objects? : asap onjects is a new concept in R/3 Release 4.0, The term has
two meanings. On the one hand, it stands for the entire ABAP runtime environment. On the other hand, it
represents the object-oriented extension ofthe ABAP language.
The Object-Oriented Language Extension: ABAP Objects is a complete set of object-oriented
statements that has been introduced into the ABAP ianguage. This object-oriented extension of ABAP
builds on the existing language, and is fully compatible with it, You can use ABAP Objects in existing
programs, and can also use "conventional" ABAP in new ABAP Objects programs.
ABAP Objects supports object-oriented programming. Object orientation (OO), also know as the
object-oriented paradigm, is a programming model that unites data and functions in objects. The rest,
of the ABAP language is primarily intended for structured programming, where data is stored in a
structured form in database tables and function-oriented programs access and work with it.
‘The object-oriented enhancement of ABAP is based on the models of Java and C++. Itis compatible with
external object interfaces such as DCOM and CORBA,
From Function Groups to Classes and Objects
At the ceniter-of any object-oriented model are-objects, which contain attributes (data) and
methods (functions): Objects .should enable programmers to map a feal problem and its proposed
software solution On @ one-to-onébasis. Typical objects in a business environment are, for example,
‘customer’, ‘Orde’, or invoice’ From Reléase 3.1 onwards, the Business Object Repository (BOR) has
contained examples of Such objects. The-object model of ABAP Obiects, the object-oriented extension of
ABAP, is compaiible with the object model of the BOR,
Before R/3 Release 4.0, the nearest equivalent of objects in ABAP were function modules and
function groups. Suppose we havé'a function group for processing orders. The attributes of an order
correspond to the global data of the function group, while the individual function modules represent
actions that manipulate that data (methods). This means thet the actual order data is encapsulated in
the function group, and is never directly addressed, but instead only through the function
modules. In this way, the function modules can ensure that the data is consistent.
‘The program cannot access the data in the function group directly, but only through the function
module, The function modules and their parameters are the interface between the function group
and the user.
The main difference between real object orientation and function groups is that although a
program can work with the instances of several function groups at the same time, it cannot work
with several instances of a single function group.
Page 2 of 134 Compiled By: Ganapati Adimulam
‘eMax Technologies,Ameerpet,fyderabad
Ph No: +91 40 65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.comABAP Objects
We Never Compromise in Quality. Would You ?
Note : Let Us Assume Either Increase / Decrease Speed is Always 1.
Function Group
Data : v_speed type I.
Funetion Modules :
Increase_Speed,
Decrease_Speed,
Display Speed.
Class
Methods
Increase_Speed,
Decrease Speed,
Display_Speed.
i i
eA iwavs Only One nsec Obiect! | [Obiec2 | [Lobiees |
CALL FUNCTION : Increase_Speed, CALL METHOD : Object! Increase_ Speed,
increase_Speed, Object2 Increase_Speed
Note : Here in the Function Groups, All the Function Modules Updates the Same Variables Where Using
Classes Each Object has it's Own Copy the Same Variable.
Conclusion : In One Program, We Cannot Have More than One Instance for the Same
Funetion Group, and We Can Have Any No Of Instances(Objects) for the Same Class in the
| Same Program.
fae
Classe 1 Clasgés are templates for objects. Conversely, you can say that the type of an object.
is the sam ad A class is an abstract description of an object. You could say that it is a set of
instructions for building’ an object. The attributes of objects are defined by the components of the class,
which describe the state and behavior of objects.
Local and Global Classes
lasses in ABAP Objects can be declared either globally or locally. You define global classes and
interfaces in the Class Builder (Transaction SE24) in the ABAP Workbench. They are stored centrally
in the class library in the 8/3 Repository. All of the ABAP programs in an R/3 System can access the
Page 3 of 134 Compiled By: Ganapati Adimulam
‘Max Technologies,Ameerpet,Ayderabad
Ph No: #91 40 -65976727, Cell No: 99484 44808, 98490 34399, wwABAP Objects
We Never Compromise in Quality. Would You ?
glotal classes. Local classes are defined within an ABAP program, Local classes and interfaces can only
be used in the program in which they are defined. When you use a class in an ABAP program, the system
first searches for 2 local class with the specified name. If it does not find one, it then looks for a global
class. Apart from the visibility question, there is no difference between using a global class and
using a local class.
Defining and Working With Local Classes
Local classes consist of ABAP source code, enclosed in the ABAP statements CLASS .. ENDCLASS. A
complete class definition consists of a declaration part and, if required, an implementation part. The
declaration part of a class is a statement block
CLASS DEFINITION
ENDCLASS.
It contains the declaration for all components (attributes, methods, events) of the ciass. When you define
local classes, the declaration part belongs to the global program data. You should therefore place itat the
teeginning of the program
If you declare methods in the declaration part of a class, you must also write an implementation part for it
This consists of a further statement block
CLASS IMPLEMENTATION,
ENDCLASS.
The
plementation part of a class contains the implementation of all methods of the class.
Structure of a Class
The following statements define the structure of a class.
. ‘class contains components
. Each comiponent is assigned to a visibility section
+ “\2.classes implement methods
The following sections describe the structure of classes in more detail
Class Components : The components of a class make up its contents. All components are declared
in the deciaration part of the class. The components define the attributes of the objects in a class. When
you define the class, each component is assigned to one of the three visibility sections, which define
the extemal interface of the class. All of the components of a class are visible within the class. All
Page 4 of 134 Compiled By: Ganapati Adimulam
‘Max Technologies,Ameerpet,llyderabad
91 40 -65976727, Cell No: 99484 44808, 98490 34399, www.emaxtech.com
PhNiABAP Objects
We Never Compromise in Quality. Would You?
components are in the same namespace. This means that all components of the class must have names
that are unique within the class.
‘There are two kinds of components in a class - those that exist separately for each object in the class,
and those that exist only once for the whole class, regardless of the number of instances. Instance-
specific components are known as instance components. Components that are not instance-specific are
called static components. 4
Components Of a Class : 4
‘Attributes : Attributes are internal data fields within a class that can have any ABAP'Matatype=The state
‘of an object is determined by the contents of its attributes. One kind of attribute i isthe reference variable.
Reference variables allow you to create and address objects. Reference variables can be defined in
classes, allowing you to access objects from within a class. %
Instance Attributes: The contents of ingfance attributes define the instance-spafilic state of an object.
‘You declare them using the DATA statement
Static Attibutes: The contents of = routes dete the sate ofthe ass thal is vad fra
instances ofthe cass. Static atibutel a for each class. You decare them using the CLASS-
Barmy see eich cs
All of the objects in a class can access its sta ibutes. If you change a static attribute in an
object, the changaiis visible in all other objects in theClass.
Methods: Methods are internal pro¢ cedures in a class that define the behavior of an object. They can
acceso al ofthe ates of cag hiallowe thom fo change the data content of an object. They
also have a parameter interface(IMPORTING,EXPOIRTING etc), with which users can supply them with
values when calling them and receive values back from them The private attributes of a class can
only be changed by metnotyp the same class.
“The definition and parameter interfaee%f a method is similar to that of function modules. You define a
method in the definition part a class and implement it in the implementation part using the
following processing block,”
“Method Implementation
METHOD