SAP ABAP直接调用标准程序取数

项目上有时候会遇到一些报表开发,可能时基于MB51的凭证查询后处理,或基于库存清单进行操作。这种需求其实在FS和开发上是都可以简化的,直接调用标准的报表数据进行加工,后续方案的调整等等对功能影响较小。

调用代码模板

if IV_SELECTION_SET_VARIANT is INITIAL.
  SUBMIT (IV_REPORT_NAME)
     WITH SELECTION-TABLE selection_table
    AND RETURN.
ELSE.
  SUBMIT (IV_REPORT_NAME)
     WITH SELECTION-TABLE selection_table
     USING SELECTION-SET IV_SELECTION_SET_VARIANT
    AND RETURN.
endif.
FIELD-SYMBOLS              TYPE ANY TABLE.
FIELD-SYMBOLS         TYPE ANY TABLE.
DATA          lr_data               TYPE REF TO data.
DATA          lr_data_line          TYPE REF TO data.
DATA          lr_data_descr          TYPE REF TO cl_abap_datadescr.
DATA          lr_data_line_descr    TYPE REF TO cl_abap_datadescr.
cl_salv_bs_runtime_info=>get_data_ref(
     IMPORTING r_data_descr      = lr_data_descr
                          r_data_line_descr = lr_data_line_descr ).
IF lr_data_descr IS NOT BOUND.
  ev_result_json = '[]'.
  EXIT.
ENDIF.

代码示例:


TABLES:EKKO,EKPO.
SELECT-OPTIONS:
S_LIFNR FOR EKKO-LIFNR,
S_EKORG FOR EKKO-EKORG,
S_EKGRP FOR EKKO-EKGRP,
S_MATNR FOR EKPO-MATNR,
S_EBELN FOR EKPO-EBELN.




FIELD-SYMBOLS  TYPE ANY TABLE.
FIELD-SYMBOLS  TYPE ANY TABLE.

DATA lr_data TYPE REF TO data.
DATA lr_data_line TYPE REF TO data.
DATA lr_data_descr TYPE REF TO cl_abap_datadescr.
DATA lr_data_line_descr TYPE REF TO cl_abap_datadescr.



CL_SALV_BS_RUNTIME_INFO=>SET( EXPORTING DISPLAY = ABAP_FALSE   METADATA = ABAP_FALSE DATA = ABAP_TRUE ).




SUBMIT RM07MSAL
WITH LIFNR IN S_LIFNR  "radiobutton 传参要用‘’
WITH EKORG IN S_EKORG
WITH EKGRP IN S_EKGRP
WITH MATNR IN S_MATNR
WITH EBELN IN S_EBELN
WITH FINAL = 'X'
WITH ALV_DEF = ''
WITH ZERO = ''
EXPORTING LIST TO MEMORY AND RETURN.


TRY.

cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data_descr = lr_data_descr
r_data_line_descr = lr_data_line_descr ).

CREATE DATA lr_data TYPE HANDLE lr_data_descr.
CREATE DATA lr_data_line TYPE HANDLE lr_data_line_descr.

ASSIGN lr_data->* TO .
ASSIGN lr_data_line->* TO .

cl_salv_bs_runtime_info=>get_data(
IMPORTING
t_data = 
t_data_line = 
).


CATCH cx_salv_bs_sc_runtime_info.
MESSAGE `无数据` TYPE 'E'.

ENDTRY.

cl_salv_bs_runtime_info=>clear_all( ).

你可能感兴趣的:(ERP-开发总结,ABAP,ALV,获取ALV数据)