ALV示例---Dyoprn實現,一個容器中嵌入ALV報表
注意點:1,螢幕上需要定義一個CoustomerControl
2,如果在CoustomerControl中設定一個按鈕,要響應這個按鈕,需要在ElementList中指定它的FunctionCode。
程式:
*&---------------------------------------------------------------------*
*& Report ZTEST_DYNPRO
*&
*&---------------------------------------------------------------------*
*& Test by Ray.Zhang
*&---------------------------------------------------------------------*
REPORT ZTEST_DYNPRO.
TABLES VBAK.
TYPES:
BEGIN OF TYP_VBAK,
VBELN TYPE VBAK-VBELN, "Sales Document
ERDAT TYPE VBAK-ERDAT, "Date on which the record was created
ERNAM TYPE VBAK-ERNAM, "Name of Person who Created the Object
AUART TYPE VBAK-AUART, "Sales Document Type
WAERK TYPE VBAK-WAERK, "SD document currency
END OF TYP_VBAK.
DATA:
TG_FIELDCAT TYPE LVC_T_FCAT,
TG_VBAK TYPE TABLE OF TYP_VBAK.
DATA:
OK_CODE TYPE SY-UCOMM,
VG_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
VG_GRID TYPE REF TO CL_GUI_ALV_GRID,
WG_LAYOUT TYPE LVC_S_LAYO.
SELECT-OPTIONS:
S_ERDAT FOR VBAK-ERDAT.
*----------------------------------------------------------------------*
* INITIALIZATION
*----------------------------------------------------------------------*
INITIALIZATION.
*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM F_GET_DATA.
*----------------------------------------------------------------------*
* END-OF-SELECTION
*----------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM F_OUTPUT_RESULT.
*----------------------------------------------------------------------*
* FORMS
*----------------------------------------------------------------------
*&---------------------------------------------------------------------*
*& Form F_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM F_GET_DATA .
SELECT VBELN
ERDAT
ERNAM
AUART "Sales Document Type
WAERK "SD document currency
FROM VBAK
INTO TABLE TG_VBAK
WHERE ERDAT IN S_ERDAT.
ENDFORM. " F_GET_DATA
*
*&---------------------------------------------------------------------*
*& Form F_OUTPUT_RESULT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM F_OUTPUT_RESULT .
PERFORM F_SET_ALV.
CALL SCREEN 9001.
ENDFORM. " F_OUTPUT_RESULT
*&---------------------------------------------------------------------*
*& Form F_SET_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM F_SET_ALV .
PERFORM F_FIELDCAT_EDIT USING '1' 'VBELN' 'Sales Document'.
PERFORM F_FIELDCAT_EDIT USING '2' 'ERDAT' 'Create Date'.
PERFORM F_FIELDCAT_EDIT USING '3' 'ERDAT' 'Create By'.
PERFORM F_FIELDCAT_EDIT USING '4' 'AUART' 'Sales Document Type'.
PERFORM F_FIELDCAT_EDIT USING '5' 'WAERK' 'Document currency'.
ENDFORM. " F_SET_ALV
*&---------------------------------------------------------------------*
*& Form F_FIELDCAT_EDIT
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
FORM F_FIELDCAT_EDIT USING U_COL_POS TYPE LVC_S_FCAT-COL_POS
U_FIELDNAME TYPE LVC_S_FCAT-FIELDNAME
U_SELTEXT_L TYPE LVC_S_FCAT-SCRTEXT_L.
DATA:
WL_FIELDCAT TYPE LVC_S_FCAT.
WL_FIELDCAT-COL_POS = U_COL_POS.
WL_FIELDCAT-FIELDNAME = U_FIELDNAME.
WL_FIELDCAT-SCRTEXT_L = U_SELTEXT_L.
APPEND WL_FIELDCAT TO TG_FIELDCAT.
ENDFORM. " F_FIELDCAT_EDIT
*&---------------------------------------------------------------------*
*& Module M_STATUS_9001 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE M_STATUS_9001 OUTPUT.
SET PF-STATUS 'ST_9001'.
IF VG_CONTAINER IS INITIAL.
CREATE OBJECT VG_CONTAINER
EXPORTING
CONTAINER_NAME = 'CONTAINER'.
CREATE OBJECT VG_GRID
EXPORTING
I_PARENT = VG_CONTAINER.
* LAYOUT SET
WG_LAYOUT-NO_TOOLBAR = 'X'. "NO TOOLBAR
WG_LAYOUT-CWIDTH_OPT = 'X'.
WG_LAYOUT-SEL_MODE = 'A'.
WG_LAYOUT-EDIT = 'X'. "Set status of all cells to editable
* ALV OUTPUT
CALL METHOD VG_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = WG_LAYOUT
CHANGING
IT_FIELDCATALOG = TG_FIELDCAT
IT_OUTTAB = TG_VBAK.
CALL METHOD VG_GRID->SET_READY_FOR_INPUT
EXPORTING
I_READY_FOR_INPUT = 0.
ENDIF.
ENDMODULE. " M_STATUS_9001 OUTPUT
*&---------------------------------------------------------------------*
*& Module M_USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE M_USER_COMMAND_9001 INPUT.
DATA:
LV_VALID(1) TYPE C,
LV_OK_CODE TYPE SY-UCOMM.
LV_OK_CODE = OK_CODE.
CASE LV_OK_CODE.
WHEN 'SAVE'.
CALL METHOD VG_GRID->CHECK_CHANGED_DATA
IMPORTING
E_VALID = LV_VALID.
IF LV_VALID = 'X'.
MESSAGE I000(0K) WITH 'Data can be saved now'.
ELSE.
MESSAGE I000(0K) WITH 'Errors still exist'.
ENDIF.
WHEN 'CHANGE'.
PERFORM F_SWITCH_EDIT_MODE.
WHEN 'BACK'.
SET SCREEN 0.
LEAVE SCREEN.
ENDCASE.
CLEAR OK_CODE.
ENDMODULE. " M_USER_COMMAND_9001 INPUT
*&---------------------------------------------------------------------*
*& Form SWITCH_EDIT_MODE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM F_SWITCH_EDIT_MODE.
*§3.Use IS_READY_FOR_INPUT to fetch current substate of editable cells.
IF VG_GRID->IS_READY_FOR_INPUT( ) EQ 0.
*§4.Use SET_READY_FOR_INPUT to switch between the substates.
CALL METHOD VG_GRID->SET_READY_FOR_INPUT
EXPORTING
I_READY_FOR_INPUT = 1.
ELSE.
CALL METHOD VG_GRID->SET_READY_FOR_INPUT
EXPORTING
I_READY_FOR_INPUT = 0.
ENDIF.
ENDFORM. " SWITCH_EDIT_MODE
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8356764/viewspace-1028187/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ALV1:使用函式顯示ALV格式報表函式
- SAP: 建立ALV GRID容器
- ALV顯示OO實現(摘)
- 27 行程式碼開發一個最簡單的 SAP ALV 報表行程
- function ALV 獲取OO ALV event IDFunction
- ALV中滑鼠雙擊事件事件
- ALV報表不能正確顯示資料問題
- function方式的ALV中 增加按鈕 用 REUSE_ALV_GRID_DISPLAYFunction
- ALV_FieldEdit
- 一個較為全面的ALV應用程式
- OO ALV 訪問保護類方法 實現欄位報錯紅框定位
- 動態的實現任意表的ALV顯示02
- 動態的實現任意表的ALV顯示01
- 自己寫的ALV程式
- ALV LAYOUT的設定
- 〔轉載〕ALV知識
- ALV_GRID_DISPLAY中設定SORT
- 動態內表及動態ALV顯示(轉)
- 如何在 SAPGUI 的同一個螢幕顯示兩個 ALV listGUI
- SAP ABAP 動態內表實現 ALV橫向按月份動態顯示資料
- 77 行程式碼實現 ABAP ALV 中的雙擊事件處理試讀版行程事件
- ALV清快取:BALVBUFDEL快取
- ALV類應用-GRID
- alv動態顯示列
- 淺談 SAP ABAP 系統裡的 ALV 輸出方式實現
- 48 行程式碼給 ABAP ALV 報表的資料行增添顏色效果行程
- SAP: ALV GRID行顏色
- 在alv grid中的列中設定icon圖示
- ALV單元格顏色設定
- ALV Grid控制元件拖放功能控制元件
- 如何給 SAP ABAP ALV 報表的修改功能新增自定義校驗邏輯試讀版
- web 報表專案中想嵌入地圖?用什麼工具實現?怎樣實現?Web地圖
- 自定義ALV欄位分類時注意
- (轉)關於REUSE_ALV_GRID_DISPLAY函式的slis_layout_alv的欄位使用的說明函式
- 一段比較好的動態生成alv的例子 (轉)
- 【轉載】ALV的Excel方式顯示缺少模板Excel
- (轉)ABAP--ALV_BLOCK_LIAST的函式使用BloCAST函式
- ABAP FM: REUSE_ALV_GRID_LAYOUT_INFO_GET