ABAP 取标准报表测试程序

Posted jimi520

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ABAP 取标准报表测试程序相关的知识,希望对你有一定的参考价值。

*&---------------------------------------------------------------------*

*& 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:

    <lt_data> type standard table,

    <L_DATA>  TYPE ANY.

 

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 XSUM = ‘‘

*    WITH PA_SUMFL = ‘X‘

*    WITH XCHAR = ‘‘

*    WITH LGBST = ‘‘

*    WITH BWBST = ‘X‘

    AND RETURN.

 

 

TRY.

  CALL METHOD CL_SALV_BS_RUNTIME_INFO=>GET_DATA_REF

    IMPORTING

      R_DATA            = LS_DATA.

  ASSIGN LS_DATA->* TO <LT_DATA>.

CATCH CX_SALV_BS_SC_RUNTIME_INFO.

*  MESSAGE ‘无法获取ALV数据‘ TYPE ‘E‘.

ENDTRY.

 

 

CL_SALV_BS_RUNTIME_INFO=>CLEAR_ALL( ).

 

 

IF <LT_DATA> IS ASSIGNED.

    LOOP AT <LT_DATA> ASSIGNING <L_DATA>.

*    MOVE-CORRESPONDING <L_DATA> TO LW_MB5B.

*    APPEND LW_MB5B TO LT_MB5B.

*    CLEAR LW_MB5B.

         MOVE-CORRESPONDING <L_DATA> TO LTH_MB5B.

         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.

以上是关于ABAP 取标准报表测试程序的主要内容,如果未能解决你的问题,请参考以下文章

2020.01.11 ABAP随笔获取标准报表数据(MB52)数据进行客制ALV

abap 获取生产订单标准工时和实际报工工时的报表

ABAP 报表

sap abap报表显示的问题

abap简单报表,alv显示,按钮事件

ABAP-动态程序生成