Skip to Content
author's profile photo Former Member
Former Member

How to create a Class

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 10, 2008 at 05:05 AM

    Hi

    Use Class Buiklder SE24 Tcode.

    Praveen

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 10, 2008 at 05:05 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 10, 2008 at 05:07 AM

    Use transaction SE24

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 10, 2008 at 05:08 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 10, 2008 at 05:14 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 10, 2008 at 12:53 PM
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.