Oops in Abap

of 227
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
    Page 1 of 227  Prepared By: Sonu Kumar Verma (SAP ABAP Technical Consultant)   Sonu Kumar Verma Technical Consultant (Vikalp Solutions)    Page 2 of 227  Prepared By: Sonu Kumar Verma (SAP ABAP Technical Consultant)   CLASS AND OBJECT USING REPORT PROGRAM IN ABAP Classes : Classes describe objects. From a technical point of view, objects are runtime instances of a class. In theory, you can create any number of objects based on a single class. Each instance (object) of a class has a unique identity and its own set of values for its attributes.  Classes in ABAP Objects can be declared either locally or globally. Global Class:   Global classes and interfaces are defined in the class builder ( Transaction se24 ) In the ABAP Workbench. They are stored centrally in class polls in the class library in the R/3 repository . All the programs in R/3 system can access the global classes. Local Classes :  Local classes are define with in the ABAP PROGRAM (Transaction SE38) and can only be used in the program in which they are declared. Local Classes : Every class will have two sections. 1.   Definition 2.   Implementation Definition :  This section used to declare the components of classes such as attributes,methods ,events . they are enclosed in the ABAP statements CLASS ……. END CLASS.  CLASS <class name> DEFINITION. …..  END CLASS. Implementation :  This section of a class contains implementation of all methods of the class . the implementation part of local class is processing block . CLASS <class name> IMPLEMENTATION. ………  END CLASS.    Page 3 of 227  Prepared By: Sonu Kumar Verma (SAP ABAP Technical Consultant)   Structure of a class. The following statements define the structure of class. 1.   A class contain components. 2.   Each component is assigned to a visibility section 3.   Classes implement methods. REPORT ZS_CLASS. *Declaring class definition attribute and property.  CLASS FIRST DEFINITION. * public section of class.  PUBLIC SECTION. METHODS: SHOWME ,SAWME. ENDCLASS. *Implementation of that class and its method.  CLASS FIRST IMPLEMENTATION. * Method implementation.  METHOD SHOWME. WRITE 'SHOW ME METHOD'. ENDMETHOD. METHOD SAWME. WRITE / 'SAW WITH IN THE SUPERCLASS'. ENDMETHOD. ENDCLASS. *   *class inherating a super class.  CLASS SECOND DEFINITION INHERITING FROM FIRST.. PUBLIC SECTION. METHODS SHOWME REDEFINITION. ENDCLASS. *SUB CLASS IMPLEMENTATION.  CLASS SECOND IMPLEMENTATION. * REDEFINE SUBCLASS METHOD.  METHOD SHOWME. WRITE / 'WITH IN THE SUBCLASS'. ENDMETHOD. ENDCLASS. *CREATING OBJECT AND EXECUTING ITS METHOD.      Page 4 of 227  Prepared By: Sonu Kumar Verma (SAP ABAP Technical Consultant)   *always create refernce and object in START-OF-SELECTION Event because the data extraction come under this event.  START-OF-SELECTION. *creating reference of the object.  DATA FIRSTOBJ TYPE REF TO FIRST. DATA SECONDOBJ TYPE REF TO SECOND. *creating object of the reference.  CREATE OBJECT FIRSTOBJ. *calling the method of that class.  CALL METHOD FIRSTOBJ->SHOWME. *Creating object of second class  CREATE OBJECT SECONDOBJ. *calling method of subclass and superclass.  CALL METHOD SECONDOBJ->SHOWME. CALL METHOD SECONDOBJ->SAWME. Components of class. 1.   Attributes :  any data , constants , types declared with in a class from the attribute of the class. 2.   Methods :  Block of code providing some functionality offered by the class can be compared to function modules . they can access all of the attributes of a class. Methods are defined in the definition part of class and implement it in the implementation part using the following processing block. METHOD <method name> ………  END METHOD. Method are call using the   CALL METHOD  statement. 3.   EVENTS :  A mechanism set with in class which can help a class to trigger methods of another class. 4.   Interfaces :  Interfaces are independent structures that you can implement in a class to extend the scope of the class.
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks