SAP ABAP - Retrieve Data From Standard Program MB52 Report to Custom Report
*&---------------------------------------------------------------------*
*& Report YMB52*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ymb52.
TABLES : mara, marc, mard, mchb.
DATA: BEGIN OF gt_mb52 OCCURS 0,
matnr LIKE mara-matnr,
werks LIKE t001w-werks,
lgort LIKE mard-lgort,
sobkz LIKE mkol-sobkz,
ssnum LIKE bickey-ssnum,
pspnr LIKE mspr-pspnr,
vbeln LIKE mska-vbeln,
posnr LIKE mska-posnr,
lifnr LIKE mkol-lifnr,
kunnr LIKE msku-kunnr,
kzbws LIKE mssa-kzbws,
charg LIKE mchb-charg,
maktx LIKE marav-maktx,
bwkey LIKE mbew-bwkey,
mtart LIKE marav-mtart,
matkl LIKE marav-matkl,
meins LIKE marav-meins,
bwtty LIKE marc-bwtty,
xchar LIKE marc-xchar,
lgobe LIKE t001l-lgobe,
bwtar LIKE mcha-bwtar,
waers LIKE t001-waers,
name1 LIKE t001w-name1,
labst LIKE mard-labst,
wlabs LIKE mbew-salk3,
sgt_scat LIKE mchb-sgt_scat.
DATA: owner LIKE msis-owner,
lifnr2 LIKE mslb-lifnr.
DATA: END OF gt_mb52,
gs_mb52 LIKE LINE OF gt_mb52.
DATA: BEGIN OF gs_data.
INCLUDE STRUCTURE gs_mb52.
DATA:
END OF gs_data,
gt_data LIKE TABLE OF gs_data.
CONSTANTS:
c_x TYPE c VALUE 'X'.
DATA :
go_data TYPE REF TO data.
FIELD-SYMBOLS:
<gt_data> TYPE ANY TABLE.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : s_matnr FOR mara-matnr,
s_werks FOR marc-werks,
s_lgort FOR mard-lgort,
s_charg FOR mchb-charg.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM get_data.
FORM get_data.
cl_salv_bs_runtime_info=>set(
EXPORTING
display = abap_false
metadata = abap_false
data = abap_true ).
SUBMIT rm07mlbs
WITH matnr IN s_matnr
WITH werks IN s_werks
WITH lgort IN s_lgort
WITH charg IN s_charg
WITH negativ = abap_false
WITH pa_sond = abap_true
WITH xmchb = abap_true
WITH nozero = c_x
WITH novalues = abap_false
WITH pa_hsq = abap_false
WITH pa_flt = c_x
WITH p_vari = abap_false
AND RETURN.
"Get data from MB52
TRY.
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = go_data ).
ASSIGN go_data->* TO <gt_data>.
"Keep mb52 data into internal table
IF <gt_data> IS ASSIGNED.
LOOP AT <gt_data> ASSIGNING FIELD-SYMBOL(<fs_data1>).
MOVE-CORRESPONDING <fs_data1> TO gs_data.
APPEND gs_data TO gt_data.
ENDLOOP.
ENDIF.
CATCH cx_salv_bs_sc_runtime_info ##NO_HANDLER.
MESSAGE 'Unable to retrieve alv data' TYPE 'e'.
ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ).
cl_demo_output=>display_data( gt_data ).
ENDFORM.
Comments
Post a Comment