ABAP程式示例4
*&---------------------------------------------------------------------*
*& Report ZTEST_07_ZHANGWL *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZTEST_07_ZHANGWL .
TYPE-POOLS: SLIS.
DATA: GT_FLIGHT TYPE STANDARD TABLE OF SFLIGHT.
DATA: BEGIN OF GT_FLIGHT1.
INCLUDE STRUCTURE SFLIGHT.
DATA: END OF GT_FLIGHT1.
DATA: GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
G_EXIT_CAUSED_BY_CALLER TYPE C,
GS_EXIT_CAUSED_BY_USER TYPE SLIS_EXIT_BY_USER,
G_REPID TYPE SY-REPID.
DATA: GT_EVENTS TYPE SLIS_T_EVENT,
GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
G_STATUS_SET TYPE SLIS_FORMNAME VALUE 'PF_STATUS_SET',
G_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND',
G_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
G_TOP_OF_LIST TYPE SLIS_FORMNAME VALUE 'TOP_OF_LIST',
G_END_OF_LIST TYPE SLIS_FORMNAME VALUE 'END_OF_LIST'.
DATA: GS_VARIANT TYPE DISVARIANT,
G_SAVE TYPE C.
INITIALIZATION.
G_REPID = SY-REPID.
GS_VARIANT-REPORT = G_REPID.
G_SAVE = 'A'.
PERFORM LAYOUT_INIT USING GS_LAYOUT.
PERFORM EVENTTAB_BUILD USING GT_EVENTS.
START-OF-SELECTION.
PERFORM SELECT_DATA TABLES GT_FLIGHT.
END-OF-SELECTION.
PERFORM COMMENT_BUILD USING GT_LIST_TOP_OF_PAGE[].
PERFORM SHOW_RESULT.
*&---------------------------------------------------------------------*
*& Form LAYOUT_INIT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GS_LAYOUT text
*----------------------------------------------------------------------*
FORM LAYOUT_INIT USING P_GS_LAYOUT TYPE SLIS_LAYOUT_ALV.
P_GS_LAYOUT-DETAIL_POPUP = 'X'.
ENDFORM. " LAYOUT_INIT
*&---------------------------------------------------------------------*
*& Form EVENTTAB_BUILD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_EVENTS text
*----------------------------------------------------------------------*
FORM EVENTTAB_BUILD USING P_GT_EVENTS TYPE SLIS_T_EVENT.
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = P_GT_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
ENDIF.
READ TABLE P_GT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE G_TOP_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO P_GT_EVENTS.
ENDIF.
ENDFORM. " EVENTTAB_BUILD
*&---------------------------------------------------------------------*
*& Form SELECT_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_FLIGHT text
*----------------------------------------------------------------------*
FORM SELECT_DATA TABLES P_GT_FLIGHT LIKE GT_FLIGHT.
SELECT * FROM SFLIGHT
INTO CORRESPONDING FIELDS OF TABLE P_GT_FLIGHT
UP TO 000030 ROWS.
ENDFORM. " SELECT_DATA
*&---------------------------------------------------------------------*
*& Form COMMENT_BUILD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->LT_LIST_TOP_OF_PAGE[] text
*----------------------------------------------------------------------*
FORM COMMENT_BUILD USING LT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: LS_LINE TYPE SLIS_LISTHEADER.
*
* LIST HEADING LINE: TYPE H
CLEAR LS_LINE.
LS_LINE-TYP = 'H'.
* LS_LINE-KEY: NOT USED FOR THIS TYPE
LS_LINE-INFO = 'ALV 演示航班概覽'.
APPEND LS_LINE TO LT_LIST_TOP_OF_PAGE.
* STATUS LINE: TYPE S
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = '有效期至'.
LS_LINE-INFO = '2007/07/30'.
APPEND LS_LINE TO LT_LIST_TOP_OF_PAGE.
LS_LINE-KEY = '機場'.
LS_LINE-INFO = 'Frankfurt'.
APPEND LS_LINE TO LT_LIST_TOP_OF_PAGE.
* ACTION LINE: TYPE A
CLEAR LS_LINE.
LS_LINE-TYP = 'A'.
* LS_LINE-KEY: NOT USED FOR THIS TYPE
LS_LINE-INFO = '當前資料'.
APPEND LS_LINE TO LT_LIST_TOP_OF_PAGE.
ENDFORM. " COMMENT_BUILD
*&---------------------------------------------------------------------*
*& Form SHOW_RESULT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* *----------------------------------------------------------------------*
FORM SHOW_RESULT .
*"Display List
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_BACKGROUND_ID = 'ALV_BACKGROUND'
I_BUFFER_ACTIVE = 'X'
I_CALLBACK_PROGRAM = G_REPID
I_STRUCTURE_NAME = 'SFLIGHT'
IS_LAYOUT = GS_LAYOUT
I_SAVE = G_SAVE
IS_VARIANT = GS_VARIANT
IT_EVENTS = GT_EVENTS[]
IMPORTING
E_EXIT_CAUSED_BY_CALLER = G_EXIT_CAUSED_BY_CALLER
ES_EXIT_CAUSED_BY_USER = GS_EXIT_CAUSED_BY_USER
TABLES
T_OUTTAB = GT_FLIGHT
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC = 0.
IF G_EXIT_CAUSED_BY_CALLER = 'X'.
*" Forced Exit by calling program
*"
ELSE.
*" User left list via F3, F12 or F15
IF GS_EXIT_CAUSED_BY_USER-BACK = 'X'. "F3
*"
ELSE.
IF GS_EXIT_CAUSED_BY_USER-EXIT = 'X'. "F15
*"
ELSE.
IF GS_EXIT_CAUSED_BY_USER-CANCEL = 'X'. "F12
*"
ELSE.
*" should not occur!
*"
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ELSE.
*"Fatal error callin ALV
* MESSAGE AXXX(XY) WITH ...
ENDIF.
ENDFORM. " SHOW_RESULT
*&---------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* *----------------------------------------------------------------------*
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE
* I_LOGO =
* I_END_OF_LIST_GRID =
.
ENDFORM.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8356764/viewspace-929420/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ABAP程式示例
- ABAP程式示例3
- ABAP中文示例1
- ABAP中文示例2
- ABAP/4程式設計中用到的系統函式程式設計函式
- 使用ABAP程式碼建立S/4HANA裡的Sales Order
- ABAP程式Hello World
- S2S3H4 整合程式碼示例S3
- SAP ABAP/4學習---BDC批次輸入寫成內表程式
- 如何使用 ABAP 程式消費 SAP ABAP OData 服務
- MQ通道配置示例 4種MQ
- BDC程式示例C程式
- ABAP 程式比對(Compare)
- ABAP初學者如何系統地學習ABAP程式設計?程式設計
- 用ABAP程式碼讀取S/4HANA生產訂單工序明細
- 使用ABAP程式碼返回S/4HANA Material上維護的Attachment明細
- log4j使用示例 (轉)
- typescript openai gtp-4o 示例TypeScriptOpenAI
- SAP ABAP 程式之間的呼叫
- 使用delphi+intraweb進行微信開發1~4程式碼示例Web
- RabbitMQ 程式碼示例MQ
- lisp 程式碼示例Lisp
- 排序程式碼示例排序
- PA認證經驗(ABAP/4)-----------摘自SAPCLUB.ORG
- log4j配置檔案示例
- 在SAP雲平臺ABAP程式設計環境上編寫第一段ABAP程式程式設計
- 一些通過SAP ABAP程式碼審查得出的ABAP程式設計最佳實踐程式設計
- ABAP的程式碼規範標準
- 如何使用ABAP程式碼反序列化JSON字串成ABAP結構JSON字串
- Java NIO 程式碼示例Java
- ALVALV程式示例
- java SPI 程式碼示例Java
- (轉)SAP ABAP/4學習--BCALV_TREE_01分析
- 通過ABAP程式碼判斷當前系統型別,BYD還是S4 OP還是S4 Cloud型別Cloud
- 比較全的log4j示例
- ABAP面試題系列:寫一組會出現死鎖(Deadlock)的ABAP程式面試題
- 視窗程式框架示例程式碼框架
- ABAP程式碼分析工具 - 事務碼SQF