SlideShare a Scribd company logo
1 of 12
What is Object Orientation?

In the past, information systems used to be defined primarily by their functionality: Data and functions
were kept separate and linked together by means of input and output relations.

The object-oriented approach, however, focuses on objects that represent abstract or concrete things of
the real world. These objects are first defined by their character and their properties, which are
represented by their internal structure and their attributes (data). The behavior of these objects is
described by methods (functionality).

Comparison between Procedural and Object Oriented Programming

     Features         Procedure Oriented approach           Object Oriented approach


     Emphasis              Emphasis on tasks.             Emphasis on things that does
                                                                 those tasks.

  Modularization        Programs are divided into          Programs are organized into
                       smaller programs known as           classes and objects and the
                                functions.              functionalities are embedded into
                                                               methods of a class.
   Data security       Most of the functions share      Data can be hidden and cannot be
                               global data.               accessed by external sources.

    Extensibility          Relatively more time          New data and functions can be
                         consuming to modify for        easily added whenever necessary.
                            extending existing
                               functionality.




Object Oriented Approach - key features

    1.    Better Programming Structure.
    2.    Real world entity can be modeled very well.
    3.    Stress on data security and access.
    4.    Reduction in code redundancy.
    5.    Data encapsulation and abstraction.

Objects

An object is a section of source code that contains data and provides services. The data forms the attributes of
the object. The services are known as methods (also known as operations or functions). They form a capsule
which combines the character to the respective behavior. Objects should enable programmers to map a real
problem and its proposed software solution on a one-to-one basis.

Classes

Classes describe objects. From a technical point of view, objects are runtime instances of a class. In theory,
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 attributes.
Local and Global Classes

As mentioned earlier a class is an abstract description of an object. Classes in ABAP Objects can be declared
either globally or locally.

Global Class

Global classes and interfaces are defined in the Class Builder (Transaction SE24) in the ABAP Workbench.
They are stored centrally in class pools in the class library in the R/3 Repository. All of the ABAP programs in
an R/3 System can access the global classes

Local Class

Local classes are define in an ABAP program (Transaction SE38) and can only be used in the program in
which they are defined.

                                Global Class                        Local Class

Accessed By                     Any program            Only the program where it is defined.

   Stored In               In the Class Repository    Only in the program where it is defined.

 Created By          Created using transaction SE24            Created using SE38

 Namespace                 Must begin with Y or Z          Can begin with any character


Local Classes

Every class will have two sections.

       (1)   Definition.

       (2)   Implementation.

Definition

This section is used to declare the components of the classes such as attributes, methods, events .They
are enclosed in the ABAP statements CLASS ... ENDCLASS.

CLASS <class> DEFINITION.

....
....

ENDCLASS.

Implementation

This section of a class contains the implementation of all methods of the class. The implementation part
of a local class is a processing block.
CLASS <class> IMPLEMENTATION.

...
...

ENDCLASS.

Structure of a Class

The following statements define the structure of a class:

      1.   A class contains components.
      2.   Each component is assigned to a visibility section.
      3.   Classes implement methods.

1. Components of a Class are as follow:

           Attributes: Any data, constants, types declared within a class form the attribute of the class.

           Methods: Block of code, providing some functionality offered by the class. Can be compared to
           function modules. They can access all of the attributes of a class.

           Methods are defined in the definition part of a class and implement it in the implementation part
           using the following processing block:
           METHOD <meth>.

              ...

             ENDMETHOD.

           Methods are called using the CALL METHOD statement.

           Events:    A mechanism set within a class which can help a class to trigger methods of other
           class.

           Interfaces: Interfaces are independent structures that you can implement in a class to extend
           the scope of that class.


           Instance and Static Components:

           Instance components exist separately in each instance (object) of the class and are referred
           using instance component selector using ‘’.

           Static components only exist once per class and are valid for all instances of the class. They are
           declared with the CLASS- keywords.

           Static components can be used without even creating an instance of the class and are referred to
           using static component selector ‘=>’.
2. Visibility of Components

       Data declared in public section can be accessed by the class itself, by its subclasses as well as
       by other users outside the class.

       Data declared in the protected section can be accessed by the class itself, and also by its
       subclasses but not by external users outside the class.

       Data declared in the private section can be accessed by the class only, but not by its subclasses
       and by external users outside the class.

           CLASS <class> DEFINITION.

             PUBLIC SECTION.

               ...

              PROTECTED SECTION.

               ...

              PRIVATE SECTION.

              ...
            ENDCLASS.

   Example on Visibility of Components
