*&---------------------------------------------------------------------*
*& Report ZPP_CA02
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
前提,BOM中的排序字符串中的值和工艺路线中工序的标准文本码相同
report zpp_ca02.
tables mara .
tables marc.
data i_mapl like table of mapl with header line.
data subrc type sy-subrc.
data messtab like bdcmsgcoll occurs 0.
data wa_messatab like bdcmsgcoll.
data: matnr_001 type bdcdata-fval.
data: werks_002 type bdcdata-fval.
data: p_model type c.
data: w_msg(200) type c.
data: begin of i_matnr occurs 0,
matnr like marc-matnr,
werks like marc-werks,
end of i_matnr.
select-options s_matnr for mara-matnr.
select-options s_werks for marc-werks obligatory.
parameters p_model1 type c radiobutton group r1.
parameters p_model2 type c radiobutton group r1.
parameters p_tag type c as checkbox.
start-of-selection.
clear i_mapl[].
clear i_matnr[].
select distinct matnr werks
into corresponding fields of table i_mapl "UP TO 10 ROWS
from mapl
where matnr in s_matnr and werks in s_werks and loekz = space.
select matnr werks
into corresponding fields of table i_matnr
from marc
where matnr in s_matnr and werks in s_werks.
if p_model1 eq 'X'.
p_model = 'N'.
else.
p_model = 'A'.
endif.
if lines( i_mapl ) write '没有工艺存在' color col_negative.
exit.
endif.
loop at i_matnr.
clear w_msg.
read table i_mapl with key matnr = i_matnr-matnr werks = i_matnr-werks.
if sy-subrc ne 0.
concatenate '物料:' i_matnr-matnr+9(9) '在工厂:' i_matnr-werks '没有工艺路线' INTO w_msg.
write w_msg color col_negative.
skip.
endif.
endloop.
clear w_msg.
loop at i_mapl.
matnr_001 = i_mapl-matnr.
werks_002 = i_mapl-werks.
call function 'ZCA02'
exporting
* CTU = 'X'
mode = p_model
* UPDATE = 'L'
* GROUP = GROUP
* USER = USER
* KEEP = KEEP
* HOLDDATE = HOLDDATE
* NODATA = '/'
matnr_001 = matnr_001
werks_002 = werks_002
* PLNNR_003 = '10008203'
* STTAG_004 = '2010.11.08'
* PLNAL_005 = ''
* ENTRY_ACT_006 = '1'
* SORTF_007 = 'X'
* SORTF_008 = 'ai'
* VORNR_009 = '0010'
* PLNFL_010 = '0'
* SORTF_011 = 'X'
* SORTF_012 = 'dip'
* VORNR_013 = '0020'
* PLNFL_014 = '0'
p_tag = p_tag
importing
subrc = subrc
tables
messtab = messtab
.
endloop.