Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a Class

Former Member
0 Kudos

how to build a class.can anyone send me the procedure to create a class .

thanks

Edited by: Alvaro Tejada Galindo on Apr 10, 2008 5:29 PM

6 REPLIES 6

Former Member
0 Kudos

Hi

Use Class Buiklder SE24 Tcode.

Praveen

Former Member
0 Kudos

Hi swathi,

Classes are templates for objects. Conversely, you can say that the type of an object is the same as its class.

components of the class describe the state and behavior of objects.

Local and Global Classes: Classes in ABAP Objects can be declared either globally or locally. You define global classes and interfaces 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.

Local classes are defined within an ABAP program. Local classes and interfaces can only be used in the program in which they are defined.

When you use a class in an ABAP program, the system first searches for a local class with the specified name. If it does not find one, it then looks for a global class.

Apart from the visibility question, there is no difference between using a global class and using a local class.

Certain restrictions apply when you define the interface of a global class, since the system must be able to guarantee that any program using an object of a global class can recognize the data type of each interface parameter.

Defining Local Classes:

A complete class definition consists of a declaration part and, if required, an implementation part.

The declaration part of a class <class>

CLASS <class> DEFINITION. ... ENDCLASS.

It contains the declaration for all components (attributes, methods, events) of the class.

The declaration part belongs to the global program data.

If you declare methods in the declaration part of a class, you must also write an implementation part for it. This consists of a further statement block:

CLASS <class> IMPLEMENTATION. ... ENDCLASS

The implementation part of a local class is a processing block. Subsequent coding that is not itself part of a processing block is therefore not accessible.

REPORT YSUBOOPS17 .

CLASS c1 DEFINITION.

PUBLIC SECTION.

data : w_num type i value 5.

methods : m1.

ENDCLASS.

CLASS c1 IMPLEMENTATION.

METHOD M1.

WRITE:/5 'I am M1 in C1'.

ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.

DATA : oref1 TYPE REF TO c1 .

CREATE OBJECT : oref1.

write:/5 oref1->w_num.

CALL METHOD : oref1->m1 .

Defined in the global area of a local program :-

CLASS <class name> DEFINITION.

…..

ENDCLASS.

All the attributes , methods, events and interfaces are declared here.

Cannot be declared inside a subroutine/function module.

Class definition cannot be nested.

REPORT YSUBOOPS17 .

CLASS c1 DEFINITION.

PUBLIC SECTION.

data : w_num type i value 5.

methods : m1.

ENDCLASS.

CLASS c1 IMPLEMENTATION.

METHOD M1.

WRITE:/5 'I am M1 in C1'.

ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.

DATA : oref1 TYPE REF TO c1 .

CREATE OBJECT : oref1.

write:/5 oref1->w_num.

CALL METHOD : oref1->m1 .

Local class in a program is implemented as follows:-

CLASS <class name> IMPLEMENTATION.

…..

ENDCLASS.

Methods used by the class are described here.

A class can be implemented

At the end of the program( like subroutines).

After the class definition.

If the latter is adopted, one must then assign subsequent non-declarative statements explicitly to a processing block, such as START-OF-SELECTION, so that they can be accessed.

Check these links.

Class Diagram: Created Classes

http://help.sap.com/saphelp_nw04/helpdata/en/06/f23c43638d11d4966d00a0c94260a5/frameset.htm

Creating Standard Classes

http://help.sap.com/saphelp_nw04/helpdata/en/c0/88885f720911d1b44d0000e8a52bed/frameset.htm

Regards

Kiran

Former Member
0 Kudos

Use transaction SE24

Former Member
0 Kudos

Hi,

The transaction for the class buider is SE24.

See the steps in :

http://help.sap.com/saphelp_nw70/helpdata/en/ca/c035baa6c611d1b4790000e8a52bed/frameset.htm

Regards,

Renjith Michael.

Former Member
0 Kudos

Hi swathi chowdary,

goto SE24 TCODE

and the class name and use ZCL_*

there you can give attributes , methods ,events in that and activate it

this means you are defining the class globally you can use this in ur report program give me ur mail id i will send screen shots how to develop a class

Former Member