The yellow block of code is CLASS Definition

    The Green block of code is CLASS Implementation

    The Grey block of code is for object creation. This object creation includes two steps:

     Step1: is Create a reference variable with reference to the class.

       Syntax: DATA : <object name> TYPE REF TO <class name>.

     Step 2: Create an object from the reference variable:-

       Syntax: CREATE OBJECT <object name> .

    Output for the above code is




Attributes of Object Oriented Programming

        Inheritance.
        Abstraction.
        Encapsulation.
        Polymorphism

Inheritance

Inheritance is the concept of adopting the features from the parent and reusing them. It involves passing the
behavior of a class to another class. You can use an existing class to derive a new class. Derived classes
inherit the data and methods of the super class. However, they can overwrite existing methods, and also add
new ones.

Inheritance is of two types:

1) Single Inheritance

2) Multiple Inheritance
Single Inheritance

Single Inheriting: Acquiring the properties from a single parent. (Children can be more).




                                    Example for Single Inheritance

Multiple inheritance

Acquiring the properties from more than one parent.

Example

Tomato4 (Best Color, Size, Taste)

Tomato1 (Best Color)

Tomato2 (Best Size)

Tomato3 (Best Tast)




Syntax: CLASS <subclass> DEFINITION INHERITING FROM <superclass>.
Let us see a very simple example for creating subclass(child) from a superclass(parent)




Multiple Inheritance is not supported by ABAP.

Output is as follows:
Abstraction: Everything is visualized in terms of classes and objects.

Encapsulation The wrapping up of data and methods into a single unit (called class) is known as
Encapsulation. The data is not accessible to the outside world only those methods, which are wrapped in
the class, can access it.

Polymorphism: Methods of same name behave differently in different classes. 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.




Sample Program for Local Class.

TABLES: RBKP,
       RSEG.

TYPES: BEGIN OF TY_RSEG,
       BELNR TYPE RE_BELNR,
      BUZEI TYPE RBLGP,
      MATNR TYPE MATNR,
      MENGE TYPE MENGE_D,
      END OF TY_RSEG.

SELECT-OPTIONS: INVOICE FOR RBKP-BELNR.

CLASS CL DEFINITION.
 PUBLIC SECTION.
 METHODS: GETDATA IMPORTING IRLOW TYPE RE_BELNR
                           IRHIGH TYPE RE_BELNR,
           DISPLAYDATA.

 DATA: WA TYPE TY_RSEG,
      ITAB TYPE STANDARD TABLE OF TY_RSEG.

ENDCLASS.

CLASS CL IMPLEMENTATION.
 METHOD GETDATA.
  SELECT BELNR
     BUZEI
     MATNR
     MENGE FROM RSEG
     INTO TABLE ITAB
     WHERE BELNR BETWEEN IRLOW AND IRHIGH.

 ENDMETHOD.

 METHOD DISPLAYDATA.
  IF NOT ITAB[] IS INITIAL.
  SORT ITAB[] BY BELNR.
  LOOP AT ITAB[] INTO WA.
   WRITE:/ WA-BELNR,
WA-BUZEI,
       WA-MATNR,
       WA-MENGE.
  ENDLOOP.
  ENDIF.
 ENDMETHOD.
ENDCLASS.

DATA: OBJ TYPE REF TO CL.
START-OF-SELECTION.
CREATE OBJECT OBJ.
CALL METHOD OBJ->GETDATA
EXPORTING
 IRLOW = INVOICE-LOW
 IRHIGH = INVOICE-HIGH.
CALL METHOD OBJ->DISPLAYDATA.




Reference:

http://www.saptechnical.com/Tutorials/OOPS/Concepts/page1.htm

http://wiki.sdn.sap.com/wiki/display/ABAP/Object+Oriented

http://wiki.sdn.sap.com/wiki/display/ABAP/Object+Oriented+ABAP+%28OO-ABAP%29

http://wiki.sdn.sap.com/wiki/display/ABAP/Polymorphism+using+OO+ABAP




http://forums.sdn.sap.com/thread.jspa?threadID=728250

http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm




http://help.sap.com/saphelp_46c/helpdata/EN/87/56d00722c011d2954a0000e8353423/content.ht
m#U--------------------------------------------SAP COMMANDS



Questions on OO ABAP

1.   Principles of oops?
2.   What is difference between procedural & OO Programming?
3.   What is class?
4.   What is object?
5.   Can we instantiate a class within implementation of other class?
6.   What is deferred key word?
7. How we can refer to a class without defining it?
8. Can we put non declarative statement e.g. START-OF-SELECTION within a class
9. What is static attribute & method?

10. How to create a global class?
11. How can we pass importing parameter? Pass by value/pass by reference
13. Can we changed pass by reference in any method?
14. What is preferred parameter? more than one optional & no mandatory
15. Can we pass returing parameter by reference? NO only pass by value
16. Can static method use instance attribute ?
17. Can a method call itself?
18. What is me variable?
19. What is constructor? What are types of constructor? When it is called?
20. Can we have export parameter in Instance constructor?
21. Can instance constructor raise exception?
22. When static constructor is called?
23. Can we have interface for static class or constructor?
24. What is abstract class?
25. Can we implement abstract method in abstract class? If not then where it can be
implemented?
26. What is final class & Method?
27. Can subclass call super class constructor?
28. Can we call static constructor more than once in a program?
29. What is method redefinition?
30. What is interface?
31. Can we implement interface in private section of any class?
32. Is it mandatory to implement all the methods of interface?
33. What is alias? Instead of specifying full name of interface methods we can assign it a name
which can directly trigger.
34. What is Friendship?
35. What is event handler method?
36. Can we have more than one event handler method for same event?
37. Can event have import parameter?
38. How you handled exception during programming?
39. What is cleanup section?
40. What is BADI?
41. What is check box for multiple usse in BADI?
42. How to search a BADI ?
43. What is Value table and Check table, Difference between them?
44. What are secondary index’s?
45. What is the draw back of secondary index’s?
46. What are conversion routines?
47. At which level are they mantained?
48. what are Predeifined data types?
49. Which predefined data type uses conversion routines?
50. What are logical units of work?
51. When is difference btw native and open sql
52. Difference between Modify and Update
53. Which is more efficient for all entries or joins?
54. When is implicit commit triggered.
55. What are RFC?
56. How do u create a destination system?
57. What are different types of commits used?
58. What are search helps?
59. Types of tables?
60. Difference between pool tables and cluster tables?
61. What is a delivery class?
62. What are the types of delivery class?
63. Difference between System tables and control tables?
64. What is normalization?
65. What is BCNF?
66. What is persistant class?



http://wiki.sdn.sap.com/wiki/display/Snippets/Binding+in+ABAP+OOP

http://www.saptechnical.com/Tutorials/OOPS/Binding/Procedure.htm

http://www.scribd.com/doc/35821441/Ooabap-Examples-------------***************



Difference between static and instance variables
Static attributes:

    1.   The attributes are created only once.
    2.   That means memory allocation for the attribute is only once.
    3.   We can call next time the same attribute by using object then the same memory space is referred.
    4.   We can change the value in the memory.

Instance attributes:

    1.   These attributes are created for every time.
    2.   That means for each and every call statement, the attribute creates a new memory location at every
         time.

Go to SE38 and create the following program.

*&---------------------------------------------------------------------*
*& Report ZLOCALCLASS_VARIABLES                                        *
*&                                                                     *
*&---------------------------------------------------------------------*
*&      By                                                             *
*&         Vikram.C for SAPTechnical.COM                               *
*&---------------------------------------------------------------------*
REPORT ZLOCALCLASS_VARIABLES.
*General local class by using static and instance.
*Define the class
CLASS CL_LC DEFINITION.
PUBLIC SECTION.
DATA: A TYPE I VALUE 10.
CLASS-DATA: B TYPE I VALUE 20.
METHODS DISPLAY.
CLASS-METHODS DISP.
ENDCLASS.
*Implement the class
CLASS CL_LC IMPLEMENTATION.
METHOD DISPLAY.
WRITE:/ 'IT IS INSTANCE METHOD',
      / 'INSTANCE VARIABLE = ', A.
ENDMETHOD.
METHOD DISP.
WRITE:/ 'IT IS STATIC METHOD' COLOR 2,
      / 'STATIC VARIABLE = ', B COLOR 2.
