SAP ABAP调用标准报表执行结果

2023-10-13 19:00:08 浏览数 (2)

有时候我们需要拿到标准报表的结果来进行一些操作:例如:MB5M执行结果 SUBMIT将所需要的参数传进去,一般标准报表:对于ALV展示效果最好选择ALV网格,这样输出的字段会比较全

代码语言:javascript复制
*&---------------------------------------------------------------------*
*& Report ZSY_ZM_TEST16
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zsy_zm_test16.

TABLES:marav,marcv,mard,mchb.
DATA:lr_alv_data TYPE REF TO data.

FIELD-SYMBOLS : <lt_alv_data> TYPE ANY TABLE .
FIELD-SYMBOLS : <lt_data> TYPE any. "LIKE LINE OF  it_tab .

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-000.
  SELECT-OPTIONS: s_matnr FOR marav-matnr,  "物料
                  s_werks FOR marcv-werks,   "工厂
                  s_lgort FOR mard-lgort,   "存储位置
                  s_charg FOR mchb-charg.   "批次

  PARAMETERS: p_lagrlz LIKE am07m-lgrlz RADIOBUTTON GROUP list,  "剩余的货架寿命
              p_gesrlz LIKE am07m-gsrlz RADIOBUTTON GROUP list DEFAULT 'X'.  "总剩余货架寿命
SELECTION-SCREEN END OF BLOCK b1.
*&---------------------------------------------------------------------*
*& "计算特殊库存E的期初期末
*&---------------------------------------------------------------------*
START-OF-SELECTION.
  cl_salv_bs_runtime_info=>set( EXPORTING display  = abap_false
                                          metadata = abap_false
                                          data     = abap_true ).
  CLEAR lr_alv_data.
  UNASSIGN <lt_alv_data>.

  SUBMIT rm07mmhd                                         "MB5B特殊库存及搜索条件
         WITH matnr IN s_matnr
         WITH werks IN s_werks
*       WITH lgort EQ so_lgort-low "循环获取每个库存地点的期初期末
         WITH lgort IN s_lgort
         WITH charg IN s_charg
         "库存类型-特殊库存
         WITH lagrlz EQ p_lagrlz
         WITH gesrlz EQ p_gesrlz
         WITH p_grid EQ 'X'
         AND RETURN.

  TRY.
      cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = lr_alv_data ).

      ASSIGN lr_alv_data->* TO <lt_alv_data>.
    CATCH cx_salv_bs_sc_runtime_info.

      MESSAGE 'Unable to retrieve ALV data! Please try other conditions.' TYPE 'E'.
  ENDTRY.

  cl_salv_bs_runtime_info=>clear_all( ).

  "
  IF <lt_alv_data> IS ASSIGNED.
    UNASSIGN <lt_data>.
    LOOP AT <lt_alv_data> ASSIGNING <lt_data>."即所需要内表数据

    ENDLOOP.
  ENDIF.

0 人点赞