Posts

OOPS ABAP: EVENTS with Example

Image
Events: Method of one class can call the method of another class. Triggering Method:   This method raises the event. Event Handler Method: The method will handle the event. Register the event handler method using SET HANDLER statement. CLASS class1. METHOD DISPLAY ENDCLASS. --------------------------------------- CLASS CLASS2. METHOD MESSAGE. ENDCLASS. Syntax for event handler: SET HANDLER lo_object1 -> event_handler for lo_object2. where lo_object1 -> class object in which event handler method is defined.              EVENT_HANDLER -> Event handler method name.              lo_object2 -> class object in which triggering method is defined.  Example *&---------------------------------------------------------------------* *& Report ZVB_EVENTS *&--------------------------------------------...

OOPS ABAP: Differences between Abstract class and interfaces

 Abstract classes: In Abstract class have at least one abstract method and others can non-abstract methods. Abstract methods can be public,private or protected. We need to redefine the  abstract method to implement the method in sub class. we can not redefine static methods. Multiple inheritance is not possible. Interfaces: All methods are abstract methods in interfaces. All methods are public. No need to redefine method. we can write the code by clicking on source code button. Multiple inheritance is possible.

OOPS ABAP: Local Interfaces with Example

Interfaces:  The ABAP statement “INTERFACE" is used to define the interfaces. The ABAP statement “INTERFACES" is used to access the interfaces in a class. The interfaces do not have their own implementation sections. The symbol "~ (tilt)" is used to refer the attributes of the interfaces.  Example: *&---------------------------------------------------------------------* *& Report ZVB_INTERFACES *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* REPORT  zvb_interfaces . PARAMETERS : p_vbeln  TYPE  vbeln_va . DATA : it_vbak  TYPE  ztt_vbak ,   "table type      is_vbak  TYPE  zst_vbak .   "structure *Creating interface and method INTERFACE   interface1 .    METHODS  display  IMPORTING  pp_vbeln  TYPE ...

OOPS ABAP : Global INTERFACES With Example

Image
 Interfaces: They are the independent structures which can be used to extend the scope of the classes. The interfaces do not have their own implementation sections, all methods are abstract classes. The interfaces must be specified under Public section of the class.  The symbol "~ (tilt)" is used to refer the attributes of the interfaces. Steps to create Global Interfaces: Execute the t-code "SE24". Enter the global class name. click on create button.  Select a radio button interface to create the gobal interfaces. Click on yes button and enter short desc.   Enter method details     Enter Parmeters.   Save,check and activate.  Calling the methods of interface in sub class: Goto se24 and enter class name and click create. select radio button 'class' and press enter. Click on 'Interface' tab and enter interface class name and activate.     Click on methods tab.    Click on source code button and write the below code and ac...