Ex :-
Steps
1.Create a triggering method in a class which will raise the event.
- Go to transaction code SE24.
- Enter the class name start's with ZCL_<class name > and click on Create.
- Pop-up will appear.
- Enter the short description and click on SAVE.
- Save it in either Package or Local Package.
- Create a Event triggering method.
- To pass parameters , Click on method name and click on Parameters.
- Pass the parameters.
- Click on Save and click on BACK button.
- Double Click on Method name.
3.Create an event handler method for the event in same/other class.
- Enter the event handler method name , Type and Visibility.
- Select the event handler name and click on " Detail View ".
- Pop-up will appear.
- Click on " Event Handler for ".
- Enter the Class name and Event name.
- Click on Change.
- Looks like,
- To implement the event handler method , double click on event handler method and enter the source code.
- Save and click on Back button.
- Create a method to display data.
- To Pass the parameters, click on method name and click on Parameters.
- Pass the parameters.
- Click on Save and click on BACK button.
- To implement the method , double click on method name.
- Source code.
- Source Code.
DATA : OBJ TYPE REF TO ZCL_EVENT_CLASS.
DATA : IT_VBRP TYPE TABLE OF VBRP.
PARAMETERS : P_VBELN TYPE VBRP-VBELN.
START-OF-SELECTION.
CREATE OBJECT OBJ.
"4. Register the event handler method in the program.
SET HANDLER OBJ->EVENT_HANDLER FOR OBJ.
CALL METHOD OBJ->FECT_DATA
EXPORTING
IM_VBELN = P_VBELN
CHANGING
CH_ITAB = IT_VBRP
.
CALL METHOD OBJ->DISPLAY
EXPORTING
CH_ITAB = IT_VBRP
.
No comments:
Post a Comment