Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

ABAP Objects Getting Started

ABAP Objects Development and Programming

Back to Top
 

Rules of this WIKI section

  • Feel free to edit this page and all related pages
  • Keep the page organized following the current layout
  • Only Content entirely related to the ABAP Objects can be inserted here
  • Always add the reference link for your text
  • Any copyrights violation will not be allowed

 
Related Links:

ABAP Objects Overview

ABAP Objects is an Object-Oriented extension to the ABAP Programming language and was introduced on SAP Basis Release 4.5.

SAP Release 4.6 delivered the complete version of ABAP Objects with the introduction of Inheritance.

ABAP Objects is indicated for those who want to guarantee agility during initial development, minimize effort on modifications and rework, and be able to enhance existing applications and create complex applications in a simple way...

The principal features of ABAP Objects are:

  • Encapsulation
  • Instantiation
  • Inheritance
  • Interfacing
  • Events 

...The ABAP runtime support for both procedural and ABAP Objects programming models enables you to use ABAP objects in any program. I.e. in executable programs, module pools, function pools etc. This enables you to use new techniques based on ABAP Objects, such as interfaces, without the need to completely rewrite your existing code.

In OO Programming the only structuring units are classes. Instead of working with global data, you work with objects, which are instances of classes. These objects encapsulate the state and behavior of self-contained parts of the application.

The application state is represented by attributes, that supersede the global variables in the classic procedural approach.

The application behavior is determined by methods, that modify the objects attributes, or call methods of other objects.

Although a pure OO world is technically possible with the SAP environment, most real-world implementations use a mixture of procedural ABAP and ABAP Objects.

Back to Top

Sample

Class Definition

*---------------------------------------------------------------------*
*       CLASS main DEFINITION
*---------------------------------------------------------------------*
CLASS main DEFINITION.

  PUBLIC SECTION.

    METHODS add_data IMPORTING i_data TYPE i.

    METHODS get_data RETURNING VALUE(e_data) TYPE char20.

  PRIVATE SECTION.

    DATA attribute TYPE char01.

ENDCLASS.

Class Implementation

*---------------------------------------------------------------------*
*       CLASS main IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS main IMPLEMENTATION.

  METHOD add_data.

    ADD i_data TO attribute.

  ENDMETHOD.

  METHOD get_data.

    CONCATENATE 'Attribute value' attribute
                               INTO e_data SEPARATED BY space.

  ENDMETHOD.

ENDCLASS.

Object Reference Creation

DATA: object_reference TYPE REF TO main.

Object Instatiation ( Object Creation )

START-OF-SELECTION.

CREATE OBJECT object_reference.

Calling Methods

DATA: var TYPE char20. CALL METHOD object_reference->add_data( i_data = 3 ).

var = object_reference->get_data(  ).

WRITE var.

The Attribute Value Is Printed

" Attribute value 3 "

Back to Top

Moderators of this WIKI section

WFP school meals

WFP school meals encourage hungry children to attend school and help them concentrate on their studies
 
www.wfp.org

Object Oriented

Frequently Asked Questions

Guidelines

Templates & Demos

ABAP Objects Projects

Share Memory Enable (SHMA)

Runtime Type Services (RTTS)

ABAP Unit

Bibliography


ABAP Objects Book's

Next Generation ABAP Development  by Rich Heilman and Thomas Jung

ABAP Objects: ABAP Programming in SAP NetWeaver  by Horst Keller and Sascha Krüger

Web Dynpro for ABAP  by Ulli Hoffmann

Design Patterns in Object-oriented ABAP   by Igor Barbaric

ABAP Objects: Application Development from Scratch
  by Thorsten Franz and Tobias Trapp

Object Orientation Book's
  • Scott Ambler, The Object Primer, SIGS Books & Multimedia (1996), ISBN: 1884842178
  • Grady Booch, Object Solutions: Managing the Object-Oriented Project, Addison-Wesley Pub Co (1995), ISBN: 0805305947
  • Martin Fowler, UML Distilled: Applying the Standard Object Modeling Language, Addison-Wesley Pub Co (1997), ISBN: 0201325632
  • Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides, Design Patterns. Elements of Reusable Object-Oriented Software, Addison-Wesley Pub Co (1998), ISBN: 0201634988
  • James Rumbaugh, OMT Insights: Perspectives on Modeling from the Journal of Object-Oriented Programming, Prentice Hall (1996), ISBN: 0138469652