*&---------------------------------------------------------------------*
*& Report ZCA03_LIST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZCA03_LIST.
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.
data : g_layout_s type slis_layout_alv.
data: l_fieldcat_s type slis_fieldcat_alv.
define __field_tab.
l_fieldcat_s-seltext_l = &1.
l_fieldcat_s-seltext_m = &1.
l_fieldcat_s-seltext_s = &1.
l_fieldcat_s-ddictxt = ' '.
end-of-definition.
tables: mapl,makt,plko,plpo,crtx,crhd,plpod.
data: begin of itab occurs 0,
matnr type mapl-matnr,"料号
maktx type makt-maktx,"物料描述
delkz type plko-delkz,"删除标记
werks type plko-werks,"工厂
vornr type plpo-vornr,"工序
arbid type plpo-arbid,"OBJECTID
arbpl type crhd-arbpl,"工作中心
ktext type crtx-ktext,
"工作中心描述(CRHD-ARBPL找到OBJID,通过OBJID和CRTX关联再找到工作中心描述
")
ktsch type plpo-ktsch,"标准文本
vgw01 type plpo-vgw01,"准备时间
vgw02 type plpo-vgw02,"机器时间
vgw03 type plpo-vgw03,"工时
vgw04 type plpo-vgw04,"工时
splim type plpo-splim,"分解数
andat type mapl-andat,"创建时间
aedat type plko-aedat,"最后更改时间
plnnr type mapl-plnnr,"组
end of itab.
selection-screen begin of block b1 with frame. title text-001.
select-options w_matnr for mapl-matnr.
select-options w_werks for mapl-werks.
selection-screen end of block b1.
selection-screen begin of block b2 with frame. title text-002.
select-options w_arbpl for plpod-arbpl.
selection-screen end of block b2.
selection-screen begin of block b3 with frame. title text-003.
select-options w_andat for mapl-andat.
select-options w_aedat for mapl-aedat.
selection-screen end of block b3.
initialization.
perform. layout_init using g_layout_s. "ALV GRID LAYOUT
perform. eventtab_build using g_events_t[]. "ALV GRID EVENT
start-of-selection.
if not ( w_matnr is initial ) and not ( w_arbpl is initial ).
message '同时只能选一个查询' type 'E'.
leave program.
endif.
if not ( w_matnr is initial ) and ( ( not w_andat is initial ) or (
not w_aedat is initial ) ).
message '同时只能选一个查询' type 'E'.
leave program.
endif.
if not ( w_arbpl is initial ) and ( ( not w_andat is initial ) or (
not w_aedat is initial ) ).
message '同时只能选一个查询' type 'E'.
leave program.
endif.
perform. get_data.
if sy-subrc = 0.
perform. displaycatalog_merge using g_fieldcat_t[] 'ITAB'.
perform. alv_display tables itab[].
* leave to screen 100.
else.
write: 'NO DATA'.
endif.
form. get_data.
data: i_crhd like crhd occurs 0.
if not ( w_matnr is initial ) or w_werks is not initial.
select mapl~matnr makt~maktx plko~delkz plko~werks plpo~vornr
plpo~arbid crhd~arbpl crtx~ktext plpo~ktsch plpo~vgw01 plpo~vgw02 plpo~vgw03 plpo~vgw04
plpo~splim mapl~andat plko~aedat mapl~plnnr
into corresponding fields of table itab
from mapl inner join plko "任务清单 - 表头
on mapl~plnnr = plko~plnnr and mapl~zaehl = plko~zaehl AND mapl~werks = plko~werks
inner join plpo "任务清单 - 工序/作业
on mapl~plnnr = plpo~plnnr "AND mapl~zaehl = plpo~zaehl
inner join crhd "工作中心表头
on plpo~arbid = crhd~objid
inner join crtx "工作中心或生产资源/工具文本
on plpo~arbid = crtx~objid
inner join makt on mapl~matnr = makt~matnr and makt~spras = sy-langu
where mapl~matnr in w_matnr and mapl~werks in w_werks and mapl~loEKZ eq space
.
exit.
endif.
if not ( w_arbpl is initial ).
*根据工作中心线获取PLPO~ARBID.
select objid into corresponding fields of table i_crhd
from crhd where arbpl in w_arbpl.
if lines( i_crhd[] ) > 0 .
select mapl~matnr makt~maktx
plpo~splim
plko~delkz plko~werks plpo~vornr
plpo~arbid crhd~arbpl crtx~ktext plpo~ktsch
plpo~vgw01 plpo~vgw02 plpo~vgw03 plpo~vgw04 mapl~andat plko~aedat mapl~plnnr
into corresponding fields of table itab
from plpo
inner join plko on plpo~plnnr = plko~plnnr
" AND plpo~zaehl = plko~zaehl
inner join mapl on plpo~plnnr = mapl~plnnr
and mapl~zaehl = plpo~zaehl
inner join crhd on plpo~arbid = crhd~objid
inner join crtx on plpo~arbid = crtx~objid
inner join makt on mapl~matnr = makt~matnr and makt~spras =
sy-langu
for all entries in i_crhd where plpo~arbid = i_crhd-objid and mapl~werks in w_WERKS and mapl~LOEKZ eq space
.
endif.
exit.
endif.
if ( not w_andat is initial ) or ( not w_aedat is initial ).
select mapl~matnr makt~maktx
plpo~splim
plko~delkz plko~werks plpo~vornr
plpo~arbid crhd~arbpl crtx~ktext plpo~ktsch
plpo~vgw01 plpo~vgw02 plpo~vgw03 plpo~vgw04 mapl~andat plko~aedat mapl~plnnr
into corresponding fields of table itab
from mapl inner join plko on mapl~plnnr = plko~plnnr
" AND mapl~zaehl = plko~zaehl
inner join plpo on mapl~plnnr = plpo~plnnr
and mapl~zaehl = plpo~zaehl
inner join crhd on plpo~arbid = crhd~objid
inner join crtx on plpo~arbid = crtx~objid
inner join makt on mapl~matnr = makt~matnr and makt~spras =
sy-langu
where mapl~werks in w_werks and mapl~andat in w_andat and plko~aedat IN w_aedat and mapl~LOEKZ eq space
.
exit.
endif.
endform. "GET_DATA
form. displaycatalog_merge using p_g_fieldcat_t
type slis_t_fieldcat_alv
p_tabname.
clear l_fieldcat_s.
l_fieldcat_s-fieldname = 'MATNR'.
l_fieldcat_s-no_zero = 'X'.
l_fieldcat_s-seltext_m = '料号'.
append l_fieldcat_s to p_g_fieldcat_t.
clear l_fieldcat_s.
l_fieldcat_s-fieldname = 'MAKTX'.
l_fieldcat_s-seltext_m = '物料描述'.
append l_fieldcat_s to p_g_fieldcat_t.
clear l_fieldcat_s.
l_fieldcat_s-fieldname = 'WERKS'.
l_fieldcat_s-seltext_m = '工厂'.
append l_fieldcat_s to p_g_fieldcat_t.
clear l_fieldcat_s.
l_fieldcat_s-fieldname = 'VORNR'.
l_fieldcat_s-seltext_m = '工序'.
append l_fieldcat_s to p_g_fieldcat_t.
clear l_fieldcat_s.
l_fieldcat_s-fieldname = 'KTSCH'.
l_fieldcat_s-seltext_m = '标准文本码'.
* l_fieldcat_s-outputlen = 20.
append l_fieldcat_s to p_g_fieldcat_t.
clear l_fieldcat_s.
l_fieldcat_s-fieldname = 'ARBPL'.
l_fieldcat_s-seltext_m = '工作中心'.
append l_fieldcat_s to p_g_fieldcat_t.
clear l_fieldcat_s.
l_fieldcat_s-fieldname = 'KTEXT'.
l_fieldcat_s-seltext_m = '工作中心描述'.
* l_fieldcat_s-outputlen = 20.
append l_fieldcat_s to p_g_fieldcat_t.
clear l_fieldcat_s.
l_fieldcat_s-fieldname = 'VGW01'.
l_fieldcat_s-seltext_m = '准备时间'.
append l_fieldcat_s to p_g_fieldcat_t.
clear l_fieldcat_s.
l_fieldcat_s-fieldname = 'VGW02'.
l_fieldcat_s-seltext_m = '机器时间'.
append l_fieldcat_s to p_g_fieldcat_t.
clear l_fieldcat_s.
l_fieldcat_s-fieldname = 'VGW03'.
l_fieldcat_s-seltext_m = '工时'.
append l_fieldcat_s to p_g_fieldcat_t.
clear l_fieldcat_s.
l_fieldcat_s-fieldname = 'VGW04'.
l_fieldcat_s-seltext_m = '产能'.
append l_fieldcat_s to p_g_fieldcat_t.
* CLEAR l_fieldcat_s.
* l_fieldcat_s-fieldname = 'SPLIM'.
* l_fieldcat_s-seltext_m = '分解数'.
*
* APPEND l_fieldcat_s TO p_g_fieldcat_t.
clear l_fieldcat_s.
l_fieldcat_s-fieldname = 'ANDAT'.
l_fieldcat_s-seltext_m = '创建时间'.
append l_fieldcat_s to p_g_fieldcat_t.
clear l_fieldcat_s.
l_fieldcat_s-fieldname = 'AEDAT'.
l_fieldcat_s-seltext_m = '最后更改时间'.
append l_fieldcat_s to p_g_fieldcat_t.
clear l_fieldcat_s.
l_fieldcat_s-fieldname = 'PLNNR'.
l_fieldcat_s-seltext_m = '组'.
append l_fieldcat_s to p_g_fieldcat_t.
endform. " FIELDCATALOG_MERGE
*&--------------------------------------------------------------------*
*& Form LAYOUT_INIT
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->P_G_LAYOUT_text
*---------------------------------------------------------------------*
form. layout_init using p_g_layout_s type slis_layout_alv.
** Build layout for list display
p_g_layout_s-detail_popup = 'X'.
p_g_layout_s-colwidth_optimize = 'X'.
* p_g_layout_s-no_vline = 'X'.
endform. " LAYOUT_INIT
*--------------------------------------------------------------------
* FORM. EVENTTAB_BUILD
*--------------------------------------------------------------------
form. eventtab_build using p_g_events_t type slis_t_event.
** Registration of events to happen during list display
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. ALV_DISPLAY
*--------------------------------------------------------------------
form. alv_display tables p_int_t.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = 'ZPP_R_012' "G_REPID
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