*&---------------------------------------------------------------------*
*& 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.
DATA ACOL TYPE SCXTAB_COLUMN.
MODULE USER_COMMAND_0100 INPUT.
SAVE_OK = OK_CODE.
CLEAR OK_CODE.
CASE SAVE_OK.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'READWR'.
*當單擊按鈕時,第一列只讀,其他列讀寫切換
LOOP AT TBL1-COLS INTO ACOL WHERE INDEX GT 0.
IF SY-TABIX = 1.
ACOL-SCREEN-INPUT = '0'.
ELSE.
IF ACOL-SCREEN-INPUT = 0.
ACOL-SCREEN-INPUT = '1'.
ELSEIF ACOL-SCREEN-INPUT = 1.
ACOL-SCREEN-INPUT = '0'.
ENDIF.
ENDIF.
MODIFY TBL1-COLS FROM ACOL INDEX SY-TABIX.
ENDLOOP.
*放到Loop 後面,第一列隱藏
* MODIFY TBL1-COLS FROM ACOL INDEX SY-TABIX.
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.