Creating classic reports in ABAP Objects

Go down

Creating classic reports in ABAP Objects

Post  Admin on Sun Apr 08, 2012 9:44 pm


REPORT z_13.

*----------------------------------------------------------------------*
* CLASS c1 DEFINITION
*----------------------------------------------------------------------*
CLASS c1 DEFINITION.
PUBLIC SECTION.
METHODS: get_data, append_data, display_data, refresh_data.
EVENTS: is_initial.
PRIVATE SECTION.
DATA: it_ekpo TYPE STANDARD TABLE OF ekpo.
DATA: wa_ekpo TYPE ekpo.
ENDCLASS. "c1 DEFINITION



*----------------------------------------------------------------------*
* CLASS c1 IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS c1 IMPLEMENTATION.
METHOD: get_data.
SELECT * FROM ekpo INTO TABLE it_ekpo UP TO 10 ROWS.
ENDMETHOD. "GET_DATA

METHOD: append_data.
wa_ekpo-ebeln = '12345'.
APPEND wa_ekpo TO it_ekpo.
ENDMETHOD. "APPEND_DATA

METHOD: display_data.
IF it_ekpo IS NOT INITIAL.
LOOP AT it_ekpo INTO wa_ekpo.
WRITE: / wa_ekpo-ebeln.
ENDLOOP.
ELSE.
RAISE EVENT IS_INITIAL.
ENDIF.
ENDMETHOD. "DISPLAY_DATA


METHOD: refresh_data.
REFRESH it_ekpo.
ENDMETHOD. "REFRESH_DATA
ENDCLASS. "c1 IMPLEMENTATION




*----------------------------------------------------------------------*
* CLASS C1_HANDLER DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS c1_handler DEFINITION.
PUBLIC SECTION.
METHODS: handle_initial FOR EVENT is_initial OF c1.
ENDCLASS. "C1_HANDLER DEFINITION


*----------------------------------------------------------------------*
* CLASS C1_HANDLER IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS c1_handler IMPLEMENTATION.
METHOD: handle_initial.
WRITE: / 'EVENT ''IS_INITIAL'' IS TRIGGERED'.
ENDMETHOD. "HANDLE_INITIAL
ENDCLASS. "C1_HANDLER IMPLEMENTATION

START-OF-SELECTION.
DATA: o1 TYPE REF TO c1.
CREATE OBJECT o1.

DATA: o2 TYPE REF TO c1_handler.
CREATE OBJECT o2.

* REGISTERING EVENTS WITH CLASS
SET HANDLER o2->handle_initial FOR o1.


CALL METHOD o1->display_data.
CALL METHOD o1->get_data.
CALL METHOD o1->display_data.
CALL METHOD o1->append_data.
CALL METHOD o1->display_data.
CALL METHOD o1->refresh_data.
CALL METHOD o1->display_data.

Admin
Admin

Posts : 92
Join date : 2012-01-26

http://mysaplab.forumotions.in

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum