(轉)ABAP--ALV_BLOCK_LIAST的函式使用
REPORT Z_ALV_BLOCK_LIST.
* Type-pools
TYPE-POOLS: SLIS.
* Data declarations.
DATA: BEGIN OF T_VBAK OCCURS 0,
VBELN TYPE VBELN,
BSTNK TYPE VBAK-BSTNK,
ERDAT TYPE VBAK-ERDAT,
KUNNR TYPE VBAK-KUNNR,
END OF T_VBAK.
DATA: BEGIN OF T_VBAP OCCURS 0,
VBELN TYPE VBELN,
MATNR TYPE VBAP-MATNR,
NETPR TYPE VBAP-NETPR,
WAERK TYPE VBAP-WAERK,
KWMENG TYPE VBAP-KWMENG,
MEINS TYPE VBAP-MEINS,
END OF T_VBAP.
DATA: T_FIELDCATALOG1 TYPE SLIS_T_FIELDCAT_ALV.
DATA: T_FIELDCATALOG2 TYPE SLIS_T_FIELDCAT_ALV.
DATA: V_REPID TYPE SYREPID.
DATA: S_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA: V_TABNAME TYPE SLIS_TABNAME.
DATA: T_EVENTS TYPE SLIS_T_EVENT.
* start-of-selection event.
START-OF-SELECTION.
V_REPID = SY-REPID.
* Get the fieldcatalog for the first block
PERFORM GET_FIELDCAT1 CHANGING T_FIELDCATALOG1.
* Get the fieldcatalog for the second block
PERFORM GET_FIELDCAT2 CHANGING T_FIELDCATALOG2.
* Get the data for the first block
SELECT VBELN BSTNK ERDAT KUNNR
UP TO 10 ROWS
INTO TABLE T_VBAK
FROM VBAK
WHERE VBELN > '0060000100'.
* Get the data for the second block
SELECT VBELN MATNR NETPR WAERK KWMENG MEINS
UP TO 10 ROWS
INTO TABLE T_VBAP
FROM VBAP
WHERE VBELN > '0060000100'.
* init
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID.
* First block
V_TABNAME = 'T_VBAK'.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = S_LAYOUT
IT_FIELDCAT = T_FIELDCATALOG1
I_TABNAME = V_TABNAME
IT_EVENTS = T_EVENTS
TABLES
T_OUTTAB = T_VBAK.
* Second block
V_TABNAME = 'ITAB2'.
CALL FUNCTION
'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = S_LAYOUT
IT_FIELDCAT = T_FIELDCATALOG2
I_TABNAME = V_TABNAME
IT_EVENTS = T_EVENTS
TABLES
T_OUTTAB = T_VBAP.
*Display
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY' .
*---------------------------------------------------------------------*
* FORM GET_FIELDCAT1.
**---------------------------------------------------------------------*
* Get the field catalog for the first block
**---------------------------------------------------------------------*
FORM GET_FIELDCAT1 CHANGING LT_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV.
DATA: S_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV.
* Order number s_fieldcatalog-col_pos = '1'.
S_FIELDCATALOG-FIELDNAME = 'VBELN'.
S_FIELDCATALOG-TABNAME = 'T_VBAK'.
S_FIELDCATALOG-REF_TABNAME = 'VBAK'.
S_FIELDCATALOG-REF_FIELDNAME = 'VBELN'.
APPEND S_FIELDCATALOG TO LT_FIELDCATALOG.
CLEAR S_FIELDCATALOG.
* Customer purchase order. s_fieldcatalog-col_pos = '2'.
S_FIELDCATALOG-FIELDNAME = 'BSTNK'.
S_FIELDCATALOG-TABNAME = 'T_VBAK'.
S_FIELDCATALOG-REF_TABNAME = 'VBAK'.
S_FIELDCATALOG-REF_FIELDNAME = 'BSTNK'.
APPEND S_FIELDCATALOG TO LT_FIELDCATALOG.
CLEAR S_FIELDCATALOG.
* Creation date. s_fieldcatalog-col_pos = '3'.
S_FIELDCATALOG-FIELDNAME = 'ERDAT'.
S_FIELDCATALOG-TABNAME = 'T_VBAK'.
S_FIELDCATALOG-REF_TABNAME = 'VBAK'.
S_FIELDCATALOG-REF_FIELDNAME = 'ERDAT'.
APPEND S_FIELDCATALOG TO LT_FIELDCATALOG.
CLEAR S_FIELDCATALOG.
* Customer s_fieldcatalog-col_pos = '4'.
S_FIELDCATALOG-FIELDNAME = 'KUNNR'.
S_FIELDCATALOG-TABNAME ='T_VBAK'.
S_FIELDCATALOG-REF_TABNAME = 'VBAK'.
S_FIELDCATALOG-REF_FIELDNAME = 'KUNNR'.
APPEND S_FIELDCATALOG TO LT_FIELDCATALOG.
CLEAR S_FIELDCATALOG.
ENDFORM. "GET_FIELDCAT1
*---------------------------------------------------------------------*
* FORM GET_FIELDCAT2
**---------------------------------------------------------------------*
* Get the field catalog for the second block
**---------------------------------------------------------------------*
FORM GET_FIELDCAT2 CHANGING LT_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV.
DATA: S_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV.
* Order number s_fieldcatalog-col_pos = '1'.
S_FIELDCATALOG-FIELDNAME = 'VBELN'.
S_FIELDCATALOG-TABNAME = 'T_VBAP'.
S_FIELDCATALOG-REF_TABNAME = 'VBAP'.
S_FIELDCATALOG-REF_FIELDNAME = 'VBELN'.
APPEND S_FIELDCATALOG TO LT_FIELDCATALOG.
CLEAR S_FIELDCATALOG.
* Material number s_fieldcatalog-col_pos = '2'.
S_FIELDCATALOG-FIELDNAME = 'MATNR'.
S_FIELDCATALOG-TABNAME = 'T_VBAP'.
S_FIELDCATALOG-REF_TABNAME = 'VBAP'.
S_FIELDCATALOG-REF_FIELDNAME = 'MATNR'.
APPEND S_FIELDCATALOG TO LT_FIELDCATALOG.
CLEAR S_FIELDCATALOG.
* Net price s_fieldcatalog-col_pos = '3'.
S_FIELDCATALOG-FIELDNAME = 'NETPR'.
S_FIELDCATALOG-TABNAME = 'T_VBAP'.
S_FIELDCATALOG-REF_TABNAME = 'VBAP'.
S_FIELDCATALOG-REF_FIELDNAME = 'NETPR'.
S_FIELDCATALOG-CFIELDNAME = 'WAERK'.
S_FIELDCATALOG-CTABNAME = 'T_VBAP'.
APPEND S_FIELDCATALOG TO LT_FIELDCATALOG.
CLEAR S_FIELDCATALOG.
* Currency. s_fieldcatalog-col_pos = '4'.
S_FIELDCATALOG-FIELDNAME = 'WAERK'.
S_FIELDCATALOG-TABNAME = 'T_VBAP'.
S_FIELDCATALOG-REF_TABNAME = 'VBAP'.
S_FIELDCATALOG-REF_FIELDNAME = 'WAERK'.
APPEND S_FIELDCATALOG TO LT_FIELDCATALOG.
CLEAR S_FIELDCATALOG.
* QUANTITY
S_FIELDCATALOG-COL_POS = '5'.
S_FIELDCATALOG-FIELDNAME = 'KWMENG'.
S_FIELDCATALOG-TABNAME = 'T_VBAP'.
S_FIELDCATALOG-REF_TABNAME = 'VBAP'.
S_FIELDCATALOG-REF_FIELDNAME = 'KWMENG'.
S_FIELDCATALOG-QFIELDNAME = 'MEINS'.
S_FIELDCATALOG-QTABNAME = 'T_VBAP'.
APPEND S_FIELDCATALOG TO LT_FIELDCATALOG.
CLEAR S_FIELDCATALOG.
* UOM
S_FIELDCATALOG-COL_POS = '6'.
S_FIELDCATALOG-FIELDNAME = 'MEINS'.
S_FIELDCATALOG-TABNAME = 'T_VBAP'.
S_FIELDCATALOG-REF_TABNAME = 'VBAP'.
S_FIELDCATALOG-REF_FIELDNAME = 'MEINS'.
APPEND S_FIELDCATALOG TO LT_FIELDCATALOG.
CLEAR S_FIELDCATALOG.
ENDFORM. "GET_FIELDCAT2
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8356764/viewspace-941815/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [轉]分析函式 last_value的使用函式AST
- 回撥函式快速使用 (轉)函式
- 成員函式的說明和使用(轉)函式
- C++的函式和模板函式 (轉)C++函式
- Oracle 分析函式使用介紹(轉)Oracle函式
- 函式: 函式是怎麼使用的?函式
- 函式式 Java 到函式式 Kotlin 的轉換函式JavaKotlin
- typedef使用大全3(指向函式的指標) (轉)函式指標
- 函式組:TRUX 包含很多的轉換函式函式UX
- 【函式】Oracle12c 列轉行函式使用listagg函式Oracle
- oracle中ascii函式及to_char函式使用及編碼間的轉換OracleASCII函式
- 使用bind()函式的產生的函式用作建構函式this的指向函式
- DELPHI中使用API函式詳解 (轉)API函式
- Shell 函式的使用函式
- Thunk函式的使用函式
- Generator 函式的使用函式
- LNNVL函式的使用函式
- Loadrunner 使用者自定義函式使用[轉]函式
- 類的轉換函式函式
- Oracle的日期函式(轉)Oracle函式
- Excel函式應用教程:函式的引數(轉)Excel函式
- 使用MsFlexGrid控制元件的幾個函式 (轉)Flex控制元件函式
- round函式與trunc函式的使用方法函式
- numtoyminterval函式——數字轉換函式函式
- 如何使用函式指標呼叫類中的函式和普通函式函式指標
- 轉化函式函式
- 轉換函式函式
- fseek函式(轉)函式
- RegQueryValue函式 (轉)函式
- JavaScript 函式(轉)JavaScript函式
- Excel函式應用教程:函式的輸入方法(轉)Excel函式
- Excel函式應用教程:函式與公式的概念(轉)Excel函式公式
- 高階函式的使用函式
- tap函式的日常使用函式
- SQL CHARINDEX函式的使用SQLIndex函式
- perl printf函式的使用函式
- Oracle 分析函式的使用Oracle函式
- Oracle行轉列的函式Oracle函式