*&---------------------------------------------------------------------*
*& Report ZTEST_SEAMAN
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report ztest_seaman no standard page heading line-size 1000.
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* A sample program to extract data from the MRP table.
*
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
type-pools:slis.
data: i_fieldcat type slis_t_fieldcat_alv,
l_fieldcat type slis_fieldcat_alv,
xevents type slis_t_event,
ls_event type slis_alv_event,
slis_ev_top type slis_formname value 'TOP_OF_PAGE'.
data: v_repid like sy-repid.
data: gs_tabname_header type slis_tabname,
gs_tabname_item type slis_tabname,
gs_keyinfo type slis_keyinfo_alv.
tables: mdkp, "Header Data for MRP Document
mdtb, "MRP table
mdtc, "Aggregated MRP table items
t457t. "Description of MRP elements
data: begin of mdtbx occurs 0.
include structure mdtb.
data: end of mdtbx.
select-options: plant for mdkp-plwrk obligatory,
matnr for mdkp-matnr obligatory,
delnr for mdtb-delnr.
clear: mdkp, mdtb.
select * from mdkp where dtart eq 'MD'
and matnr in matnr
and plwrk in plant.
if mdkp-cflag eq 'X'.
clear mdtbx. refresh mdtbx.
import mdtbx from database mdtc(ar) id mdkp-dtnum.
loop at mdtbx.
move mdtbx to mdtb.
select single * from t457t where spras = 'E'
and delkz = mdtb-delkz.
if mdtb-plumi = '-'. multiply mdtb-mng01 by -1. endif.
endloop.
else.
select * from mdtb
where dtnum eq mdkp-dtnum
order by primary key.
select single * from t457t where spras = 'E'
and delkz = mdtb-delkz.
if mdtb-plumi = '-'. multiply mdtb-mng01 by -1. endif.
endselect.
endif.
endselect.
*ALV显示
* sort itab by zmatnr.
read table xevents with key name = slis_ev_top
into ls_event.
if sy-subrc = 0.
move slis_ev_top to ls_event-form.
append ls_event to xevents.
endif.
gs_tabname_header = 'MDTBX'.
v_repid = sy-repid.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = v_repid
i_internal_tabname = gs_tabname_header
i_inclname = v_repid
* I_STRUCTURE_NAME = 'MDTBX'
* i_inclname = v_repid
* i_bypassing_buffer = 'X'
* i_buffer_active = ''
changing
ct_fieldcat = i_fieldcat
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
if sy-subrc 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_bypassing_buffer = 'X'
i_buffer_active = ''
i_callback_program = v_repid
it_fieldcat = i_fieldcat
i_save = 'A'
it_events = xevents
tables
t_outtab = mdtbx
exceptions
program_error = 1
others = 2.
if sy-subrc 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
*&--------------------------------------------------------------*
*& FORM TOP OF PAGE
*&--------------------------------------------------------------*
* TEXT
*---------------------------------------------------------------*
form top_of_page.
write:/ 'Read MRP Result Report'.
endform. "top_of_p