21.03.2013 Views

Object Oriented ABAP

Object Oriented ABAP

Object Oriented ABAP

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Create Transaction for local class method<br />

In this demo I am going to show how to create transaction on a local class method.<br />

Step1: First create a local class in a report from transaction SE38.<br />

REPORT z_demo_oop_jg .<br />

*---------------------------------------------------------------------*<br />

* CLASS create_report DEFINITION<br />

*---------------------------------------------------------------------*<br />

*<br />

*---------------------------------------------------------------------*<br />

CLASS create_report DEFINITION.<br />

PUBLIC SECTION.<br />

METHODS: main.<br />

PRIVATE SECTION.<br />

DATA: i_data TYPE STANDARD TABLE OF sbook INITIAL SIZE 0.<br />

METHODS: fetch_data,<br />

display_data.<br />

ENDCLASS. "create_report DEFINITION<br />

*---------------------------------------------------------------------*<br />

* CLASS create_report IMPLEMENTATION<br />

*---------------------------------------------------------------------*<br />

*<br />

*---------------------------------------------------------------------*<br />

CLASS create_report IMPLEMENTATION.<br />

METHOD fetch_data.<br />

* Select 100 records from SBOOK table<br />

SELECT * FROM sbook<br />

INTO TABLE i_data<br />

UP TO 100 ROWS.<br />

ENDMETHOD. "fetch_data<br />

METHOD display_data.<br />

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'<br />

EXPORTING<br />

i_structure_name = 'SBOOK'<br />

TABLES<br />

t_outtab = i_data<br />

EXCEPTIONS<br />

program_error = 1<br />

OTHERS = 2.<br />

IF sy-subrc 0.<br />

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno<br />

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.<br />

ENDIF.<br />

ENDMETHOD. "display_data<br />

METHOD main.<br />

fetch_data( ).<br />

display_data( ).<br />

ENDMETHOD. "main<br />

ENDCLASS. "create_report IMPLEMENTATION

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!