Oo abap-sap-1206973306636228-5


Published on

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Oo abap-sap-1206973306636228-5

  1. 1. Object Oriented ABAP Hyderabad February 24-26th 2006 Instructor: Subhas Katikala.
  2. 2. Workshop Goals This workshop will enable you to: <ul><li>Learn object – oriented concepts. </li></ul><ul><li>Learn the principle of object - oriented programming. </li></ul><ul><li>Learn the application of object </li></ul><ul><li>- oriented ABAP. </li></ul>
  3. 3. Course Contents Object Oriented Concepts Object Oriented Programming. Advantages of the Object-Oriented Approach <ul><li>Methods </li></ul><ul><li>Syntax and Visibility </li></ul><ul><li>Instance Methods and Static Methods </li></ul><ul><li>Constructor </li></ul><ul><li>Reference Variables </li></ul><ul><li>Creating References </li></ul><ul><li>Assigning References </li></ul><ul><li>Classes </li></ul><ul><li>Components of a Class </li></ul><ul><li>Attributes </li></ul><ul><li>Syntax and Visibility </li></ul><ul><li>Instance Attributes and Static Attributes </li></ul>
  4. 4. Course Contents <ul><li>Inheritance </li></ul><ul><li>Super classes and Subclasses </li></ul><ul><li>Visibility </li></ul><ul><li>Inheritance and the (Instance) Constructor </li></ul><ul><li>Parameters </li></ul><ul><li>Redefining Methods in OOABAP </li></ul><ul><li>Compatibility </li></ul><ul><li>Principles of the Narrowing Cast </li></ul><ul><li>Static and Dynamic Components </li></ul><ul><li>Final Classes and Methods </li></ul>
  5. 5. Course Contents <ul><li>Polymorphism </li></ul><ul><li>Advantages Compared to Procedural Programming </li></ul><ul><li>Abstract Classes and Methods </li></ul><ul><li>Component Namespaces in Classes </li></ul><ul><li>Interfaces </li></ul><ul><li>Defining and Implementing an Interface </li></ul><ul><li>Working with Interface Components </li></ul><ul><li>Interface References </li></ul><ul><ul><li>Narrowing Cast </li></ul></ul><ul><ul><li>Widening Cast </li></ul></ul><ul><li>Using Several Interfaces </li></ul><ul><li>Polymorphism and Interfaces </li></ul><ul><li>Polymorphism and Inheritance </li></ul><ul><li>Compound Interfaces </li></ul>
  6. 6. Course Contents <ul><li>Events </li></ul><ul><li>Define and Trigger Events </li></ul><ul><li>Handle Events </li></ul><ul><li>Register and deregister Events </li></ul><ul><li>Receive a reference from Sender </li></ul>
  7. 7. Object – Oriented Concepts What are Objects ?
  8. 8. <ul><li>Object Oriented Programming </li></ul><ul><li>Encapsulation </li></ul><ul><li>Inheritance </li></ul><ul><li>Polymorphism </li></ul><ul><li>Instantiation </li></ul><ul><li>Interfacing </li></ul><ul><li>Events </li></ul>OOPS
  9. 9. <ul><li>Advantages </li></ul><ul><li>Simplicity </li></ul><ul><li>Explicitness </li></ul><ul><li>Maintainability </li></ul><ul><li>Future Orientation </li></ul>
  10. 10. <ul><li>Classes are the central element of object-orientation. </li></ul><ul><li>A Class is an abstract description of an object. </li></ul><ul><li>Classes are templates for objects. </li></ul><ul><li>The attributes of objects are defined by the components of the class, which describe the state and behavior of objects. </li></ul>Classes
  11. 11. <ul><li>You define global classes and interfaces in the Class Builder (Transaction SE24) in the ABAP Workbench. </li></ul><ul><li>They are stored centrally in class pools in the class library in the R/3 Repository. </li></ul><ul><li>All of the ABAP programs in an R/3 System can access the global classes. </li></ul>Classes
  12. 12. Components in a class
  13. 13. Defining Local Classes <ul><li>A complete class definition consists of a declaration part and, if required, an implementation part. </li></ul><ul><li>The declaration part of a class <class> is a statement block: </li></ul><ul><ul><li>CLASS c1 DEFINITION.   </li></ul></ul><ul><ul><li>… .  </li></ul></ul><ul><ul><li>ENDCLASS. </li></ul></ul><ul><li>If you declare methods in the declaration part of a class, you must also write an implementation part for it. </li></ul><ul><li> CLASS c1 IMPLEMENTATION. </li></ul><ul><li> … .   ENDCLASS.   </li></ul>Classes
  14. 14. Attributes
  15. 15. Defining Local Classes Classes
  16. 16. Attributes, Types, Constants - Syntax
  17. 17. Attributes and Visibility
  18. 18. Instance attributes and Static attributes
  19. 19. Methods
  20. 20. Methods : Syntax
  21. 21. Methods and Visibility
  22. 22. Instance methods and Static methods
  23. 23. Instance methods and Static methods : Example
  24. 24. Constructor
  25. 25. Constructor : Example
  26. 26. Static Constructor : Implementation
  27. 27. Static Constructor : Call Examples
  28. 28. Creating Objects
  29. 29. Reference Variables
  30. 30. Creating Objects : Syntax
  31. 31. Assigning References
  32. 32. <ul><li>Inheritance allows you to derive a new class from an existing class. </li></ul><ul><li>You do this using the INHERITING FROM addition in the </li></ul><ul><li>CLASS <subclass> DEFINITION INHERITING FROM <superclass> </li></ul><ul><li>statement. </li></ul><ul><li>The new class <subclass> inherits all of the components of the existing class <superclass>. </li></ul><ul><li>The new class is called the subclass of the class from which it is derived. </li></ul><ul><li>The original class is called the superclass of the new class. </li></ul>Inheritance
  33. 33. Inheritance
  34. 34. Inheritance : Syntax
  35. 35. Relationships between super classes and subclasses Relationships between super classes and subclasses
  36. 36. Inheritance and Visibility
  37. 37. Inheritance and (Instance) constructor
  38. 38. Parameters and CREATE OBJECT
  39. 39. Redefining Methods in ABAP Objects
  40. 40. Redefining Methods : Example
  41. 41. Compatibility and Narrowing Cast
  42. 42. Principles of the Narrowing Cast
  43. 43. Static and Dynamic Types: Example
  44. 44. Static and Dynamic Types for References
  45. 45. Widening the Cast Static and Dynamic Types for References
  46. 46. Widening the cast
  47. 47. Polymorphism
  48. 48. Polymorphism
  49. 49. Polymorphism
  50. 50. <ul><li>Interfaces exclusively describe the external point of contact of a class, but they do not contain their own implementation part. </li></ul>Interface
  51. 51. Defining and Implementing Interface
  52. 52. Working with Interface components
  53. 53. Interface References Narrowing casting
  54. 54. <ul><li>The assignment of an object reference to an interface reference is known as a narrowing cast since, as with inheritance, only a part of the object interface is visible once you have assigned the reference. </li></ul><ul><li>With an interface reference, you can no longer address all components in the class carrying out the implementation, but only the components defined in the interface. </li></ul>Interface
  55. 55. Interface references widening cast
  56. 56. <ul><li>The widening cast is, as with inheritance, the opposite of the narrowing cast: here it is used to retrieve an object reference from an interface reference. Obviously it cannot be statically checked, since an interface can be implemented by more than one class. </li></ul><ul><li>An object reference cannot be assigned to an interface reference if it has itself not implemented the corresponding interface. </li></ul>Interface
  57. 57. <ul><li>In the above example, one class is implementing several interfaces. Even if these interfaces contain components with the same name, they are differentiated in the class carrying out the implementation by the prefix “<interfacename>~”. </li></ul>Using several Interface
  58. 58. Polymorphism and Interface
  59. 59. <ul><li>Objects or Classes use events to trigger Event Handler methods in other objects or classes. </li></ul><ul><li>When an event is triggered any number of Event Handler Methods can be called. </li></ul><ul><li>The events of a class can be raised in the same class using the RAISE EVENT Statement. </li></ul><ul><li>Events have only output parameters which are accepted by the Event Handler Methods as input parameters. </li></ul><ul><li>The link between the trigger and the handler is established dynamically at runtime using the statement SET HANDLER . </li></ul>Events
  60. 60. Events Overview
  61. 61. Triggering and handling Events : Overview
  62. 62. Defining and Triggering Events
  63. 63. Handling and Registering Events
  64. 64. Handling Events
  65. 65. Registering for an Event : Syntax
  66. 66. Deregistration
  67. 67. Registration/Deregistration : Handler Table
  68. 68. Event handling : Characteristics
  69. 69. Events and Visibility