- 全屏模式生成SALV的方式:http://t.csdnimg.cn/CzNLz
- 可控模式生成SALV的方式:http://t.csdnimg.cn/zB7tu
- Docking container生成SALV的方式,需要在屏幕的PBO或者屏幕初始化事件里完成。
- 完整代码
TABLES:vbak. CLASS lcl_model DEFINITION. PUBLIC SECTION. TYPES:BEGIN OF TY_dATA, vbeln TYPE vbak-vbeln, erdat TYPE erdat, erzet TYPE erzet, ernam TYPE ernam, auart TYPE auart. TYPES:END OF ty_data. DATA mt_data TYPE TABLE OF ty_data. DATA mo_salv TYPE REF TO cl_salv_table. "获取数据的方法 METHODS get_data. "展示SALV的方法 METHODS alv_show. ENDCLASS. CLASS lcl_model IMPLEMENTATION. METHOD get_data. SELECT vbeln erdat erzet ernam auart INTO TABLE mt_data FROM vbak UP TO 20 ROWS. ENDMETHOD. METHOD alv_show. DATA(lo_dock) = NEW cl_gui_docking_container( repid = sy-cprog dynnr = sy-dynnr ratio = 80 side = cl_gui_docking_container=>dock_at_bottom ). TRY. cl_salv_table=>factory( EXPORTING r_container = lo_dock IMPORTING r_salv_table = mo_salv CHANGING t_table = mt_data ). CATCH cx_salv_msg INTO DATA(msg). MESSAGE msg TYPE 'S' DISPLAY LIKE 'E'. ENDTRY. mo_salv->display( ). ENDMETHOD. ENDCLASS. SELECT-OPTIONS vbeln FOR vbak-vbeln. AT SELECTION-SCREEN OUTPUT. DATA(lo_model) = NEW lcl_model( ). lo_model->get_data( ). lo_model->alv_show( ).
- 显示效果: