Class in abap

 Class:

    *  Class is a collection of data members and member functions.

    *  Data members means variables and member function means functions.

    *  T-code -se24 and also se38.

    Syntax of class

        class < class_name> definiton.

            { visibility} - public,protected,private

            { declaration} - static / instance

            { events/interfaces}

        endclass.

        class <class_name> implementation.

            method <method_name>

            endmethod

        endclass.

    data obj_class type refer to<class_name>

    create object obj_class. or data(obj_class) = new <class_name> ().

    Example in se38 - local class 

         

    REPORT ZAJAY_CL_1.
    CLASS DEFINITION.
      PUBLIC SECTION.
          datatext1 type string VALUE 'hello1'.
          METHODS meth.
      PROTECTED SECTION.
          datatext2 type string VALUE 'hello2'.
      PRIVATE SECTION.
           datatext3 type string VALUE 'hello3'.
      ENDCLASS.

    CLASS IMPLEMENTATION.
          METHOD meth.
              write/ text1,
                    / text2 ,
                    / text3.
                        
            ENDMETHOD.
        ENDCLASS.

     START-OF-SELECTION.
    data obj TYPE REF TO a.
    create OBJECT obj.
    obj->meth).

         Example in se24 - Global class

      *  declare variables in attributes

     

    *  declare methods in methods and double click on method then write operation.


                                

Comments