ENDMETHOD.
ENDCLASS.
*Create the object
DATA OBJ TYPE REF TO CL_LC.
START-OF-SELECTION.
CREATE OBJECT OBJ.
*Call the instance method
CALL METHOD OBJ->DISPLAY.
*Call the static method.
CALL METHOD CL_LC=>DISP.


Save it, check it, activate it after that execute it.

Then the output is like this.

More Related Content

What's hot

1000 solved questions
1000 solved questions1000 solved questions
1000 solved questions
Kranthi Kumar
 
Ooabap notes with_programs
Ooabap notes with_programsOoabap notes with_programs
Ooabap notes with_programs
Kranthi Kumar
 
Enhancement framework the new way to enhance your abap systems
Enhancement framework   the new way to enhance your abap systemsEnhancement framework   the new way to enhance your abap systems
Enhancement framework the new way to enhance your abap systems
Kranthi Kumar
 

What's hot (20)

BRF+ Walk through
BRF+ Walk throughBRF+ Walk through
BRF+ Walk through
 
1000 solved questions
1000 solved questions1000 solved questions
1000 solved questions
 
SAP ABAP using OOPS - JH Softech
SAP ABAP using OOPS - JH SoftechSAP ABAP using OOPS - JH Softech
SAP ABAP using OOPS - JH Softech
 
SAP Modularization techniques
SAP Modularization techniquesSAP Modularization techniques
SAP Modularization techniques
 
Field symbols
Field symbolsField symbols
Field symbols
 
SAP Flexible workflows.pptx
SAP Flexible workflows.pptxSAP Flexible workflows.pptx
SAP Flexible workflows.pptx
 
Ooabap notes with_programs
Ooabap notes with_programsOoabap notes with_programs
Ooabap notes with_programs
 
OOPS ABAP.docx
OOPS ABAP.docxOOPS ABAP.docx
OOPS ABAP.docx
 
ABAP Programming Overview
ABAP Programming OverviewABAP Programming Overview
ABAP Programming Overview
 
Enhancement framework the new way to enhance your abap systems
Enhancement framework   the new way to enhance your abap systemsEnhancement framework   the new way to enhance your abap systems
Enhancement framework the new way to enhance your abap systems
 
VOFM Routine
VOFM RoutineVOFM Routine
VOFM Routine
 
Abap data dictionary
Abap data dictionaryAbap data dictionary
Abap data dictionary
 
SAP Smart forms
SAP Smart formsSAP Smart forms
SAP Smart forms
 
CDS Views.pptx
CDS Views.pptxCDS Views.pptx
CDS Views.pptx
 
SAP data archiving
SAP data archivingSAP data archiving
SAP data archiving
 
HANA WITH ABAP OVERVIEW
HANA WITH ABAP OVERVIEWHANA WITH ABAP OVERVIEW
HANA WITH ABAP OVERVIEW
 
Abap hr programing
Abap hr programingAbap hr programing
Abap hr programing
 
SAP Document Management System Integration with Content Servers
SAP Document Management System Integration with Content Servers SAP Document Management System Integration with Content Servers
SAP Document Management System Integration with Content Servers
 
SAP S/4HANA Cloud
SAP S/4HANA CloudSAP S/4HANA Cloud
SAP S/4HANA Cloud
 
Technical Overview of CDS View - SAP HANA Part II
Technical Overview of CDS View - SAP HANA Part IITechnical Overview of CDS View - SAP HANA Part II
Technical Overview of CDS View - SAP HANA Part II
 

Similar to Object oriented basics

oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
ArpitaJana28
 
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
AnkurSingh340457
 
Application package
Application packageApplication package
Application package
JAYAARC
 

Similar to Object oriented basics (20)

Oops
OopsOops
Oops
 
Oops concepts
Oops conceptsOops concepts
Oops concepts
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
 
Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1
 
My c++
My c++My c++
My c++
 
Oops
OopsOops
Oops
 
Php oop (1)
Php oop (1)Php oop (1)
Php oop (1)
 
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
 
JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
 
python.pptx
python.pptxpython.pptx
python.pptx
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
 
12th ip CBSE chapter 4 oop in java notes complete
12th ip CBSE  chapter 4 oop in java notes complete12th ip CBSE  chapter 4 oop in java notes complete
12th ip CBSE chapter 4 oop in java notes complete
 
Oops
OopsOops
Oops
 
Application package
Application packageApplication package
Application package
 
