1.ABAP中显示方法:
FORM DISPLAY_DATA.
IF UPLOAD = 'X' OR CHECK = 'X'.
ADD_FIELD :
'BLDAT' 'ITAB' 10 TEXT-002 ' ', "發票日期
'BUDAT' 'ITAB' 10 TEXT-003 ' ', "過帳日期
'XBLNR' 'ITAB' 10 TEXT-004 ' ', "發票號碼
'WRBTR' 'ITAB' 20 TEXT-005 ' ', "金額
'WAERS' 'ITAB' 10 TEXT-006 ' ', "幣別
'MWSKZ' 'ITAB' 10 TEXT-008 ' ', "稅別
'EBELN' 'ITAB' 10 TEXT-009 ' ', "PO #
'EBELP' 'ITAB' 10 TEXT-010 ' ', "PO item
'REF_DOC' 'ITAB' 10 'REF DOC' ' ', "REF_DOC
'REF_DOC_IT' 'ITAB' 10 'REF DOC IT' ' ', "REF_DOC item
'FLAG' 'ITAB' 15 TEXT-011 ' ',
'REMARK' 'ITAB' 200 '狀態' ' ' .
DISPLAY_DATA ITAB ''.
ELSEIF QUERY = 'X'.
ADD_FIELD :
'BELNR' 'TAB_RBKPDIS' 10 TEXT-013 ' ', "發票文件號碼
* 'GJAHR' 'TAB_RBKPDIS' 10 TEXT-002 ' ', "會計年度
'BLART' 'TAB_RBKPDIS' 10 TEXT-014 ' ', "文件類型
'BLDAT' 'TAB_RBKPDIS' 10 TEXT-002 ' ', "文件日期
'BUDAT' 'TAB_RBKPDIS' 10 TEXT-003 ' ', "過帳日期
'XBLNR' 'TAB_RBKPDIS' 10 TEXT-004 ' ', "發票號碼
'LIFNR' 'TAB_RBKPDIS' 10 TEXT-015 ' ', "開票方
'WAERS' 'TAB_RBKPDIS' 10 TEXT-006 ' ', "幣別
'KURSF' 'TAB_RBKPDIS' 10 TEXT-017 ' ', "匯率
'RMWWR' 'TAB_RBKPDIS' 10 TEXT-018 ' ', "總發票金額(要乘100)
'BEZNK' 'TAB_RBKPDIS' 10 TEXT-019 ' ', "淨發票金額(要乘100)
'WMWST1' 'TAB_RBKPDIS' 10 TEXT-020 ' ', "稅額(要乘100)
'STBLG' 'TAB_RBKPDIS' 10 TEXT-021 ' ', "迴轉者
'ZFBDT' 'TAB_RBKPDIS' 10 TEXT-022 ' ', "基準日
'MWSKZ1' 'TAB_RBKPDIS' 10 TEXT-008 ' ', "稅碼
* 'BUPLA' 'TAB_RBKPDIS' 10 TEXT-006 ' ', "商業區段
'BUKRS' 'TAB_RBKPDIS' 10 TEXT-026 ' '. "公司代碼
DISPLAY_DATA TAB_RBKPDIS ''.
ENDIF.
ENDFORM. " DISPLAY_DATA
2.先定义ADD_FIELD.
DEFINE ADD_FIELD.
I_FIELDCAT-TABNAME = &2.
I_FIELDCAT-FIELDNAME = &1.
I_FIELDCAT-SELTEXT_M = &4.
I_FIELDCAT-OUTPUTLEN = &3.
I_FIELDCAT-INPUT = &5.
I_FIELDCAT-HOTSPOT = P_CHAR.
APPEND I_FIELDCAT.
END-OF-DEFINITION.
3.定义DISPLAY_DATA.
DEFINE DISPLAY_DATA.
******启动命令功能********************************
REFRESH I_EVENTS.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = I_EVENTS.
READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND
INTO L_LS_EVENT.
IF SY-SUBRC = 0.
MOVE SLIS_EV_USER_COMMAND TO L_LS_EVENT-FORM.
APPEND L_LS_EVENT TO I_EVENTS.
ENDIF.
********功能扩充**********************************
I_LAYOUT-ZEBRA = 'X'. "颜色交替显示
I_LAYOUT-WINDOW_TITLEBAR = L_WINDOW_TITLEBAR. "抬头显示
I_LAYOUT-COLWIDTH_OPTIMIZE = 'X'. "优化
I_LAYOUT-GROUP_CHANGE_EDIT = 'X'.
I_LAYOUT-F2CODE = &2.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_SAVE = 'X'
IS_VARIANT = G_VARIANT
I_GRID_TITLE = TITLE "抬头
IT_HYPERLINK = GT_HYPETAB
IT_EVENTS = I_EVENTS "事件
IT_FIELDCAT = I_FIELDCAT[] "显示的内容和描述
IS_LAYOUT = I_LAYOUT
TABLES
T_OUTTAB = &1 "数据表
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
END-OF-DEFINITION.