物料主数据批导程序
作者:互联网
*&---------------------------------------------------------------------*
*& 程序名称 :Z_MM_001 *
*& 程序目的 :物料主数据批导程序
*&---------------------------------------------------------------------*
report z_mm_001.
tables: mara, " General Material Data
marc, " Material Master: C Segment
marm, " Units of Measure
mast, " Material to BOM Link
t001w, " Plants/Branches
t100,
tq34,
t006a.
data: begin of itab occurs 0.
data: bismt(018). "旧物料号****
data: maktx1(040). "旧物料描述****
data: vflag. "模块标志 ****
data: matnr(018). "物料号 ****
data: maktx(040). "物料描述****
data: mbrsh(001). "行业领域****
data: mtart(004). "物料类型****
data: werks(004). "工厂 ****
data: lgort1(004).
data: vkorg(004). "销售组织****
data: vtweg(002). "分销渠道****
data: maktxf(040). "物料描述繁体****
data: maktxe(040). "物料描述英文****
data: maktxp(040). "葡萄牙物料长文本****
data text(132). "长文本备注
data: meins(003). "基本计量单位****
data: matkl(009). "物料组****
data: ematkl(18). "外部物料组(18)
data: labor(03). "实验室/办公室(18)
data: bismt1(018). "东莞旧物料号码(18)
data: bismt2(018). "台湾旧物料号码(18) 生产/检验备忘录
data: bismt3(018). "宁波旧物料号码(18)
*DATA: NORMT(018). "行业标准描述
data: groes(032). "大小/量纲 (32)***
data: brgew(017). "毛重***
data: ntgew(017). "净重***
data: gewei(003). "重量单位****
data: volum(18). "体积****
data: voleh(003). "体积单位 (3)****
data: mstae(02). "跨工厂物料状态****
data: mstde(10). "有效起始期****
data: vrkme(03). "销售单位****
data: spart(02). "部门/产品组****
data: umren1(03). "转换为基本计量单位的分母 (3)****
data: umrez1(03). "基本计量单位转换分子****
data: dwerk(04). "交货工厂***
data: taxkm(01). "税码***
data: versg(01). "物料统计组****
data: mtpos(04). "项目类别组****
data: ktgrm(02). "科目设置组****
data: tragr(04). "运输组****
data: mtvfp(02). "可用量检查****
data: ladgr(04). "装载组****
data: prctr(10). "利润中心****
data: bstme(03). "采购单位****
data: umren(03). "转换为基本计量单位的分母 (3)****
data: umrez(03). "基本计量单位转换分子****
data: ekgrp(003). "采购组 ****
data: xchpf(001). "批次管理(1) ****
data: kordb. "货源清单
data: lgort(010). "库存仓位 ****
data: dismm(002). "MRP 类型 ****
data: maabc(001). "ABC标识 ****
data: dispo(003). "MRP控制员*****
data: mmsta(002). "特定工厂的物料状态*****
data: disgr(004). "MRP组 (4)*****-DISGR
data: disls(002). "批量 (2)*****
data: bstfe(018). "固定批量 (13,3)*****
data: bstrf(013). "舍人值 (13)*****
data: beskz(001). "采购类型*****
data: sobsl(002). "特殊采购类型*****
data: rgekz(002). "反冲*****
data: dzeit(003). "自制生产(2)*****
data: lgpro(004). "生产仓储地点*****
data: lgfsb(004). "外部采购库存地点 *****
data: plifz(003). "计划交货时间 (3) *****
data: eisbe(018). "安全库存 (13,3) *****
data: fhori(003). "计划边际码 (3) ****
data: mtvfp1(002). "可用性检查 (2) ****
data: sbdkz(001). "独立/集中 ****
data: kausf(006). "部件废品(%) ****
data: rbnrm(009). "类别参数文件 ****
data: prfrq(005). "检验间隔时间(5) * ****
data: qmpur(001). "QM采购激活 ****
data: ssqss(008). "QM 控制码 ****
data: kzdkz(001). "须要纪录文件(1)***
data: art_01(008). "检验类型1***
data: art_02(008). "检验类型2***
data: art_03(008). "检验类型3***
data: art_04(008). "检验类型4***
data: art_05(008). "检验类型5***
data: art_06(008). "检验类型6***
data: bklas(004). "评估类 (4) ****
data: vprsv(001). "价格控制( ****
data: verpr(015). "移动平均价 ****
data: stprs(015). "标准价格 ****
data: peinh(5). "价格单位 ****
data: losgr(013). "核算批量(13)*****
data: prctr1(010). "利润中心 ****
data: ncost(001). "无成本核算(1) ****
data: ekalr(001). "QS估算(1) ****
data: hkmat(001). "物料相关的源****
data: awsls(006). "差异码 **** "转换比例fm
data: end of itab.
data: begin of vws_itab occurs 0 , "视图内表
material(18), " 0 物料号
ind_sector, " 0 行业领域
matl_type(4), " 0 物料类型
basic_view, " 0 基本数据视图
sales_view, " 0 销售视图
purchase_view, " 0 采购视图
mrp_view, " 0 物料需求计划(MRP)视图
forecast_view, " 0 预测视图
work_sched_view, " 0 工作计划视图
prt_view, " 生产资源/工具(PRT)视图
storage_view, " 0 存储视图
warehouse_view, " 0 仓库管理视图
quality_view, " 0 质量管理视图
account_view, " 0 会计视图
cost_view, " 0 成本视图
end of vws_itab.
data: begin of out_put occurs 0,
bismt(018), "旧物料号****
maktx1(040), "旧物料描述****
vflag, "模块标志 ****
matnr(018), "物料号 ****
maktx(040), "物料描述****
werks(4)," 工厂
text(100), "输出信息
end of out_put.
data: bapi_makt like bapi_makt occurs 0 with header line .
*-* Units of Measure
data: bapi_marm like bapi_marm occurs 0 with header line .
*-* Checkbox Structure for BAPI_MARM
data: bapi_marmx like bapi_marmx occurs 0 with header line .
*-* International Article Numbers (EANs)
data: bapi_mean like bapi_mean occurs 0 with header line .
*-* Long Texts
data: bapi_mltx like bapi_mltx occurs 0 with header line .
*-* Tax Data
data: bapi_mlan like bapi_mlan occurs 0 with header line .
*-* Substitute Structure for Return Parameter BAPIRET2
data: bapi_matreturn2 like bapi_matreturn2 occurs 0 with header line .
*-* Production Resource Tool (PRT) Fields in the Material Master
data: bapi_mfhm like bapi_mfhm occurs 0 with header line .
*-* Checkbox Structure for BAPI_MFHM
data: bapi_mfhmx like bapi_mfhmx occurs 0 with header line .
*-* Ref. structure for BAPI parameter ExtensionIn/ExtensionOut
data: bapiparex like bapiparex occurs 0 with header line .
*-* Checkbox Structure for Extension In/Extension Out
data: bapiparexx like bapiparexx occurs 0 with header line .
*-* /NFM/: NF Charge Weights for Materials on Org. Level
data: nfmchargeweights like /nfm/bapitvgw occurs 0 with header line .
*-* /NFM/: Update Information for /NFM/BAP
data: nfmchargeweightsx like /nfm/bapitvgwx occurs 0 with header line .
*-* /NFM/: NF Structural Weights
data: nfmstructuralweights like /nfm/bapitkgw occurs 0 with header line .
*-* /NFM/: Update Information for /NFM/BAPITKGW
data: nfmstructuralweightsx like /nfm/bapitkgwx occurs 0 with header line .
data: bapi1001004_qmat like bapi1001004_qmat occurs 0 with header line .
*-* Returned Parameters
data: return like bapiret2." OCCURS 0 WITH HEADER LINE .
*
data: return1 like bapiret2 occurs 0 with header line .
data: inspectionctrl like bapi1001004_qmat occurs 0 with header line .
*
data: qm_return like bapiret2 occurs 0 with header line.
* define structure data for BAPIs function of material master creation
data: headdata like bapimathead. "Header Segment with Control Information
data: bapi_mara like bapi_mara. "Material Data at Client Level
data: bapi_marax like bapi_marax. "Checkbox Structure for BAPI_MARA
data: bapi_marc like bapi_marc. "Material Data at Plant Level
data: bapi_marcx like bapi_marcx. "Checkbox Structure for BAPI_MARC
data: bapi_mpop like bapi_mpop. "Forecast Parameters
data: bapi_mpopx like bapi_mpopx. "Checkbox Structure for BAPI_MPOP
data: bapi_mpgd like bapi_mpgd. "Change Document Structure for Material Master/Product Group
data: bapi_mpgdx like bapi_mpgdx. "Checkbox Structure for BAPI_MPGD
data: bapi_mard like bapi_mard. "Material Data at Storage Location Level
data: bapi_mardx like bapi_mardx. "Checkbox Structure for BAPI_MARD
data: bapi_mbew like bapi_mbew. "Valuation Data
data: bapi_mbewx like bapi_mbewx. "Checkbox Structure for BAPI_MBEW
data: bapi_mlgn like bapi_mlgn. "Warehouse Number Data
data: bapi_mlgnx like bapi_mlgnx. "Checkbox Structure for BAPI_MLGN
data: bapi_mvke like bapi_mvke. "Sales Data
data: bapi_mvkex like bapi_mvkex. "Checkbox Structure for BAPI_MVKE
data: bapi_mlgt like bapi_mlgt. "Storage Type Data
data: bapi_mlgtx like bapi_mlgtx. "Checkbox Structure for BAPI_MLGT
type-pools: slis.
data : gt_fieldcat type slis_t_fieldcat_alv,
gs_layout type slis_layout_alv,
control_title type lvc_title,
times(6) type n.
*----------------------------------------------------------------------*
* SELECTION SCREEN *
*----------------------------------------------------------------------*
selection-screen begin of block bk1 with frame title text-001.
parameters: p_ufile like rlgrap-filename obligatory default 'C:\物料主数据.txt',
p_ok as checkbox default 'X'.
selection-screen end of block bk1.
*----------------------------------------------------------------------*
* INITIALIZATION *
*----------------------------------------------------------------------*
initialization.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN *
*----------------------------------------------------------------------*
at selection-screen on value-request for p_ufile.
perform get_filepath.
*top-of-page.
start-of-selection.
perform upload_data. "上载文本资料
perform check_data. "检查上载文本资料是否符合sap规则
if not itab[] is initial and out_put[] is initial.
perform get_mara_data. "正确的数据写到bapi相应的表
endif.
end-of-selection.
if not out_put[] is initial.
perform out_put.
else.
write: '无符合选择条件的数据输出!'.
endif.
*&---------------------------------------------------------------------*
*& Form GET_FILEPATH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_filepath .
call function 'WS_FILENAME_GET'
exporting
def_filename = 'DATAFILE.TXT'
def_path = 'C:\TEMP\'
mask = ',*.TXT,.'
mode = 'O'
title = 'Get filename'
importing
filename = p_ufile
exceptions
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
others = 5.
endform. " GET_FILEPATH
*&---------------------------------------------------------------------*
*& Form UPLOAD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form upload_data .
call function 'WS_UPLOAD'
exporting
* CODEPAGE = ' '
filename = p_ufile
filetype = 'DAT'
* HEADLEN = ' '
* LINE_EXIT = ' '
* TRUNCLEN = ' '
* USER_FORM = ' '
* USER_PROG = ' '
* DAT_D_FORMAT = ' '
* IMPORTING
* FILELENGTH =
tables
data_tab = itab
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
others = 10.
if itab[] is initial.
message '导入数据为空,请确认后重新导入! ' type 'I'.
exit.
endif.
endform. " UPLOAD_DATA
*&---------------------------------------------------------------------*
*& Form CHECK_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form check_data .
data dflag.
if p_ok = 'X'.
delete itab index 1.
endif.
delete itab where matnr eq ''.
sort itab by matnr werks.
delete adjacent duplicates from itab comparing matnr werks.
loop at itab.
translate itab-matnr to upper case.
translate itab-werks to upper case.
translate itab-vflag to upper case.
translate itab-mbrsh to upper case.
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = itab-matnr
importing
output = itab-matnr
exceptions
others = 1.
select single * from mara where matnr = itab-matnr.
if sy-subrc ne 0.
if itab-vflag ne 'M'.
out_put-bismt = itab-bismt.
out_put-maktx1 = itab-maktx1.
out_put-vflag = itab-vflag. "模块标志 ****
out_put-matnr = itab-matnr. "物料号 ****
out_put-maktx = itab-maktx. "物料描述****
out_put-werks = itab-werks." 工厂
out_put-text = '此物料未维护,请MM先维护基本视图!'. "输出信息
append out_put.
clear out_put.
dflag = 'X'.
else.
vws_itab-basic_view = 'X'.
if itab-meins eq ''.
out_put-bismt = itab-bismt.
out_put-maktx1 = itab-maktx1.
out_put-vflag = itab-vflag. "模块标志 ****
out_put-matnr = itab-matnr. "物料号 ****
out_put-maktx = itab-maktx. "物料描述****
out_put-werks = itab-werks." 工厂
out_put-text = '基本单位资料不完整'. "输出信息
append out_put.
clear out_put.
dflag = 'X'.
endif.
if itab-maktx eq ''.
out_put-bismt = itab-bismt.
out_put-maktx1 = itab-maktx1.
out_put-vflag = itab-vflag. "模块标志 ****
out_put-matnr = itab-matnr. "物料号 ****
out_put-maktx = itab-maktx. "物料描述****
out_put-werks = itab-werks." 工厂
out_put-text = '物料描述资料不完整'. "输出信息
append out_put.
clear out_put.
dflag = 'X'.
endif.
if itab-matkl eq ''.
out_put-bismt = itab-bismt.
out_put-maktx1 = itab-maktx1.
out_put-vflag = itab-vflag. "模块标志 ****
out_put-matnr = itab-matnr. "物料号 ****
out_put-maktx = itab-maktx. "物料描述****
out_put-werks = itab-werks." 工厂
out_put-text = '物料组资料不完整'. "输出信息
append out_put.
clear out_put.
dflag = 'X'.
endif.
endif.
endif.
case itab-vflag.
when 'M'."采购视图
vws_itab-purchase_view = 'X'.
vws_itab-storage_view = 'X'.
* VWS_ITAB-WAREHOUSE_VIEW = 'X'.
* IF itab-LGORT EQ ''.
* OUT_PUT-BISMT = ITAB-BISMT.
* OUT_PUT-MAKTX1 = ITAB-MAKTX1.
* OUT_PUT-VFLAG = ITAB-VFLAG. "模块标志 ****
* OUT_PUT-MATNR = ITAB-MATNR. "物料号 ****
* OUT_PUT-MAKTX = ITAB-MAKTX. "物料描述****
* OUT_PUT-WERKS = ITAB-WERKS." 工厂
* OUT_PUT-TEXT = '库存地点资料不完整'. "输出信息
* append out_put.
* clear out_put.
* dflag = 'X'.
* ENDIF.
when 'S'."销售视图
vws_itab-sales_view = 'X'.
if itab-vkorg eq ''.
out_put-bismt = itab-bismt.
out_put-maktx1 = itab-maktx1.
out_put-vflag = itab-vflag. "模块标志 ****
out_put-matnr = itab-matnr. "物料号 ****
out_put-maktx = itab-maktx. "物料描述****
out_put-werks = itab-werks." 工厂
out_put-text = '销售组织资料不完整'. "输出信息
append out_put.
clear out_put.
dflag = 'X'.
endif.
if itab-vtweg eq ''.
out_put-bismt = itab-bismt.
out_put-maktx1 = itab-maktx1.
out_put-vflag = itab-vflag. "模块标志 ****
out_put-matnr = itab-matnr. "物料号 ****
out_put-maktx = itab-maktx. "物料描述****
out_put-werks = itab-werks." 工厂
out_put-text = '分销渠道资料不完整'. "输出信息
append out_put.
clear out_put.
dflag = 'X'.
endif.
if itab-taxkm eq ''.
out_put-bismt = itab-bismt.
out_put-maktx1 = itab-maktx1.
out_put-vflag = itab-vflag. "模块标志 ****
out_put-matnr = itab-matnr. "物料号 ****
out_put-maktx = itab-maktx. "物料描述****
out_put-werks = itab-werks." 工厂
out_put-text = '税码未维护!'. "输出信息
append out_put.
clear out_put.
dflag = 'X'.
endif.
if itab-mtpos eq ''.
out_put-bismt = itab-bismt.
out_put-maktx1 = itab-maktx1.
out_put-vflag = itab-vflag. "模块标志 ****
out_put-matnr = itab-matnr. "物料号 ****
out_put-maktx = itab-maktx. "物料描述****
out_put-werks = itab-werks." 工厂
out_put-text = '项目类别组未维护!'. "输出信息
append out_put.
clear out_put.
dflag = 'X'.
endif.
if itab-mtvfp eq ''.
out_put-bismt = itab-bismt.
out_put-maktx1 = itab-maktx1.
out_put-vflag = itab-vflag. "模块标志 ****
out_put-matnr = itab-matnr. "物料号 ****
out_put-maktx = itab-maktx. "物料描述****
out_put-werks = itab-werks." 工厂
out_put-text = '可用量检查未维护!'. "输出信息
append out_put.
clear out_put.
dflag = 'X'.
endif.
if itab-tragr eq ''.
out_put-bismt = itab-bismt.
out_put-maktx1 = itab-maktx1.
out_put-vflag = itab-vflag. "模块标志 ****
out_put-matnr = itab-matnr. "物料号 ****
out_put-maktx = itab-maktx. "物料描述****
out_put-werks = itab-werks." 工厂
out_put-text = '运输组未维护!'. "输出信息
append out_put.
clear out_put.
dflag = 'X'.
endif.
if itab-ladgr eq ''.
out_put-bismt = itab-bismt.
out_put-maktx1 = itab-maktx1.
out_put-vflag = itab-vflag. "模块标志 ****
out_put-matnr = itab-matnr. "物料号 ****
out_put-maktx = itab-maktx. "物料描述****
out_put-werks = itab-werks." 工厂
out_put-text = '装载组未维护!'. "输出信息
append out_put.
clear out_put.
dflag = 'X'.
endif.
when 'P'."生产视图
vws_itab-mrp_view = 'X'.
if itab-beskz = 'E' or itab-beskz = 'X' or itab-mtart = 'FERT'.
vws_itab-work_sched_view = 'X'.
endif.
if itab-dismm eq ''.
out_put-bismt = itab-bismt.
out_put-maktx1 = itab-maktx1.
out_put-vflag = itab-vflag. "模块标志 ****
out_put-matnr = itab-matnr. "物料号 ****
out_put-maktx = itab-maktx. "物料描述****
out_put-werks = itab-werks." 工厂
out_put-text = 'MRP 类型未维护!'. "输出信息
append out_put.
clear out_put.
dflag = 'X'.
endif.
when 'Q'."质量视图
vws_itab-quality_view = 'X'.
when 'F'."财务视图
vws_itab-account_view = 'X'.
vws_itab-cost_view = 'X'.
if itab-bklas eq ''.
out_put-bismt = itab-bismt.
out_put-maktx1 = itab-maktx1.
out_put-vflag = itab-vflag. "模块标志 ****
out_put-matnr = itab-matnr. "物料号 ****
out_put-maktx = itab-maktx. "物料描述****
out_put-werks = itab-werks." 工厂
out_put-text = '评估类未维护!'. "输出信息
append out_put.
dflag = 'X'.
endif.
endcase.
if dflag ne 'X'.
vws_itab-material = itab-matnr. " 0 物料号
vws_itab-ind_sector = itab-mbrsh. " 0 行业领域
vws_itab-matl_type = itab-mtart. " 0 物料类型
append vws_itab.
modify itab.
else.
delete itab.
clear dflag.
endif.
clear out_put.
clear vws_itab.
endloop.
endform. " CHECK_DATA
*&---------------------------------------------------------------------*
*& Form GET_MARA_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_mara_data .
loop at itab.
clear: headdata ,
bapi_mara ,
bapi_marax ,
bapi_marc ,
bapi_marcx ,
bapi_mpop ,
bapi_mpopx ,
bapi_mpgd ,
bapi_mpgdx ,
bapi_mard ,
bapi_mardx ,
bapi_mbew ,
bapi_mbewx ,
bapi_mlgn ,
bapi_mlgnx ,
bapi_mvke ,
bapi_mvkex ,
bapi_mlgt ,
bapi_mlgtx .
free: bapi_makt.
read table vws_itab with key material = itab-matnr.
if sy-subrc = 0.
move-corresponding vws_itab to headdata.
endif.
*******
if headdata-basic_view eq 'X'.
if itab-maktx ne '' .
bapi_makt-langu = '1'.
bapi_makt-langu_iso = 'ZH'.
bapi_makt-matl_desc = itab-maktx.
append: bapi_makt.
clear: bapi_makt.
endif.
"物料描述繁体****
if itab-maktxf ne '' .
bapi_makt-langu = 'M'.
bapi_makt-langu_iso = 'ZF'.
bapi_makt-matl_desc = itab-maktxf.
append: bapi_makt.
clear: bapi_makt.
endif.
"物料描述英文****
if itab-maktxe ne '' .
bapi_makt-langu = 'E'.
bapi_makt-langu_iso = 'EN'.
bapi_makt-matl_desc = itab-maktxe.
append: bapi_makt.
clear: bapi_makt.
endif.
"葡萄牙物料长文本****
if itab-maktxp ne '' .
bapi_makt-langu = 'P'.
bapi_makt-langu_iso = 'PT'.
bapi_makt-matl_desc = itab-maktxp.
append: bapi_makt.
clear: bapi_makt.
endif.
if itab-text ne '' .
bapi_mltx-applobject = 'MATERIAL'.
bapi_mltx-text_name = itab-matnr.
bapi_mltx-text_id = 'GRUN'.
bapi_mltx-langu = 'ZH'.
bapi_mltx-text_line = itab-text.
append: bapi_mltx.
clear: bapi_mltx.
endif.
endif.
**基础视图
bapi_marc-plant = itab-werks. "工厂 ****
bapi_marcx-plant = itab-werks. "工厂 ****
bapi_mara-base_uom = itab-meins. "基本计量单位****
bapi_mara-matl_group = itab-matkl. "物料组****
bapi_mara-extmatlgrp = itab-ematkl. "外部物料组(18)
bapi_mara-dsn_office = itab-labor. "实验室/办公室(18)
bapi_mara-old_mat_no = itab-bismt1. "东莞旧物料号码(18)
bapi_mara-prod_memo = itab-bismt2. "台湾旧物料号码(18) 生产/检验备忘录
bapi_mara-std_descr = itab-bismt3. "宁波旧物料号码(18) 行业标准描述
bapi_mara-size_dim = itab-groes. "大小/量纲 (32)***
bapi_mara-allowed_wt = itab-brgew. "毛重***
bapi_mara-net_weight = itab-ntgew. "净重***
bapi_mara-unit_of_wt = itab-gewei. "重量单位****
bapi_mara-allwd_vol = itab-volum. "体积****
bapi_mara-pack_vo_un = itab-voleh. "体积单位 (3)****
if not itab-lgort1 is initial.
bapi_mard-plant = itab-werks. "工厂 ****
bapi_mard-stge_loc = itab-lgort1. "工厂 ****
bapi_mardx-plant = itab-werks. "工厂 ****
bapi_mardx-stge_loc = itab-lgort1. "工厂 ****
endif.
if headdata-basic_view eq 'X'.
bapi_marax-base_uom = 'X'. "基本计量单位****
bapi_marax-matl_group = 'X'. "物料组****
bapi_marax-extmatlgrp = 'X'. "外部物料组(18)
bapi_marax-dsn_office = 'X'. "实验室/办公室(18)
bapi_marax-old_mat_no = 'X'. "东莞旧物料号码(18)
bapi_marax-prod_memo = 'X'. "台湾旧物料号码(18) 生产/检验备忘录
bapi_marax-std_descr = 'X'. "宁波旧物料号码(18) 行业标准描述
bapi_marax-size_dim = 'X'. "大小/量纲 (32)***
bapi_marax-allowed_wt = 'X'. "毛重***
bapi_marax-net_weight = 'X'. "净重***
bapi_marax-unit_of_wt = 'X'. "重量单位****
bapi_marax-allwd_vol = 'X'. "体积****
bapi_marax-pack_vo_un = 'X'. "体积单位 (3)****
else.
if itab-werks = 'T100' and itab-vflag = 'M'.
bapi_marax-prod_memo = 'X'. "台湾旧物料号码(18) 生产/检验备忘录
endif.
if itab-werks = 'C100' and itab-vflag = 'M'.
bapi_marax-std_descr = 'X'. "宁波旧物料号码(18) 行业标准描述
endif.
endif.
**销售视图
if headdata-sales_view = 'X'.
bapi_mvke-sales_org = itab-vkorg. "销售组织****
bapi_mvke-distr_chan = itab-vtweg. "分销渠道****
bapi_mvkex-sales_org = itab-vkorg. "销售组织****
bapi_mvkex-distr_chan = itab-vtweg. "分销渠道****
bapi_mara-pur_status = itab-mstae. "跨工厂物料状态****
bapi_mara-pvalidfrom = itab-mstde. "有效起始期****
bapi_mvke-sales_unit = itab-vrkme. "销售单位****
if itab-vrkme ne ''.
bapi_marm-alt_unit = itab-vrkme.
bapi_marm-alt_unit_iso = itab-meins.
bapi_marm-numerator = itab-umren1. "转换为基本计量单位的分母 (3)****
bapi_marm-denominatr = itab-umrez1. "基本计量单位转换分子****
bapi_marmx-alt_unit = 'X'.
bapi_marmx-alt_unit_iso = 'X'.
bapi_marmx-numerator = 'X'. "转换为基本计量单位的分母 (3)****
bapi_marmx-denominatr = 'X'. "基本计量单位转换分子****
append: bapi_marm,bapi_marmx.
clear: bapi_marm,bapi_marmx.
endif.
bapi_mara-division = itab-spart. "部门/产品组****
bapi_mvke-delyg_plnt = itab-dwerk. "交货工厂***
bapi_marax-pur_status = 'X'. "跨工厂物料状态****
bapi_marax-pvalidfrom = 'X'. "有效起始期****
bapi_mvkex-sales_unit = 'X'. "销售单位****
bapi_marax-division = 'X'. "部门/产品组****
bapi_mvkex-delyg_plnt = 'X'. "交货工厂***
*itab-TAXKM. "税码***
case itab-vkorg .
when 'C100' or 'C200' or 'C300'.
move 'CN' to bapi_mlan-depcountry.
* MOVE 'CH' TO BAPI_MLAN-DEPCOUNTRY_ISO.
move 'MWST' to bapi_mlan-tax_type_1.
move itab-taxkm to bapi_mlan-taxclass_1.
append: bapi_mlan .
clear : bapi_mlan.
when 'T100'.
move 'TW' to bapi_mlan-depcountry.
* MOVE 'TW' TO BAPI_MLAN-DEPCOUNTRY_ISO.
move 'MWST' to bapi_mlan-tax_type_1.
move itab-taxkm to bapi_mlan-taxclass_1.
append: bapi_mlan .
clear : bapi_mlan.
when 'B100'.
move 'BZ' to bapi_mlan-depcountry.
* MOVE 'BZ' TO BAPI_MLAN-DEPCOUNTRY_ISO.
move 'MWST' to bapi_mlan-tax_type_1.
move itab-taxkm to bapi_mlan-taxclass_1.
append: bapi_mlan .
clear : bapi_mlan.
move 'CN' to bapi_mlan-depcountry.
* MOVE 'CH' TO BAPI_MLAN-DEPCOUNTRY_ISO.
move 'MWST' to bapi_mlan-tax_type_1.
move itab-taxkm to bapi_mlan-taxclass_1.
append: bapi_mlan .
clear : bapi_mlan.
when 'N100'.
move 'IN' to bapi_mlan-depcountry.
* MOVE 'IN' TO BAPI_MLAN-DEPCOUNTRY_ISO.
move 'MWST' to bapi_mlan-tax_type_1.
move itab-taxkm to bapi_mlan-taxclass_1.
append: bapi_mlan .
clear : bapi_mlan.
endcase .
bapi_mvke-matl_stats = itab-versg. "物料统计组****
bapi_mvke-item_cat = itab-mtpos. "项目类别组****
bapi_mvke-acct_assgt = itab-ktgrm. "科目设置组****
bapi_mara-trans_grp = itab-tragr. "运输组****
bapi_marc-availcheck = itab-mtvfp. "可用量检查****
bapi_marc-loadinggrp = itab-ladgr. "装载组****
bapi_marc-profit_ctr = itab-prctr. "利润中心****
bapi_mvkex-matl_stats = 'X'. "物料统计组****
bapi_mvkex-item_cat = 'X'. "项目类别组****
bapi_mvkex-acct_assgt = 'X'. "科目设置组****
bapi_marax-trans_grp = 'X'. "运输组****
bapi_marcx-availcheck = 'X'. "可用量检查****
bapi_marcx-loadinggrp = 'X'. "装载组****
bapi_marcx-profit_ctr = 'X'. "利润中心****
endif.
**采购视图
if headdata-purchase_view = 'X'.
bapi_mara-po_unit = itab-bstme. "采购单位****
bapi_marax-po_unit = 'X'. "采购单位****
if itab-bstme ne ''.
bapi_marm-alt_unit = itab-bstme.
bapi_marm-alt_unit_iso = itab-meins.
bapi_marm-numerator = itab-umren. "转换为基本计量单位的分母 (3)****
bapi_marm-denominatr = itab-umrez. "基本计量单位转换分子****
bapi_marmx-alt_unit = 'X'.
bapi_marmx-alt_unit_iso = 'X'.
bapi_marmx-numerator = 'X'. "转换为基本计量单位的分母 (3)****
bapi_marmx-denominatr = 'X'. "基本计量单位转换分子****
append: bapi_marm,bapi_marmx.
clear: bapi_marm,bapi_marmx.
endif.
bapi_marc-pur_group = itab-ekgrp. "采购组 ****
bapi_marc-batch_mgmt = itab-xchpf. "批次管理(1) ****
bapi_marc-sourcelist = itab-kordb. "货源清单
bapi_mard-stge_bin = itab-lgort. "库存仓位 ****
bapi_marcx-pur_group = 'X'. "采购组 ****
bapi_marcx-batch_mgmt = 'X'. "批次管理(1) ****
bapi_marcx-sourcelist = 'X'. "货源清单
bapi_mardx-stge_bin = 'X'. "库存仓位 ****
endif.
***生产视图
if headdata-mrp_view = 'X'.
bapi_marc-plant = itab-werks. "工厂 ****
bapi_marc-mrp_type = itab-dismm. "MRP 类型 ****
bapi_marc-abc_id = itab-maabc. "ABC标识 ****
bapi_marc-mrp_ctrler = itab-dispo. "MRP控制员*****
bapi_marc-pur_status = itab-mmsta. "特定工厂的物料状态*****
bapi_marc-mrp_group = itab-disgr. "MRP组 (3)*****
bapi_marc-lotsizekey = itab-disls. "批量 (2)*****
bapi_marc-fixed_lot = itab-bstfe. "固定批量 (13,3)*****
bapi_marc-round_val = itab-bstrf. "舍人值 (13)*****
bapi_marc-proc_type = itab-beskz. "采购类型*****
bapi_marc-spproctype = itab-sobsl. "特殊采购类型*****
bapi_marc-inhseprodt = itab-dzeit. "自制生产(2)*****
bapi_marc-iss_st_loc = itab-lgpro. "生产仓储地点*****
bapi_marc-sloc_exprc = itab-lgfsb. "外部采购库存地点 *****
bapi_marc-plnd_delry = itab-plifz. "计划交货时间 (3) *****
bapi_marc-safety_stk = itab-eisbe. "安全库存 (13,3) *****
bapi_marc-sm_key = itab-fhori. "计划边际码 (3) ****
bapi_marc-availcheck = itab-mtvfp1. "可用性检查 (2) ****
bapi_marc-dep_req_id = itab-sbdkz. "独立/集中 ***
if itab-mtart = 'FERT'.
"20091022增加周琼花提出
bapi_marc-serno_prof = '0001'. "序列号参数文件
bapi_mara-serialization_level = '1'."序列号上的等级
bapi_marcx-serno_prof = 'X'.
bapi_marax-serialization_level = 'X'.
endif.
bapi_marcx-plant = itab-werks. "工厂 ****
bapi_marcx-mrp_type = 'X'. "MRP 类型 ****
bapi_marcx-abc_id = 'X'. "ABC标识 ****
bapi_marcx-mrp_ctrler = 'X'. "MRP控制员*****
bapi_marcx-pur_status = 'X'. "特定工厂的物料状态*****
bapi_marcx-mrp_group = 'X'. "MRP组 (3)*****
bapi_marcx-lotsizekey = 'X'. "批量 (2)*****
bapi_marcx-fixed_lot = 'X'. "固定批量 (13,3)*****
bapi_marcx-round_val = 'X'. "舍人值 (13)*****
bapi_marcx-proc_type = 'X'. "采购类型*****
bapi_marcx-spproctype = 'X'. "特殊采购类型*****
bapi_marcx-inhseprodt = 'X'. "自制生产(2)*****
bapi_marcx-iss_st_loc = 'X'. "生产仓储地点*****
bapi_marcx-sloc_exprc = 'X'. "外部采购库存地点 *****
bapi_marcx-plnd_delry = 'X'. "计划交货时间 (3) *****
bapi_marcx-safety_stk = 'X'. "安全库存 (13,3) *****
bapi_marcx-sm_key = 'X'. "计划边际码 (3) ****
bapi_marcx-availcheck = 'X'. "可用性检查 (2) ****
bapi_marcx-dep_req_id = 'X'. "独立/集中 ***
bapi_marc-comp_scrap = itab-kausf. "部件废品(%) ****
bapi_marcx-comp_scrap = 'X'.
endif.
**质量视图
if headdata-quality_view = 'X'.
bapi_mara-catprofile = itab-rbnrm. "类别参数文件 ****
bapi_marax-catprofile = 'X'.
bapi_marc-insp_int = itab-prfrq. "检验间隔时间(5) * ****
bapi_marcx-insp_int = 'X'.
clear mara.
select single qmpur from mara into mara-qmpur
where matnr = itab-matnr.
if mara-qmpur is initial.
bapi_mara-qm_procmnt = itab-qmpur. "QM采购激活 ****
bapi_marax-qm_procmnt = 'X'. "QM采购激活 ****
endif.
bapi_marc-ctrl_key = itab-ssqss. "QM 控制码 ****
bapi_marcx-ctrl_key = 'X'.
*BAPI_MARC-QMATV = 'X'.
*BAPI_MARCX-QMATV = 'X'.
if itab-art_01 ne ''. "检验类型1***
perform bapi1001004 using itab-art_01.
endif.
if itab-art_02 ne ''. "检验类型2***
perform bapi1001004 using itab-art_02.
endif.
if itab-art_03 ne ''. "检验类型3***
perform bapi1001004 using itab-art_03.
endif.
if itab-art_04 ne ''. "检验类型4***
perform bapi1001004 using itab-art_04.
endif.
if itab-art_05 ne ''. "检验类型5***
perform bapi1001004 using itab-art_05.
endif.
if itab-art_06 ne ''. "检验类型6***
perform bapi1001004 using itab-art_06.
endif.
*itab-KZDKZ. "须要纪录文件(1)***
endif.
***财务视图
if headdata-account_view = 'X'.
*BAPI_MBEW-VAL_AREA
*VAL_TYPE
bapi_mbew-val_area = itab-werks." 工厂
bapi_mbewx-val_area = itab-werks." 工厂
if itab-bklas ne ''.
bapi_mbew-val_class = itab-bklas. "评估类 (4) ****
bapi_mbewx-val_class = 'X'.
endif.
if itab-vprsv ne ''.
bapi_mbew-price_ctrl = itab-vprsv. "价格控制( ****
bapi_mbewx-price_ctrl = 'X'.
endif.
if itab-verpr ne ''.
bapi_mbew-moving_pr = itab-verpr. "移动平均价 ****
bapi_mbewx-moving_pr = 'X'.
endif.
if itab-stprs ne ''.
bapi_mbew-std_price = itab-stprs. "标准价格 ****
bapi_mbewx-std_price = 'X'.
endif.
if itab-peinh ne ''.
bapi_mbew-price_unit = itab-peinh. "价格单位 ****
bapi_mbewx-price_unit = 'X'.
endif.
if itab-losgr ne ''.
bapi_marc-lot_size = itab-losgr. "核算批量(13)*****
bapi_marcx-lot_size = 'X'.
endif.
if itab-prctr1 ne ''.
bapi_marc-profit_ctr = itab-prctr1. "利润中心 ****
bapi_marcx-profit_ctr = 'X'.
endif.
if itab-ncost ne ''.
bapi_marc-no_costing = itab-ncost. "无成本核算(1) ****
bapi_marcx-no_costing = 'X'.
endif.
if itab-ekalr ne ''.
bapi_mbew-qty_struct = itab-ekalr. "QS估算(1) ****
bapi_mbewx-qty_struct = 'X'.
endif.
if itab-hkmat ne ''.
bapi_mbew-orig_mat = itab-hkmat. "物料相关的源****
bapi_mbewx-orig_mat = 'X'.
endif.
bapi_marc-variance_key = '000001'."itab-AWSLS. "差异码 ****
bapi_marcx-variance_key = 'X'.
endif.
perform create_matnr_bapi.
endloop.
endform. " GET_MARA_DATA
*&---------------------------------------------------------------------*
*& Form CREATE_MATNR_BAPI
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form create_matnr_bapi .
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
headdata = headdata
clientdata = bapi_mara
clientdatax = bapi_marax
plantdata = bapi_marc
plantdatax = bapi_marcx
* PLANNINGDATA =
* PLANNINGDATAX =
storagelocationdata = bapi_mard
storagelocationdatax = bapi_mardx
valuationdata = bapi_mbew
valuationdatax = bapi_mbewx
* WAREHOUSENUMBERDATA =
* WAREHOUSENUMBERDATAX =
salesdata = bapi_mvke
salesdatax = bapi_mvkex
* STORAGETYPEDATA =
* STORAGETYPEDATAX =
flag_online = ' '
flag_cad_call = ' '
no_dequeue = ' '
no_rollback_work = ' '
importing
return = return
tables
materialdescription = bapi_makt
unitsofmeasure = bapi_marm
unitsofmeasurex = bapi_marmx
* INTERNATIONALARTNOS =
materiallongtext = bapi_mltx
taxclassifications = bapi_mlan
returnmessages = bapi_matreturn2
* PRTDATA =
* PRTDATAX =
* EXTENSIONIN =
* EXTENSIONINX =
.
loop at bapi_matreturn2 where type eq 'E'.
exit.
endloop.
if sy-subrc eq 0.
call function 'BAPI_TRANSACTION_ROLLBACK'.
else.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
endif.
call function 'BUFFER_REFRESH_ALL'.
out_put-bismt = itab-bismt.
out_put-maktx1 = itab-maktx1.
out_put-vflag = itab-vflag. "模块标志 ****
out_put-matnr = itab-matnr. "物料号 ****
out_put-maktx = itab-maktx. "物料描述****
out_put-werks = itab-werks." 工厂
out_put-text = return-message. "输出信息
if headdata-quality_view = 'X'.
do 1000 times.
select single * from marc where matnr = itab-matnr
and werks = itab-werks.
enddo.
call function 'BAPI_MATINSPCTRL_SAVEREPLICA'
tables
return = return1
inspectionctrl = bapi1001004_qmat.
loop at return1 where type eq 'E'.
out_put-text = return1-message .
append out_put.
endloop.
if sy-subrc ne 0.
out_put-text = 'QM试图扩展成功!' .
append out_put.
endif.
commit work.
free: return1,bapi1001004_qmat.
clear: bapi1001004_qmat,return1.
else.
append out_put.
endif.
clear out_put.
free:headdata,
bapi_mara,
bapi_marax,
bapi_marc,
bapi_marcx,
bapi_mard,
bapi_mardx,
bapi_mbew,
bapi_mbewx,
bapi_mvke,
bapi_mvkex,
bapi_makt,
bapi_marm,
bapi_marmx,
bapi_mltx,
bapi_mlan,
bapi_matreturn2.
clear:headdata,
bapi_mara,
bapi_marax,
bapi_marc,
bapi_marcx,
bapi_mard,
bapi_mardx,
bapi_mbew,
bapi_mbewx,
bapi_mvke,
bapi_mvkex,
bapi_makt,
bapi_marm,
bapi_marmx,
bapi_mltx,
bapi_mlan,
return,
bapi_matreturn2.
endform. " CREATE_MATNR_BAPI
*---------------------------------------------------------------------*
* Form OUT_PUT
*---------------------------------------------------------------------*
form out_put .
control_title = '数据上传信息'.
perform e01_fieldcat_init using :
'BISMT' '旧物料号' 18 '' '' '' '' '' '' '' '',
'MAKTX1' '旧物料描述' 40 '' '' '' '' '' '' '' '',
'VFLAG' '模块标志' 10 '' '' '' '' '' '' '' '',
'MATNR' '物料号' 18 '' '' '' '' '' '' '' '',
'MAKTX' '物料描述' 40 '' '' '' '' '' '' '' '',
'WERKS' ' 工厂' 4 '' '' '' '' '' '' '' '',
'TEXT' '输出信息' 50 '' '' '' '' '' '' '' ''.
gs_layout-colwidth_optimize = 'X'.
gs_layout-info_fieldname = 'COLOR'.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = sy-cprog
it_fieldcat = gt_fieldcat[]
is_layout = gs_layout
i_callback_user_command = 'MYCOMMAND'
i_save = 'X'
i_grid_title = control_title
tables
t_outtab = out_put.
endform. " OUT_PUT
*&---------------------------------------------------------------------*
*& Form e01_fieldcat_init
*&---------------------------------------------------------------------*
form e01_fieldcat_init using
field_name type c
field_text type c
field_lenth type i
field_edit type c
field_type type c
field_key type c
field_hotspot type c
field_checkbox type c
field_no_zero type c
field_ref_tabname type c
field_emphasize type c.
data: ls_fieldcat type slis_fieldcat_alv.
clear ls_fieldcat.
ls_fieldcat-fieldname = field_name.
ls_fieldcat-seltext_l = field_text.
ls_fieldcat-seltext_m = field_text.
ls_fieldcat-seltext_s = field_text.
ls_fieldcat-checkbox = field_checkbox.
ls_fieldcat-round = 0.
ls_fieldcat-edit = field_edit.
ls_fieldcat-datatype = field_type.
if field_type = 'Q'.
ls_fieldcat-just = 'R'.
ls_fieldcat-datatype = 'QUAN'.
ls_fieldcat-decimals_out = 0.
else.
ls_fieldcat-just = 'L'.
endif.
ls_fieldcat-key = field_key.
ls_fieldcat-hotspot = field_hotspot .
ls_fieldcat-outputlen = field_lenth.
* ls_fieldcat-no_zero = field_no_zero.
ls_fieldcat-emphasize = field_emphasize .
append ls_fieldcat to gt_fieldcat.
endform. " e01_fieldcat_init
*&---------------------------------------------------------------------*
*& Form BAPI1001004
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ITAB_ART_01 text
*----------------------------------------------------------------------*
form bapi1001004 using p_itab_art_01.
clear tq34.
select single * from tq34 where art = p_itab_art_01.
bapi1001004_qmat-ind_insp_with_tsk_list = tq34-ppl. "有任务清单的检验
bapi1001004_qmat-ind_spec_matspec = tq34-spezueber. "使用物料说明的检验
bapi1001004_qmat-ind_spec_config = tq34-conf. "来自配置的检验规范
bapi1001004_qmat-ind_spec_batch = tq34-tls. "批次确定的检验规范
bapi1001004_qmat-ind_auto_assign = tq34-app. "自动规格分配
bapi1001004_qmat-ind_insp_by_charac = tq34-mer. "按特性检验
bapi1001004_qmat-ind_post_to_insp_stock = tq34-insmk. "过帐到检验库存
bapi1001004_qmat-ind_automatic_ud = tq34-ave. "计划的自动用途决定
bapi1001004_qmat-sampling_procedure = tq34-stichprver. "采样程序
bapi1001004_qmat-dyn_modif_rule = tq34-dynregel. "动态修改规则
bapi1001004_qmat-insp_percentage = tq34-sproz. "检验百分比
bapi1001004_qmat-ind_100_percent_inspection = tq34-hpz. "100% 检验
bapi1001004_qmat-ind_skips_allowed = tq34-dyn. "允许略过
bapi1001004_qmat-ind_manual_sample = tq34-mpb. "手工输入采样
bapi1001004_qmat-ind_manual_sample_calc = tq34-mst. "手动触发采样计算
bapi1001004_qmat-ind_single_units_possible = tq34-ein. "可能的序列号管理
* BAPI1001004_QMAT-AVE_INSP_DURATION = TQ34-MPDAU. "平均检验期
bapi1001004_qmat-contr_insp_lot_create = tq34-chg. "控制检验批创建(批次摘要)
bapi1001004_qmat-qual_score_procedure = tq34-qkzverf. "计算质量记分的程序
bapi1001004_qmat-allowed_scrap_share = tq34-qpmat. "检验批中允许的废品份额(百分比)
* BAPI1001004_QMAT-FUNCTION = '004'.
bapi1001004_qmat-insptype = p_itab_art_01.
bapi1001004_qmat-material = itab-matnr.
bapi1001004_qmat-plant = itab-werks.
bapi1001004_qmat-preferred_insptype = 'X'.
bapi1001004_qmat-ind_insptype_mat_active = 'X'.
append bapi1001004_qmat.
clear bapi1001004_qmat.
endform. " BAPI1001004
*---------------------------------------------------------------------*
* FORM mycommand *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> R_UCOMM *
* --> RS_SELFIELD *
*---------------------------------------------------------------------*
form mycommand using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
data: carrid type afpo-aufnr.
data: myindex like sy-tabix.
if r_ucomm = '&IC1'.
myindex = rs_selfield-tabindex.
read table out_put index myindex.
if sy-subrc = 0.
set parameter id 'MAT' field out_put-matnr.
call transaction 'MM03' and skip first screen.
endif.
* elseif r_ucomm = '&EB91'.
* MYINDEX = RS_SELFIELD-TABINDEX.
* READ TABLE ST_AFPO INDEX MYINDEX.
* IF SY-SUBRC = 0.
* SET PARAMETER ID 'ANR' FIELD ST_AFPO-AUFNR.
* CALL TRANSACTION 'CO02' AND SKIP FIRST SCREEN.
* ENDIF.
endif.
endform. "mycommand
标签:物料,itab,程序,bapi,批导,put,data,out 来源: https://blog.csdn.net/qq_37968127/article/details/94429121