REPORT ztest_oo_alv_main.
*
*----------------------------------------------------------------------*
* CLASS lcl_report DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_report DEFINITION.
PUBLIC SECTION.
TYPES: BEGIN OF ty_vbak,
vbeln TYPE vbak-vbeln,
erdat TYPE erdat,
auart TYPE auart,
kunnr TYPE kunnr,
END OF ty_vbak.
DATA: t_vbak TYPE STANDARD TABLE OF ty_vbak.
DATA: o_alv TYPE REF TO cl_salv_table.
METHODS:
get_data,
generate_output.
PRIVATE SECTION.
METHODS: set_pf_status CHANGING co_alv TYPE REF TO cl_salv_table.
ENDCLASS. "lcl_report DEFINITION
START-OF-SELECTION.
DATA: lo_report TYPE REF TO lcl_report.
CREATE OBJECT lo_report.
lo_report->get_data( ).
lo_report->generate_output( ).
*----------------------------------------------------------------------*
* CLASS lcl_report IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_report IMPLEMENTATION.
METHOD get_data.
SELECT vbeln erdat auart kunnr
INTO TABLE t_vbak
FROM vbak
UP TO 20 ROWS.
ENDMETHOD. "get_data
METHOD set_pf_status.
***使用其它程序的gui status
co_alv->set_screen_status(
pfstatus = 'SALV_STANDARD'
report = 'SALV_DEMO_TABLE_SELECTIONS'
set_functions = co_alv->c_functions_all ).
ENDMETHOD. "set_pf_status
METHOD generate_output.
DATA: lx_msg TYPE REF TO cx_salv_msg.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = o_alv
CHANGING
t_table = t_vbak ).
CATCH cx_salv_msg INTO lx_msg.
ENDTRY.
CALL METHOD set_pf_status
CHANGING
co_alv = o_alv.
o_alv->display( ).
ENDMETHOD. "generate_output
ENDCLASS. "lcl_report IMPLEMENTATION
阅读(1287) | 评论(0) | 转发(0) |