S_MATNR 物料号
S_PERXX 需求期间
S_WERKS 工厂
________ ______________________________
________ ______________________________
*&---------------------------------------------------------------------*
*& Report ZSD_R_010
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report zsd_r_10.
type-pools: slis.
types: slis_t_fieldcat_alv type slis_fieldcat_alv occurs 1.
data: g_events_t type slis_t_event,
g_fieldcat_t type slis_t_fieldcat_alv,
g_layout_s type slis_layout_alv,
l_fieldcat_s type slis_fieldcat_alv.
define field_build.
clear l_fieldcat_s.
l_fieldcat_s-fieldname = &1.
l_fieldcat_s-seltext_m = &2.
append l_fieldcat_s to g_fieldcat_t.
end-of-definition.
tables:pbim,pbed."pbid
data:begin of itab occurs 0,
werks like pbim-werks, "工厂
bedae like pbim-bedae, "需求类型
matnr like pbim-matnr, "物料号
maktx like makt-maktx, "
perxx like pbed-perxx, "计划期间
pdatu like pbed-pdatu,
plnmg like pbed-plnmg, "计划数量
aenam like pbed-aenam, "人员
labst like mard-labst, "非限制使用的估价的库存
end of itab.
selection-screen begin of block bl1 with frame title text-001.
select-options:
s_werks for pbim-werks, "
s_perxx for pbed-perxx, "
s_bedae for pbim-bedae, "
s_matnr for pbim-matnr. "
selection-screen end of block bl1.
initialization.
perform layout_init using g_layout_s. "ALV GRID LAYOUT
perform eventtab_build using g_events_t[]. "ALV GRID EVENT
start-of-selection.
* PERFORM chk_authority.
perform get_data.
perform displaycatalog_merge using g_fieldcat_t[] 'ITAB'.
perform alv_display tables itab[].
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_data .
select a~werks a~bedae a~matnr b~perxx b~plnmg b~aenam b~pdatu
d~labst c~maktx
into corresponding fields of table itab
from pbim as a
inner join pbed as b on b~bdzei = a~bdzei
inner join makt as c on c~matnr = a~matnr
left join mard as d on d~matnr = a~matnr and d~lgort = '1042'
and d~werks = a~werks
where a~werks in s_werks
and a~bedae in s_bedae
and a~matnr in s_matnr
and b~perxx in s_perxx.
loop at itab.
call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
exporting
input = itab-matnr
importing
output = itab-matnr.
modify itab.
if itab-perxx is not initial.
clear itab-pdatu.
modify itab.
endif.
endloop.
sort itab by matnr perxx.
endform. " GET_DATA
*&---------------------------------------------------------------------*
*& Form DISPLAYCATALOG_MERGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_G_FIELDCAT_T[] text
* -->P_0133 text
*----------------------------------------------------------------------*
form displaycatalog_merge using p_g_fieldcat_t
type slis_t_fieldcat_alv
p_tabname.
field_build 'WERKS' '工厂'.
field_build 'BEDAE' '需求类型'.
field_build 'MATNR' '物料号'.
field_build 'MAKTX' '物料描述'.
field_build 'PERXX' '计划期间'.
field_build 'PDATU' '计划日期'.
field_build 'PLNMG' '计划数量'.
field_build 'AENAM' '修改人'.
field_build 'LABST' '备机仓库存'.
endform. " DISPLAYCATALOG_MERGE
*&---------------------------------------------------------------------*
*& Form ALV_DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ITAB[] text
*----------------------------------------------------------------------*
form alv_display tables p_int_t.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-repid
i_callback_user_command = 'USER_CALLBACK'
is_layout = g_layout_s
it_fieldcat = g_fieldcat_t[]
i_save = 'A'
tables
t_outtab = p_int_t
exceptions
program_error = 1
others = 2.
endform. " ALV_DISPLAY
*&---------------------------------------------------------------------*
*& Form user_callback
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RF_UCOMM text
* -->RS_SELFIELD text
*----------------------------------------------------------------------*
form user_callback using rf_ucomm type sy-ucomm
rs_selfield type slis_selfield.
case rf_ucomm.
when '&IC1'.
data msg type string.
field-symbols
read table itab index rs_selfield-tabindex assigning
if sy-subrc = 0.
set parameter id: 'MAT' field
set parameter id: 'WRK' field
set parameter id: 'BDA' field
call transaction 'MD63' and skip first screen.
endif.
endcase.
endform. " user_callback
*&---------------------------------------------------------------------*
*& Form eventtab_build
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_G_EVENTS_T text
*----------------------------------------------------------------------*
form eventtab_build using p_g_events_t type slis_t_event.
data: l_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_g_events_t.
* GUI STATUS
read table p_g_events_t with key name = slis_ev_pf_status_set
into l_event.
if sy-subrc eq 0.
move 'PF_STATUS_SET' to l_event-form.
append l_event to p_g_events_t.
endif.
endform. " EVENTTAB_BUILD
*&---------------------------------------------------------------------*
*& Form layout_init
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_G_LAYOUT_S text
*----------------------------------------------------------------------*
form layout_init using p_g_layout_s type slis_layout_alv.
p_g_layout_s-detail_popup = 'X'.
p_g_layout_s-colwidth_optimize = 'X'.
endform. " LAYOUT_INIT