Object Oriented Javascript part2
Object Oriented Javascript part2Object Oriented Javascript part2
Object Oriented Javascript part2
 
Objectorientedprogrammingmodel1
Objectorientedprogrammingmodel1Objectorientedprogrammingmodel1
Objectorientedprogrammingmodel1
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Review oop and ood
Review oop and oodReview oop and ood
Review oop and ood
 
Lab 4 (1).pdf
Lab 4 (1).pdfLab 4 (1).pdf
Lab 4 (1).pdf
 
OOSD1-unit1_1_16_09.pptx
OOSD1-unit1_1_16_09.pptxOOSD1-unit1_1_16_09.pptx
OOSD1-unit1_1_16_09.pptx
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 

Object oriented basics

  • 1. What is Object Orientation? In the past, information systems used to be defined primarily by their functionality: Data and functions were kept separate and linked together by means of input and output relations. The object-oriented approach, however, focuses on objects that represent abstract or concrete things of the real world. These objects are first defined by their character and their properties, which are represented by their internal structure and their attributes (data). The behavior of these objects is described by methods (functionality). Comparison between Procedural and Object Oriented Programming Features Procedure Oriented approach Object Oriented approach Emphasis Emphasis on tasks. Emphasis on things that does those tasks. Modularization Programs are divided into Programs are organized into smaller programs known as classes and objects and the functions. functionalities are embedded into methods of a class. Data security Most of the functions share Data can be hidden and cannot be global data. accessed by external sources. Extensibility Relatively more time New data and functions can be consuming to modify for easily added whenever necessary. extending existing functionality. Object Oriented Approach - key features 1. Better Programming Structure. 2. Real world entity can be modeled very well. 3. Stress on data security and access. 4. Reduction in code redundancy. 5. Data encapsulation and abstraction. Objects An object is a section of source code that contains data and provides services. The data forms the attributes of the object. The services are known as methods (also known as operations or functions). They form a capsule which combines the character to the respective behavior. Objects should enable programmers to map a real problem and its proposed software solution on a one-to-one basis. Classes Classes describe objects. From a technical point of view, objects are runtime instances of a class. In theory, 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 attributes.
  • 2. Local and Global Classes As mentioned earlier a class is an abstract description of an object. Classes in ABAP Objects can be declared either globally or locally. Global Class Global classes and interfaces are defined in the Class Builder (Transaction SE24) in the ABAP Workbench. They are stored centrally in class pools in the class library in the R/3 Repository. All of the ABAP programs in an R/3 System can access the global classes Local Class Local classes are define in an ABAP program (Transaction SE38) and can only be used in the program in which they are defined. Global Class Local Class Accessed By Any program Only the program where it is defined. Stored In In the Class Repository Only in the program where it is defined. Created By Created using transaction SE24 Created using SE38 Namespace Must begin with Y or Z Can begin with any character Local Classes Every class will have two sections. (1) Definition. (2) Implementation. Definition This section is used to declare the components of the classes such as attributes, methods, events .They are enclosed in the ABAP statements CLASS ... ENDCLASS. CLASS <class> DEFINITION. .... .... ENDCLASS. Implementation This section of a class contains the implementation of all methods of the class. The implementation part of a local class is a processing block.
  • 3. CLASS <class> IMPLEMENTATION. ... ... ENDCLASS. Structure of a Class The following statements define the structure of a class: 1. A class contains components. 2. Each component is assigned to a visibility section. 3. Classes implement methods. 1. Components of a Class are as follow: Attributes: Any data, constants, types declared within a class form the attribute of the class. Methods: Block of code, providing some functionality offered by the class. Can be compared to function modules. They can access all of the attributes of a class. Methods are defined in the definition part of a class and implement it in the implementation part using the following processing block: METHOD <meth>. ... ENDMETHOD. Methods are called using the CALL METHOD statement. Events: A mechanism set within a class which can help a class to trigger methods of other class. Interfaces: Interfaces are independent structures that you can implement in a class to extend the scope of that class. Instance and Static Components: Instance components exist separately in each instance (object) of the class and are referred using instance component selector using ‘’. Static components only exist once per class and are valid for all instances of the class. They are declared with the CLASS- keywords. Static components can be used without even creating an instance of the class and are referred to using static component selector ‘=>’.
  • 4. 2. Visibility of Components Data declared in public section can be accessed by the class itself, by its subclasses as well as by other users outside the class. Data declared in the protected section can be accessed by the class itself, and also by its subclasses but not by external users outside the class. Data declared in the private section can be accessed by the class only, but not by its subclasses and by external users outside the class. CLASS <class> DEFINITION. PUBLIC SECTION. ... PROTECTED SECTION. ... PRIVATE SECTION. ... ENDCLASS. Example on Visibility of Components
  • 5. The yellow block of code is CLASS Definition The Green block of code is CLASS Implementation The Grey block of code is for object creation. This object creation includes two steps: Step1: is Create a reference variable with reference to the class. Syntax: DATA : <object name> TYPE REF TO <class name>. Step 2: Create an object from the reference variable:- Syntax: CREATE OBJECT <object name> . Output for the above code is Attributes of Object Oriented Programming Inheritance. Abstraction. Encapsulation. Polymorphism Inheritance Inheritance is the concept of adopting the features from the parent and reusing them. It involves passing the behavior of a class to another class. You can use an existing class to derive a new class. Derived classes inherit the data and methods of the super class. However, they can overwrite existing methods, and also add new ones. Inheritance is of two types: 1) Single Inheritance 2) Multiple Inheritance
  • 6. Single Inheritance Single Inheriting: Acquiring the properties from a single parent. (Children can be more). Example for Single Inheritance Multiple inheritance Acquiring the properties from more than one parent. Example Tomato4 (Best Color, Size, Taste) Tomato1 (Best Color) Tomato2 (Best Size) Tomato3 (Best Tast) Syntax: CLASS <subclass> DEFINITION INHERITING FROM <superclass>.
  • 7. Let us see a very simple example for creating subclass(child) from a superclass(parent) Multiple Inheritance is not supported by ABAP. Output is as follows:
  • 8. Abstraction: Everything is visualized in terms of classes and objects. Encapsulation The wrapping up of data and methods into a single unit (called class) is known as Encapsulation. The data is not accessible to the outside world only those methods, which are wrapped in the class, can access it. Polymorphism: Methods of same name behave differently in different classes. 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. Sample Program for Local Class. TABLES: RBKP, RSEG. TYPES: BEGIN OF TY_RSEG, BELNR TYPE RE_BELNR, BUZEI TYPE RBLGP, MATNR TYPE MATNR, MENGE TYPE MENGE_D, END OF TY_RSEG. SELECT-OPTIONS: INVOICE FOR RBKP-BELNR. CLASS CL DEFINITION. PUBLIC SECTION. METHODS: GETDATA IMPORTING IRLOW TYPE RE_BELNR IRHIGH TYPE RE_BELNR, DISPLAYDATA. DATA: WA TYPE TY_RSEG, ITAB TYPE STANDARD TABLE OF TY_RSEG. ENDCLASS. CLASS CL IMPLEMENTATION. METHOD GETDATA. SELECT BELNR BUZEI MATNR MENGE FROM RSEG INTO TABLE ITAB WHERE BELNR BETWEEN IRLOW AND IRHIGH. ENDMETHOD. METHOD DISPLAYDATA. IF NOT ITAB[] IS INITIAL. SORT ITAB[] BY BELNR. LOOP AT ITAB[] INTO WA. WRITE:/ WA-BELNR,
  • 9. WA-BUZEI, WA-MATNR, WA-MENGE. ENDLOOP. ENDIF. ENDMETHOD. ENDCLASS. DATA: OBJ TYPE REF TO CL. START-OF-SELECTION. CREATE OBJECT OBJ. CALL METHOD OBJ->GETDATA EXPORTING IRLOW = INVOICE-LOW IRHIGH = INVOICE-HIGH. CALL METHOD OBJ->DISPLAYDATA. Reference: http://www.saptechnical.com/Tutorials/OOPS/Concepts/page1.htm http://wiki.sdn.sap.com/wiki/display/ABAP/Object+Oriented http://wiki.sdn.sap.com/wiki/display/ABAP/Object+Oriented+ABAP+%28OO-ABAP%29 http://wiki.sdn.sap.com/wiki/display/ABAP/Polymorphism+using+OO+ABAP http://forums.sdn.sap.com/thread.jspa?threadID=728250 http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm http://help.sap.com/saphelp_46c/helpdata/EN/87/56d00722c011d2954a0000e8353423/content.ht m#U--------------------------------------------SAP COMMANDS Questions on OO ABAP 1. Principles of oops? 2. What is difference between procedural & OO Programming? 3. What is class? 4. What is object? 5. Can we instantiate a class within implementation of other class? 6. What is deferred key word?
  • 10. 7. How we can refer to a class without defining it? 8. Can we put non declarative statement e.g. START-OF-SELECTION within a class 9. What is static attribute & method? 10. How to create a global class? 11. How can we pass importing parameter? Pass by value/pass by reference 13. Can we changed pass by reference in any method? 14. What is preferred parameter? more than one optional & no mandatory 15. Can we pass returing parameter by reference? NO only pass by value 16. Can static method use instance attribute ? 17. Can a method call itself? 18. What is me variable? 19. What is constructor? What are types of constructor? When it is called? 20. Can we have export parameter in Instance constructor? 21. Can instance constructor raise exception? 22. When static constructor is called? 23. Can we have interface for static class or constructor? 24. What is abstract class? 25. Can we implement abstract method in abstract class? If not then where it can be implemented? 26. What is final class & Method? 27. Can subclass call super class constructor? 28. Can we call static constructor more than once in a program? 29. What is method redefinition? 30. What is interface? 31. Can we implement interface in private section of any class? 32. Is it mandatory to implement all the methods of interface? 33. What is alias? Instead of specifying full name of interface methods we can assign it a name which can directly trigger. 34. What is Friendship? 35. What is event handler method? 36. Can we have more than one event handler method for same event? 37. Can event have import parameter? 38. How you handled exception during programming? 39. What is cleanup section? 40. What is BADI? 41. What is check box for multiple usse in BADI? 42. How to search a BADI ? 43. What is Value table and Check table, Difference between them? 44. What are secondary index’s? 45. What is the draw back of secondary index’s? 46. What are conversion routines? 47. At which level are they mantained? 48. what are Predeifined data types? 49. Which predefined data type uses conversion routines? 50. What are logical units of work?
  • 11. 51. When is difference btw native and open sql 52. Difference between Modify and Update 53. Which is more efficient for all entries or joins? 54. When is implicit commit triggered. 55. What are RFC? 56. How do u create a destination system? 57. What are different types of commits used? 58. What are search helps? 59. Types of tables? 60. Difference between pool tables and cluster tables? 61. What is a delivery class? 62. What are the types of delivery class? 63. Difference between System tables and control tables? 64. What is normalization? 65. What is BCNF? 66. What is persistant class? http://wiki.sdn.sap.com/wiki/display/Snippets/Binding+in+ABAP+OOP http://www.saptechnical.com/Tutorials/OOPS/Binding/Procedure.htm http://www.scribd.com/doc/35821441/Ooabap-Examples-------------*************** Difference between static and instance variables Static attributes: 1. The attributes are created only once. 2. That means memory allocation for the attribute is only once. 3. We can call next time the same attribute by using object then the same memory space is referred. 4. We can change the value in the memory. Instance attributes: 1. These attributes are created for every time. 2. That means for each and every call statement, the attribute creates a new memory location at every time. Go to SE38 and create the following program. *&---------------------------------------------------------------------* *& Report ZLOCALCLASS_VARIABLES * *& * *&---------------------------------------------------------------------*
  • 12. *& By * *& Vikram.C for SAPTechnical.COM * *&---------------------------------------------------------------------* REPORT ZLOCALCLASS_VARIABLES. *General local class by using static and instance. *Define the class CLASS CL_LC DEFINITION. PUBLIC SECTION. DATA: A TYPE I VALUE 10. CLASS-DATA: B TYPE I VALUE 20. METHODS DISPLAY. CLASS-METHODS DISP. ENDCLASS. *Implement the class CLASS CL_LC IMPLEMENTATION. METHOD DISPLAY. WRITE:/ 'IT IS INSTANCE METHOD', / 'INSTANCE VARIABLE = ', A. ENDMETHOD. METHOD DISP. WRITE:/ 'IT IS STATIC METHOD' COLOR 2, / 'STATIC VARIABLE = ', B COLOR 2. ENDMETHOD. ENDCLASS. *Create the object DATA OBJ TYPE REF TO CL_LC. START-OF-SELECTION. CREATE OBJECT OBJ. *Call the instance method CALL METHOD OBJ->DISPLAY. *Call the static method. CALL METHOD CL_LC=>DISP. Save it, check it, activate it after that execute it. Then the output is like this.