‎2007 Apr 16 7:00 AM
Hi Gurus,
I want to know thw difference between objectoriented program and abap general programme?
thanks in advance
‎2007 Apr 16 7:07 AM
Hi Rama Krishna ,
Object Orientation
A programming technique in which solutions reflect real world objects
What are objects ?
An object is an instantiation of a class. E.g. If Animal is a class, A cat
can be an object of that class .
With respect to code, Object refers to a set of services ( methods /
attributes ) and can contain data
What are classes ?
A class defines the properties of an object. A class can be instantiated
as many number of times
Advantages of Object Orientated approach
Easier to understand when the system is complex
Easy to make changes
Encapsulation - Can restrict the visibility of the data ( Restrict the access to the data )
Polymorphism - Identically named methods behave differently in different classes
Inheritance - You can use an existing class to define a new class
Polymorphism and inheritance lead to code reuse
Classes in abap
Classes in ABAP are either local or global
Global classes are declared in class builder (SE24 )
Local classes are declared within programs
Components of a class
Attributes : Internal data fields of class
Attributes can be either instance attributes specific to each instance of the class ( object ) or static attributes which are common to all instances
Methods :
Subroutines / procedures in a class that define the behavior of the object. Methods can also be instance methods or static methods
Encapsulation in ABAP
Encapsulation is obtained through the restriction in visibility of attributes / methods attained through the definition of Public, Private and Protected section of a class
Public Section
All of the components declared in the public section are accessible to all users of the class, and to the methods of the class and any classes that inherit from it. The public components of the class form the interface between the class and its users.
Protected Section
All of the components declared in the protected section are accessible to all methods of the class and of classes that inherit from it.
Private Section
Components that you declare in the private section are only visible in the methods of the same class.
Inheritance in ABAP
Inheritance allows you to derive a class based on an already existing class.
CLASS <subclass> DEFINITION INHERITING FROM <superclass>.
..
ENDCLASS.
CLASS <subclass> IMPLEMENTATION.
ENDCLASS.
All attributes / methods of super class become the property of the subclass too. Only public and protected attributes / methods are visible in the subclass
Polymorphism in ABAP
When methods with same name perform differently under different
circumstances we call it polymorphism.
Methods redefined in a subclass is an example for Polymorphism
Interfaces
Interfaces are used to define the model of a class.
They also like classes can be either local or global.
Global interfaces are defined through SE24 and local interfaces are defined in program.
Please check this online document (starting page 1291).
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf
Also check this links as well.
http://help.sap.com/saphelp_nw2004s/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
http://www.sapgenie.com/abap/OO/
http://www.futureobjects.de/content/intro_oo_e.html
http://www.sap-img.com/abap/business-add-in-you-need-to-understand-abap-oo-interface-concept.htm
/people/ravikumar.allampallam/blog/2005/02/11/abap-oo-in-action
check the below links lot of info and examples r there
http://www.sapgenie.com/abap/OO/index.htm
http://www.geocities.com/victorav15/sapr3/abap_ood.html
http://www.brabandt.de/html/abap_oo.html
Check this cool weblog:
/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
Hope this resolves your query.
Reward all the helpful answers.
Thanks & Regards
Bhaskar rao.M
‎2007 Apr 16 7:09 AM
Normal report adn Dialogue programs are event driven whereas the object oriented programming is based on OOPS principles of Data hiding and encapsulation, inheritance, polymorphism