Define Classes PDF Print E-mail
User Rating: / 4
PoorBest 
ABAP Tutorials - Object Oriented ABAP
Written by mastram   
Saturday, 07 June 2008 16:34

In this chapter we will teach you how to create classes in ABAP.

In ABAP, classes can be of two types: Local and Global. As the name suggests Local classes can be used locally inside the declared program only, while the global classes are available globally to be used across different programs. A local class is created within a program (ABAP Editor) while a global class is created with class builder (transaction SE24)

A Class can have 2 parts - Definition and Implementation. In class definition we will define the attributes and methods of class (static and instance both) and in class implementation we will implement the methods of class.

Local Classes

As stated above the local classes are visible only inside the program that they are created in. The below example shows how to create a local class. Please note the syntax also. The key words are shown in CAPS

*******************************************************************

CLASS human DEFINITION.

PUBLIC SECTION
{ "Define attributes, methods and events here.
}

PRIVATE SECTION
{ "Define attributes, methods and events here.
}

PROTECTED SECTION
{ "Define attributes, methods and events here.
}

ENDCLASS.

CLASS human IMPLEMENTATION.
METHOD kick.
** Implement the method to Kick here
ENDMETHOD.

ENDCLASS.

******************************************************************

Global Classes

Global classes are declared in the class editor (transaction SE24).

When you create a class here, just give the class name and press create button. On the new screen give a description for the class. Leave all other fields as defaulted. These will be explained in further chapters. Here you will see different tabs provided to define the attributes and methods of the class. Define the attributes and methods. To implement a method, double click on the method name to open the standard ABAP editor. Here you can write your code.

Comments
Add New Search
Saurabh Mathuria  - ABAP OO Concepts   |address122.248.161.91 |2009-11-27 03:58:34
Hi,

The content on this site is really good.
The concepts are explained with
very interesting examples. Good work guys.

Regards,
Saurabh
Write comment
Name:
Email:
 
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

Last Updated ( Thursday, 14 August 2008 02:12 )
 

Advertisement

 

Google Search

Advertisement