*&---------------------------------------------------------------------*
*& Report ZMB5B_TEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZMB5B_TEST.
TABLES:
MKPF,
MSEG.
TYPES:
BEGIN OF TYP_MB5B,
MATNR TYPE MSEG-MATNR,
WERKS TYPE MSEG-WERKS,
NAME1 TYPE T001W-NAME1,
START_DATE TYPE SY-DATUM, "开始日期
END_DATE TYPE SY-DATUM, "结束日期
ANFMENGE TYPE MSEG-MENGE, "期初库存
ENDMENGE TYPE MSEG-MENGE, "期末库存
END OF TYP_MB5B.
DATA:
LTH_MB5B TYPE TYP_MB5B,
TD_MB5B TYPE TABLE OF TYP_MB5B,
LS_DATA TYPE REF TO DATA.
field-symbols:
SELECT-OPTIONS:
S_WERKS FOR MSEG-WERKS,
S_MATNR FOR MSEG-MATNR,
S_BUDAT FOR MKPF-BUDAT.
START-OF-SELECTION.
CALL METHOD CL_SALV_BS_RUNTIME_INFO=>SET
EXPORTING
DISPLAY = ABAP_FALSE
METADATA = ABAP_FALSE
DATA = ABAP_TRUE.
SUBMIT RM07MLBD "Tcode MB5B
WITH MATNR IN S_MATNR
WITH WERKS IN S_WERKS "填写筛选屏幕字段
WITH DATUM IN S_BUDAT
* WITH LGORT EQ SPACE "每个库存地点
* WITH SOBKZ EQ SPACE
WITH DATUM IN SC_BUDAT
"库存类型-特殊库存
* WITH LGBST EQ SPACE
* WITH BWBST EQ 'X'
* WITH SBBST EQ SPACE
"清单范围
* WITH PA_WDZER EQ SPACE
* WITH PA_WDZEW EQ 'X'
* WITH PA_WDWIZ EQ 'X'
* WITH PA_WDWUW EQ 'X'
* WITH PA_WDWEW EQ 'X'
* WITH PA_NDZER EQ SPACE
* WITH PA_NDSTO EQ 'X'
"设置
* WITH PA_SFLVA EQ 'T1'
WITH PA_SUMFL EQ 'X'
* WITH XCHAR EQ SPACE
* WITH XNOMCHB EQ SPACE
* WITH XNOMCHB EQ SPACE
* WITH NOSTO EQ SPACE
* WITH PA_DBSTD EQ 'X'
* VIA SELECTION-SCREEN
AND RETURN
.
AND RETURN.
TRY.
CALL METHOD CL_SALV_BS_RUNTIME_INFO=>GET_DATA_REF
IMPORTING
R_DATA = LS_DATA.
ASSIGN LS_DATA->* TO
CATCH CX_SALV_BS_SC_RUNTIME_INFO.
* MESSAGE '无法获取ALV数据' TYPE 'E'.
ENDTRY.
CL_SALV_BS_RUNTIME_INFO=>CLEAR_ALL( ).
IF
LOOP AT
* MOVE-CORRESPONDING
* APPEND LW_MB5B TO LT_MB5B.
* CLEAR LW_MB5B.
MOVE-CORRESPONDING
APPEND LTH_MB5B TO TD_MB5B.
CLEAR LTH_MB5B.
ENDLOOP.
ENDIF.
LOOP AT TD_MB5B INTO LTH_MB5B.
WRITE: / LTH_MB5B-MATNR, '||',
LTH_MB5B-WERKS, '||',
LTH_MB5B-START_DATE, '||',
LTH_MB5B-END_DATE, '||',
LTH_MB5B-ANFMENGE, '||',
LTH_MB5B-ENDMENGE.
CLEAR LTH_MB5B.
*
ENDLOOP.