调用完创建物料的BAPI后,对质量管理视图中的“检验设置”维护检验类型等
BAPI_MATERIAL_SAVEDATA 调用成功后
代码片段:
data: return_qm like bapiret2 occurs 0 with header line,
lt_qmat like standard table of bapi1001004_qmat.
"检验类型
if gs_upload-plant eq '7100'.
gs_upload-material = headdata-material. "物料编号
clear lt_qmat[].
perform get_qm_insp tables lt_qmat[] using gs_upload.
if lt_qmat[] is not initial.
call function 'BAPI_MATINSPCTRL_SAVEREPLICA'
tables
inspectionctrl = lt_qmat
return = return_qm.
read table return_qm assigning field-symbol(<fs_return>) with key type = 'E'.
if sy-subrc = 0.
<wa_alv>-message = '出错:'(569) && <fs_return>-message.
call function 'BAPI_TRANSACTION_ROLLBACK'.
else.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
<wa_alv>-message = '成功'(434).
<wa_alv>-message = <wa_alv>-message && ';物料号为:'(435) && headdata-material.
endif.
endif.
endif.
*&---------------------------------------------------------------------*
*& Form GET_QM_INSP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_<WA_CRT_MAT> text
* <--P_LT_QMAT text
*----------------------------------------------------------------------*
form get_qm_insp tables lt_qmat structure bapi1001004_qmat using ls_data like gs_upload.
"新增 7100下的原料和膏体都需要配置QM视图
"物料类型=ZROH、ZRO1 检验类型=在库复检(Z302)
"物料类型= ZAL3+物料组不等于100300的物料 检验类型=Z303
data lt_qmat_s type qmat.
data: ls_qmat like bapi1001004_qmat.
data:lt_tq34 like standard table of tq34,
ls_tq34 like tq34.
call function 'CONVERSION_EXIT_MATN1_INPUT'
exporting
input = ls_data-material
importing
output = ls_data-material.
select single * from qmat into lt_qmat_s
where matnr = ls_data-material
and werks = ls_data-plant.
if ls_data-matl_type = 'ZROH' or ls_data-matl_type = 'ZRO1'.
ls_qmat-insptype = 'Z302'."检验类型
ls_qmat-ave_insp_duration = lt_qmat_s-mpdau."平均检验天数
append ls_qmat to lt_qmat.
clear ls_qmat.
elseif ls_data-matl_type = 'ZAL3' and ls_data-matl_group <> '100300'.
ls_qmat-insptype = 'Z303'."检验类型
ls_qmat-ave_insp_duration = lt_qmat_s-mpdau."平均检验天数
append ls_qmat to lt_qmat.
clear ls_qmat.
endif.
if lt_qmat[] is not initial.
select * from tq34 into corresponding fields of table lt_tq34
for all entries in lt_qmat
where art = lt_qmat-insptype.
endif.
loop at lt_qmat into ls_qmat.
read table lt_tq34 into ls_tq34 with key art = ls_qmat-insptype.
if sy-subrc = 0.
ls_qmat-plant = ls_data-plant.
ls_qmat-material = ls_data-material.
ls_qmat-ind_insp_with_tsk_list = ls_tq34-ppl ."有任务清单的检验
ls_qmat-ind_spec_matspec = ls_tq34-spezueber ."使用物料说明的检验
ls_qmat-ind_spec_config = ls_tq34-conf ."来自配置的检验规范
ls_qmat-ind_spec_batch = ls_tq34-tls ."批次确定的检验规范
ls_qmat-ind_auto_assign = ls_tq34-app ."自动规格分配
ls_qmat-ind_insp_by_charac = ls_tq34-mer ."按特性检验
ls_qmat-ind_post_to_insp_stock = ls_tq34-insmk ."过帐到检验库存
ls_qmat-ind_automatic_ud = ls_tq34-ave ."计划的自动用途决定
ls_qmat-sampling_procedure = ls_tq34-stichprver ."采样程序
ls_qmat-dyn_modif_rule = ls_tq34-dynregel ."动态修改规则
ls_qmat-insp_percentage = ls_tq34-sproz ."检验百分比
ls_qmat-ind_100_percent_inspection = ls_tq34-hpz ."100% 检验
ls_qmat-ind_skips_allowed = ls_tq34-dyn ."允许略过
ls_qmat-ind_manual_sample = ls_tq34-mpb ."手工输入采样
ls_qmat-ind_manual_sample_calc = ls_tq34-mst ."手动触发采样计算
ls_qmat-ind_single_units_possible = ls_tq34-ein ."可能的序列号管理
ls_qmat-contr_insp_lot_create = ls_tq34-chg ."控制检验批创建(批次摘要)
ls_qmat-qual_score_procedure = ls_tq34-qkzverf ."计算质量记分的程序
ls_qmat-allowed_scrap_share = ls_tq34-qpmat ."检验批中允许的废品份额(百分比)
"LS_QMAT-IND_SPECIAL_QM_ORDER = LS_TQ34-KZPRFKOST ."单个 QM 订单的记录评估成本
"LS_QMAT-QM_ORDERID = LS_TQ34-AUFNR_CO ."记录评估成本的订单号
"LS_QMAT-IND_INSPTYPE_MAT_ACTIVE = LS_TQ34-AKTIV ."检验类型 - 物料合并已激活
* ls_qmat-preferred_insptype = ls_tq34-apa ."首选的检验类型
ls_qmat-ind_hu_inspection = ls_tq34-afr ."处理单位的检验
ls_qmat-ms_flag = ls_tq34-ms_flag ."标识:多个规范
ls_qmat-ind_insptype_mat_active = 'X'."激活的
if ls_qmat-insptype eq 'Z101'.
ls_qmat-preferred_insptype = 'X'."首选检验类型
endif.
modify lt_qmat from ls_qmat.
clear ls_qmat.
endif.
endloop.
endform.