「ZPGM_ALV_GRID_DEMO」
常用:「CL_GUI_ALV_GRID」でALVを新規作成;
灵活性强,ALV实现报表方式上最为灵活;
実装の基本的な流れ:
ステップ1:(オブジェクト)定義
DATA: GRID TYPE REF TO CL_GUI_ALV_GRID,
G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
ステップ2:CUSTOM CONTAINERの新規作成(スクリーンの作成が必須);
ステップ3:OOの初期化
IF G_CUSTOM_CONTAINER IS INITIAL.
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING CONTAINER_NAME = 'CONTAINER'.
CREATE OBJECT GRID
EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
ENDIF.
まず、SE51、スクリームを作成する。(CALL SCREEN 100)
*&---------------------------------------------------------------------* *& Report ZAXYT_GRID_DEMO *&---------------------------------------------------------------------* *& Title : Use CL_GUI_ALV_GRID to create ALV *&---------------------------------------------------------------------* REPORT ZAXYT_GRID_DEMO. * get data SELECT * FROM VBAK INTO TABLE @DATA(LT_TAB) UP TO 30 ROWS. * variable definition DATA(O_GRID) = NEW CL_GUI_ALV_GRID( I_PARENT = CL_GUI_CONTAINER=>SCREEN0 " 定义一个 CL_GUI_ALV_GRID 类型的对象 O_GRID,并将其实例化。 "I_PARENT = CL_GUI_CONTAINER=>SCREEN0 表示该对象将显示在 SAP 系统的屏幕上。 ). * alv O_GRID->SET_TABLE_FOR_FIRST_DISPLAY( EXPORTING I_STRUCTURE_NAME = 'VBAK' " Internal Output Table Structure Name CHANGING IT_OUTTAB = LT_TAB "Output Table ). IF SY-SUBRC <> 0. MESSAGE S000(YMSG) WITH 'Failed'. ENDIF. * create screen CALL SCREEN 100.
标签:CONTAINER,CL,GUI,CUSTOM,OOALV,GRID,ALV From: https://www.cnblogs.com/asking66666/p/17609715.html