*&---------------------------------------------------------------------*
*& Report YTEST00A
*&---------------------------------------------------------------------*
*&Violin 2021/3/10
*&---------------------------------------------------------------------*
REPORT ytest00a.
*第7章 表控件Table Control---------------------------------------------------------------------*
*7.1.1手動建立程序
DATA: OK_CODE TYPE SY-UCOMM,
SAVE_OK TYPE SY-UCOMM.
DATA SP2 LIKE TABLE OF SPFLI WITH HEADER LINE.
DATA SP1 TYPE SPFLI.
DATA NUMS TYPE I.
*增加內表數據
SELECT * INTO CORRESPONDING FIELDS OF TABLE SP2 FROM SPFLI.
*直接調用窗口
CALL SCREEN 560.
*定義表控制對象
CONTROLS TBL1 TYPE TABLEVIEW USING SCREEN 560.
*輸出對象,看內表有無改變
LOOP AT SP2.
WRITE: / SP2-CARRID,SP2-CONNID,SP2-COUNTRYFR,SP2-CITYFROM.
ENDLOOP.
MODULE STATUS_0100 OUTPUT.
SET TITLEBAR 'T01' WITH TEXT-001 TEXT-002.
SET PF-STATUS 'TESTSTA1'.
* 添加垂直滾動條(沒有垂直滾動條原因:沒有定義表格的記錄數)
IF NUMS = 0.
DESCRIBE TABLE SP2 LINES NUMS.
TBL1-LINES = NUMS.
ENDIF.
ENDMODULE.
MODULE USER_COMMAND_0100 INPUT.
SAVE_OK = OK_CODE.
CLEAR OK_CODE.
CASE SAVE_OK.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE.
MODULE CANCEL INPUT.
LEAVE PROGRAM.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module FILLTBL1 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE filltbl1 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
READ TABLE SP2 INTO SP1 INDEX TBL1-CURRENT_LINE.
ENDMODULE.
*&---------------------------------------------------------------------*
*& Module READTBL1 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE readtbl1 INPUT.
MODIFY SP2 FROM SP1 INDEX TBL1-CURRENT_LINE.
ENDMODULE.
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*處理LOOP從內表讀到表控制
LOOP WITH CONTROL TBL1.
MODULE FILLTBL1.
ENDLOOP.
*
PROCESS AFTER INPUT.
*處理LOOP從表控制更新內表
LOOP WITH CONTROL TBL1.
MODULE READTBL1.
ENDLOOP.
MODULE USER_COMMAND_0100.