MM01物料主数据批导
1业务场景
期初批量导入物料主数据时,有以下要求:
- 维护相应的物料视图
- 将物料维护到多个工厂
- 可能需要对物料进行分割评估
- 对某些字段,需要在BAPI中做增强处理进行维护
2代码实现
2.1物料基本数据
1.基本数据
2.声明要维护的视图
3.之后根据前台相应字段所在的表,在BAPI参数中找到对应的BAPI参数并维护即可
4.最后调用BAPI_MATERIAL_SAVEDATA创建物料主数据
该BAPI可以满足创建、修改物料,还可以将物料扩展到其他工厂
2.2维护物料长文本
当保证物料创建成功时,可以维护物料的长文本。
调用函数SAVE_TEXT维护物料的长文本
2.3维护分类视图
从声明维护视图时可以发现,分类视图等不能和其他视图通过物料主数据BAPI维护,需要单独创建
调用BAPI_OBJCL_CREATE创建物料的分类视图,另外,针对物料的分类特性的修改获取,还有多个BAPI,在后边做简要介绍。
2.4维护质量视图
质量视图,要先根据检验类型ART,获取到相关数据
将获取的值维护到质量视图
调用BAPI_MATINSPCTRL_SAVEREPLICA维护质量视图
2.5启用分割评估
在实际业务中,需要对物料的会计视图,启用分割评估。
前台操作为,MM02,进入会计视图,并输入现有的工厂,输入评估类别,保存
退出后MM01进入,输入工厂和评估类型
输入评估分类,保存
MM03进入,输入和不输入评估类型进入的会计1视图将会不一样
将调用BAPI_MATERIAL_SAVEDATA封装成一个form,根据该BAPI可以创建修改两种功能,之后两次调用,相当于执行了MM02和MM01,第一次传入评估类别,第二次传入评估类型,实现了启用分割评估的需求。
3.物料主数据增强
在通过BAPI维护过程中,发现有的物料在BAPI参数中找不到,此时就需要通过增强维护。
物料基本视图2中有物料时可配置的字段,需要打钩,而BAPI参数中找不到该参数,但是这个参数是存在于MARA表中的KZKFG
在自定义BAPI结构中,添加该字段
还有更新结构,也要添加,注意组件类型为更新类型
定义参数
代码示例:
如此便可以维护该字段
如果在界面上增加字段,可以在MM01中维护,但是BAPI却更新不进去,是因为需要在SPRO中配置,路径:后勤-常规—>物料主数据—>字段选择—>给字段选择组分配字段,配置进去即可用BAPI更新
4.问题记录
4.1配置问题
导入5000的物料时,报这个错误时,最终查到是后台配置的问题,物料类型数量更新和值更新没有勾选。
4.2删除物料
4.2.1 集团级别删除物料
4.2.2 工厂级别删除物料
工厂级别删除物料时,一定要维护存储视图,否则无法删除
4.3报错问题
4.3.1 字段BWKEY已被不一致地转移或字段是空的
类似的问题是因为该字段所处的结构被传值,但是该字段确实空的, 需要传值
5.源代码
"-----------------------------@斌将军-----------------------------
FORM frm_bapi_creat. *--------------------------------------------------------------------* * BAPI 字段 *--------------------------------------------------------------------* * 物料文本 DATA:ls_header TYPE thead, " lt_lines TYPE STANDARD TABLE OF tline, ls_lines TYPE tline. DATA: ls_mdma LIKE mdma, ls_dpop LIKE dpop, ls_sdibe TYPE sdibe_massfields, ls_return2 TYPE bapireturn1, lt_return2 TYPE TABLE OF bapireturn1. "质量视图 DATA:ls_qmat TYPE bapi1001004_qmat, lt_qmat TYPE TABLE OF bapi1001004_qmat. DATA:lv_land1 TYPE t001w-land1, "国家代码 lv_tax_type TYPE tatyp VALUE 'MWST', "税类别 lv_matnr TYPE mara-matnr, "物料号 lv_objectkeynew TYPE bapi1003_key-object, lv_message TYPE char200, "消息 lv_msg TYPE char200, "消息 lv_check TYPE char2. "检查 "进度条使用标志 CLEAR:gv_flag. DESCRIBE TABLE gt_template LINES gv_lines. LOOP AT gt_template INTO gs_template WHERE icon <> icon_led_red. "当前条目 gv_tabix = gv_tabix + 1. "进度条 PERFORM frm_indicator USING gv_tabix. REFRESH:gt_makt[],gt_mlan[],gt_mltx[],gt_marm[],gt_marmx[],gt_mean[],gt_return. CLEAR:gs_headdata,gs_mara,gs_marax,gs_marc,gs_marcx,gs_mpop,gs_mpopx,gs_mpgd, gs_mpgdx,gs_mard,gs_mardx,gs_mlgn,gs_mlgnx,gs_mvke,gs_mvkex,gs_mlgt,gs_mlgtx, gs_mbew,gs_mbewx,gs_return,gt_makt,gt_mlan,gt_mltx,gt_marm,gt_marmx,gt_mean. *&---------------------------------------------------------------------* *& 基本数据1 *&---------------------------------------------------------------------* gs_headdata-material = gs_template-matnr. "SAP物料编码 gs_headdata-ind_sector = gs_template-mbrsh. "行业 gs_headdata-matl_type = gs_template-mtart. "物料类型 gs_marc-plant = gs_template-werks. "工厂 gs_marcx-plant = gs_template-werks. *--------------------------------------------------------------------* *维护视图 *--------------------------------------------------------------------* * IF p_jb = 'X'. gs_headdata-basic_view = 'X'."基本数据视图 * ENDIF. IF p_xs = 'X'. gs_headdata-sales_view = 'X'."销售视图 ENDIF. IF p_cg = 'X'. gs_headdata-purchase_view = 'X'."采购视图 ENDIF. IF p_mrp = 'X'. gs_headdata-mrp_view = 'X'."MRP视图 ENDIF. * IF p_gz = 'X'. * gs_headdata-work_sched_view = 'X'."工作计划视图 * ENDIF. IF p_kj = 'X'. gs_headdata-account_view = 'X'."会计视图 ENDIF. IF p_cb = 'X'. gs_headdata-cost_view = 'X'."成本视图 ENDIF. IF p_zl = 'X'. gs_headdata-quality_view = 'X'."质量视图 ENDIF. IF p_cc = 'X'. gs_headdata-storage_view = 'X'."存储视图 ENDIF. * IF p_ck = 'X'. * gs_headdata-warehouse_view = 'X'."仓库管理视图 * ENDIF. *--------------------------------------------------------------------* * 基本视图 *--------------------------------------------------------------------* *物料描述 gt_makt-langu = sy-langu. gt_makt-matl_desc = gs_template-maktx. "物料描述 APPEND gt_makt. gs_mara-base_uom = gs_template-meins."基本计量单位 gs_marax-base_uom = 'X'. gs_mara-matl_group = gs_template-matkl. "物料组 gs_marax-matl_group = 'X'. gs_mara-extmatlgrp = gs_template-extwg. "物料组 gs_marax-extmatlgrp = 'X'. gs_mara-division = gs_template-spart."产品组 gs_marax-division = 'X'. gs_mara-old_mat_no = gs_template-bismt."旧物料号 gs_marax-old_mat_no = 'X'. gs_mara-pur_status = gs_template-mstae. "跨工厂物料状态 gs_marax-pur_status = 'X'. gs_mara-item_cat = gs_template-mtpos_mara."普通项目类别组 gs_marax-item_cat = 'X'."普通项目类别组 gt_marm-alt_unit = gs_template-meins."基本计量单位 gt_marmx-alt_unit = gs_template-meins."基本计量单位 *&---------------------------------------------------------------------* *& 销售:销售组织数据1 *&---------------------------------------------------------------------* IF p_xs = 'X'."销售视图 IF gs_template-vkorg IS NOT INITIAL . gs_mvke-sales_org = gs_template-vkorg."销售组织 gs_mvkex-sales_org = gs_template-vkorg. ENDIF. gs_mvke-distr_chan = gs_template-vtweg."分销渠道 gs_mvkex-distr_chan = gs_template-vtweg."分销渠道 gs_mvke-delyg_plnt = gs_template-dwerk."交货工厂 gs_mvkex-delyg_plnt = 'X'. CLEAR: lv_land1. "获取国家键值 SELECT SINGLE land1 INTO lv_land1 FROM t001w WHERE werks = gs_template-werks."工厂 IF sy-subrc <> 0. gs_template-icon = icon_led_red. gs_template-log = '无法获取国家键值'. MODIFY gt_template FROM gs_template TRANSPORTING icon log. CLEAR:gs_template. CONTINUE. ENDIF. gt_mlan-depcountry = lv_land1. gt_mlan-tax_type_1 = lv_tax_type. gt_mlan-taxclass_1 = gs_template-taxm1."税分类 APPEND gt_mlan. *&---------------------------------------------------------------------* *& 销售:销售组织数据2 *&---------------------------------------------------------------------* IF gs_template-ktgrm IS NOT INITIAL . gs_mvke-acct_assgt = gs_template-ktgrm."科目设置组 gs_mvkex-acct_assgt = 'X'. ENDIF. IF gs_template-mtpos IS NOT INITIAL . gs_mvke-item_cat = gs_template-mtpos."项目类别 gs_mvkex-item_cat = 'X'. ENDIF. gs_marc-availcheck = gs_template-mtvfp_xs. "可用性检查 gs_marcx-availcheck = 'X'. * IF gs_template-prodh IS NOT INITIAL . * gs_mvke-prod_hier = gs_template-prodh."产品层次 * gs_mvkex-prod_hier = 'X'. * ENDIF. *&---------------------------------------------------------------------* *& 销售:一般/工厂 *&---------------------------------------------------------------------* IF gs_template-ladgr IS NOT INITIAL . gs_marc-loadinggrp = gs_template-ladgr."装载组 gs_marcx-loadinggrp = 'X'. ENDIF. IF gs_template-tragr IS NOT INITIAL . gs_mara-trans_grp = gs_template-tragr."运输组 gs_marax-trans_grp = 'X'. ENDIF. ENDIF. *&---------------------------------------------------------------------* *& 采购 *&---------------------------------------------------------------------* IF p_cg = 'X'. "采购视图. gs_marc-pur_group = gs_template-werks. "工厂 gs_marcx-pur_group = 'X'. gs_marc-pur_group = gs_template-ekgrp. "采购组 gs_marcx-pur_group = 'X'. * gs_mara-po_unit = gs_template-bstme. "订单单位 * gs_marax-po_unit = 'X'. gs_marc-gr_pr_time = gs_template-webaz. "收货处理时间 gs_marcx-gr_pr_time = 'X'. gs_marc-sourcelist = gs_template-kordb. "源清单 gs_marcx-sourcelist = 'X'. gs_marc-pur_status = gs_template-mmsta. "工厂特定的物料状态 gs_marcx-pur_status = 'X'. * gs_marc-PVALIDFROM = gs_template-MMSTD. "工厂特定物料状态有效的起始日期 * gs_marcx-PVALIDFROM = 'X'. * gs_marc-MATFRGTGRP = gs_template-MFRGR. "物料运输组 * gs_marcx-MATFRGTGRP = 'X'. * gs_marc-batch_mgmt = gs_template-xchpf. "批次管理 * gs_marcx-batch_mgmt = 'X'. gs_mara-batch_mgmt = gs_template-xchpf. "批次管理 gs_marax-batch_mgmt = 'X'. * * gs_marc-CRIT_PART = gs_template-KZKRI. "关键部件 * gs_marcx-CRIT_PART = 'X'. * gs_marc-QUOTAUSAGE = gs_template-USEQU. "配额安排 * gs_marcx-QUOTAUSAGE = 'X'. * gs_marc-JIT_RELVT = gs_template-FABKZ. "标识: 与 JIT 交货计划相关的物料 * gs_marcx-JIT_RELVT = 'X'. * gs_marc-abc_id = '220'."gs_template-maabc. "abc标识 * gs_marcx-abc_id = 'X'. * gs_mara-var_ord_un = '220'."gs_template-vabme. "可变单位 * gs_marax-var_ord_un = 'X'. IF gs_template-umren IS NOT INITIAL. gt_marm-denominatr = gs_template-umren."分母 gt_marmx-denominatr = 'X'."分母 ENDIF. IF gs_template-meinh IS NOT INITIAL. gt_marm-alt_unit = gs_template-meinh."计量单位 gt_marmx-alt_unit = gs_template-meinh."计量单位 ENDIF. IF gs_template-umrez IS NOT INITIAL. gt_marm-numerator = gs_template-umrez."分子 gt_marmx-numerator = 'X'."分子 ENDIF. ENDIF. APPEND gt_marm. APPEND gt_marmx. *&---------------------------------------------------------------------* *& MRP视图1 *&---------------------------------------------------------------------* IF p_mrp = 'X'."MRP视图 gs_marc-mrp_type = gs_template-dismm. "mrp类型 gs_marcx-mrp_type = 'X'. gs_marc-reorder_pt = gs_template-minbe. "再订货点 gs_marcx-reorder_pt = 'X'. gs_marc-mrp_ctrler = gs_template-dispo. "mrp控制者 gs_marcx-mrp_ctrler = 'X'. gs_marc-lotsizekey = gs_template-disls. "批量大小 gs_marcx-lotsizekey = 'X'. gs_marc-fixed_lot = gs_template-bstfe. "固定批量大小 gs_marcx-fixed_lot = 'X'. gs_marc-minlotsize = gs_template-bstmi. "最小批量大小 gs_marcx-minlotsize = 'X'. gs_marc-maxlotsize = gs_template-bstma. "最大批量大小 gs_marcx-maxlotsize = 'X'. gs_marc-max_stock = gs_template-mabst. "最大库存水平 gs_marcx-max_stock = 'X'. gs_marc-pur_status = gs_template-mmsta. "工厂特定的物料状态 gs_marcx-pur_status = 'X'. gs_marc-round_val = gs_template-bstrf. "舍入值 gs_marcx-round_val = 'X'. gs_marc-proc_type = gs_template-beskz. "采购类型 gs_marcx-proc_type = 'X'. gs_marc-spproctype = gs_template-sobsl. "特殊采购类型 gs_marcx-spproctype = 'X'. gs_marc-backflush = gs_template-rgekz. "反冲 gs_marcx-backflush = 'X'. gs_marc-iss_st_loc = gs_template-lgpro. "生产仓储地点 gs_marcx-iss_st_loc = 'X'. gs_marc-sloc_exprc = gs_template-lgfsb. "外部采购仓储地点 gs_marcx-sloc_exprc = 'X'. gs_marc-inhseprodt = gs_template-dzeit. "自制生产时间 gs_marcx-inhseprodt = 'X'. gs_marc-plnd_delry = gs_template-plifz. "计划交货时间 gs_marcx-plnd_delry = 'X'. gs_marc-sm_key = gs_template-fhori. "计划边际码 gs_marcx-sm_key = 'X'. gs_marc-safety_stk = gs_template-eisbe. "安全库存 gs_marcx-safety_stk = 'X'. gs_marc-mrp_relevancy_dep_requirements = gs_template-ahdis. "MRP相关需求 gs_marcx-mrp_relevancy_dep_requirements = 'X'. * gs_marc-batch_mgmt = gs_template-xchpf. "批次管理 * gs_marcx-batch_mgmt = 'X'. gs_marc-availcheck = gs_template-mtvfp_mrp. "可用性检查 gs_marcx-availcheck = 'X'. * gs_marc-mrp_group = '0000'."gs_template-disgr. "mrp组 * gs_marcx-mrp_group = 'X'. *gs_marc-abc_id = '220'."gs_template-maabc. "abc标识 *gs_marcx-abc_id = 'X'. *gs_marc-assy_scrap = '220'."gs_template-ausss. "装配报废百分比 *gs_marcx-assy_scrap = 'X'. * gs_marc-plan_strgp = gs_template-strgr. "策略组 * gs_marcx-plan_strgp = 'X'. * gs_marc-consummode = gs_template-vrmod. "消耗模式 * gs_marcx-consummode = 'X'. * gs_marc-fwd_cons = gs_template-vint2. "向前消耗期间 * gs_marcx-fwd_cons = 'X'. * gs_marc-bwd_cons = gs_template-vint1. "逆向消耗期间 * gs_marcx-bwd_cons = 'X'. gs_marc-dep_req_id = gs_template-sbdkz. "独立/集中 gs_marcx-dep_req_id = 'X'. * gs_marc-comp_scrap = gs_template-kausf. "部件废品 * gs_marcx-comp_scrap = 'X'. ENDIF. *&---------------------------------------------------------------------* *& 会计1 *&---------------------------------------------------------------------* gs_mbew-val_area = gs_template-werks."估计范围 gs_mbewx-val_area = gs_template-werks."估计范围 IF p_kj = 'X'."会计 IF gs_template-bklas IS NOT INITIAL . gs_mbew-val_class = gs_template-bklas."评估分类 gs_mbewx-val_class = 'X'. ENDIF. gs_mbew-ml_active = gs_template-mlmaa."SML作业 gs_mbewx-ml_active = 'X'. IF gs_template-mlast IS NOT INITIAL . gs_mbew-ml_settle = gs_template-mlast."价格确定 gs_mbewx-ml_settle = 'X'. ENDIF. "若上传价格单位为空则默认值为‘1’ IF gs_template-peinh IS INITIAL. gs_mbew-price_unit = 1. ELSE. gs_mbew-price_unit = gs_template-peinh."价格单位 ENDIF. gs_mbewx-price_unit = 'X'. IF gs_template-vmvpr IS NOT INITIAL . gs_mbew-price_ctrl = gs_template-vmvpr."价格控制 gs_mbewx-price_ctrl = 'X'. ENDIF. IF gs_template-verpr IS NOT INITIAL . gs_mbew-moving_pr = gs_template-verpr."移动价格 gs_mbewx-moving_pr = 'X'. ENDIF. IF gs_template-stprs IS NOT INITIAL . gs_mbew-std_price = gs_template-stprs."标准价格 gs_mbewx-std_price = 'X'. ENDIF. ENDIF. *&---------------------------------------------------------------------* *& 成本1 *&---------------------------------------------------------------------* gs_mbew-qty_struct = gs_template-ekalr."用QS的成本估算 gs_mbewx-qty_struct = 'X'. gs_mbew-orig_mat = gs_template-hkmat."物料来源 gs_mbewx-orig_mat = 'X'. * IF gs_template-mmsta IS NOT INITIAL . * gs_marc-pur_status = gs_template-mmsta."工厂特定的物料状态 * gs_marcx-pur_status = 'X'. * ENDIF. * IF gs_template-losgr IS NOT INITIAL . * gs_marc-lot_size = gs_template-losgr."成本核算批量 * gs_marcx-lot_size = 'X'. * ENDIF. * gs_marc-specprocty = gs_template-sobsk."特殊采购成本核算 * gs_marcx-specprocty = 'X'. *&---------------------------------------------------------------------* *& 成本2 *&---------------------------------------------------------------------* * gs_mbew-plndprice1 = gs_template-zplp1."计划价格1 * gs_mbewx-plndprice1 = 'X'. * 调用创建物料主数据BAPI PERFORM frm_create_matnr. CLEAR:lv_message,lv_matnr. IF gs_return-type = 'S'."如果主数据创建成功 * CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' * EXPORTING * wait = 'X'. lv_matnr = gs_template-matnr. lv_message = '物料主数据创建成功'. "物料长文本 "更改物料描述长文本 CLEAR:ls_header,ls_lines. REFRESH lt_lines. ls_header-tdobject = 'MATERIAL'. ls_header-tdname = lv_matnr. ls_header-tdid = 'GRUN'. ls_header-tdspras = '1'. ls_lines-tdformat = '1'. ls_lines-tdline = gs_template-maktxl. APPEND ls_lines TO lt_lines. CALL FUNCTION 'SAVE_TEXT' EXPORTING client = sy-mandt header = ls_header * INSERT = ' ' savemode_direct = 'X' TABLES lines = lt_lines EXCEPTIONS id = 1 language = 2 name = 3 object = 4 OTHERS = 5. IF sy-subrc <> 0. ROLLBACK WORK. lv_message = '物料创建成功,但是长文本创建失败!'. gs_template-icon = icon_led_red. ELSE. COMMIT WORK. ENDIF. IF p_fl = 'X'. REFRESH:gt_return. CLEAR:lv_objectkeynew,lv_msg. lv_objectkeynew = lv_matnr. CALL FUNCTION 'BAPI_OBJCL_CREATE' EXPORTING objectkeynew = lv_objectkeynew objecttablenew = 'MARA' classnumnew = gs_template-class "分类编号 classtypenew = gs_template-klart "分类的类型 * status = '1' standardclass = 'X' * changenumber = * keydate = sy-datum * no_default_values = '' * objectkeynew_long = * IMPORTING * classif_status = TABLES * allocvaluesnum = * allocvalueschar = * allocvaluescurr = return = gt_return. CLEAR:gs_return,lv_check. lv_check = 'S'. CLEAR:lv_msg. LOOP AT gt_return INTO gs_return WHERE type = 'E' OR type = 'A'. lv_check = 'E'. CONCATENATE lv_msg gs_return-message INTO lv_msg. CLEAR:gs_return. ENDLOOP. IF lv_check = 'S'. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. ELSEIF lv_check = 'E'. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. CONCATENATE lv_message '/' lv_msg INTO lv_message. gs_template-icon = icon_led_red. ENDIF. ENDIF. ******************维护质量视图******************************************** IF p_zl = 'X' . CLEAR:lv_msg. IF gs_template-art IS NOT INITIAL. ls_qmat-insptype = gs_template-art."检验类型 ls_qmat-material = lv_matnr."物料编码 ls_qmat-plant = gs_template-werks."工厂 ls_qmat-ind_insptype_mat_active = gs_template-aktiv."检验类型 - 物料合并已激活 READ TABLE gt_art INTO gs_art WITH KEY art = gs_template-art BINARY SEARCH. IF sy-subrc = 0. ls_qmat-ind_insp_with_tsk_list = gs_art-ppl."有任务清单的检验 ls_qmat-ind_spec_matspec = gs_art-spezueber."使用物料说明的检验 ls_qmat-ind_spec_config = gs_art-conf."来自配置的检验规范 ls_qmat-ind_spec_batch = gs_art-tls."批次确定的检验规范 ls_qmat-ind_auto_assign = gs_art-app."自动规格分配 ls_qmat-ind_insp_by_charac = gs_art-mer."按特性检验 ls_qmat-ind_post_to_insp_stock = gs_art-insmk."过帐到检验库存 ls_qmat-ind_automatic_ud = gs_art-ave."自动用途决定 ls_qmat-sampling_procedure = gs_art-stichprver."采样程序 ls_qmat-dyn_modif_rule = gs_art-dynregel."动态修改规则 ls_qmat-insp_percentage = gs_art-sproz."检验百分比 ls_qmat-ind_100_percent_inspection = gs_art-hpz."100% 检验 ls_qmat-ind_skips_allowed = gs_art-dyn."允许略过 ls_qmat-ind_manual_sample = gs_art-mpb."手工输入采样 ls_qmat-ind_manual_sample_calc = gs_art-mst."手动触发采样计算 ls_qmat-ind_single_units_possible = gs_art-ein."可能的序列号管理 ls_qmat-ave_insp_duration = gs_art-mpdau."平均检验期 ls_qmat-contr_insp_lot_create = gs_art-chg."控制检验批创建(批次摘要) ls_qmat-qual_score_procedure = gs_art-qkzverf."质量记分过程 ls_qmat-allowed_scrap_share = gs_art-qpmat."检验批中允许的废品份额(百分比) ENDIF. APPEND ls_qmat TO lt_qmat. CLEAR:ls_qmat. REFRESH:gt_return. CALL FUNCTION 'BAPI_MATINSPCTRL_SAVEREPLICA' TABLES return = gt_return inspectionctrl = lt_qmat. lv_check = 'S'. CLEAR:lv_msg. LOOP AT gt_return INTO gs_return WHERE type = 'E' OR type = 'A'. lv_check = 'E'. CONCATENATE lv_msg gs_return-message INTO lv_msg. CLEAR:gs_return. ENDLOOP. IF lv_check = 'S'. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. ELSEIF lv_check = 'E'. CLEAR: lv_message. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. CONCATENATE lv_message '/质量检验设置扩展失败:' lv_msg INTO lv_message. gs_template-icon = icon_led_red. ENDIF. ENDIF. ENDIF. IF p_kj = 'X'."会计1 IF gs_template-is_fgpg IS NOT INITIAL."启用分割评估 gs_mbew-val_cat = gs_template-bwtty."评估类别 gs_mbewx-val_cat = 'X'. PERFORM frm_create_matnr. IF gs_return-type = 'S'. gs_mbew-val_class = gs_template-bklas_fg."评估分类 gs_mbewx-val_class = 'X'. gs_mbew-val_cat = gs_template-bwtty."评估类别 gs_mbewx-val_cat = 'X'. gs_mbew-val_type = gs_template-bwtar."评估类型 gs_mbewx-val_type = gs_template-bwtar. PERFORM frm_create_matnr. IF gs_return-type = 'E'. CONCATENATE lv_message '/' gs_template-log INTO lv_message. ENDIF. ELSE. CONCATENATE lv_message '/' gs_template-log INTO lv_message. ENDIF. ENDIF. ENDIF. gs_template-log = lv_message. ENDIF. MODIFY gt_template FROM gs_template TRANSPORTING icon log. CLEAR:gs_template. ENDLOOP. ENDFORM. " FRM_SAVE_DATA FORM frm_create_matnr. CLEAR:gs_return. CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA' EXPORTING headdata = gs_headdata clientdata = gs_mara clientdatax = gs_marax plantdata = gs_marc plantdatax = gs_marcx * FORECASTPARAMETERS = * FORECASTPARAMETERSX = * PLANNINGDATA = * PLANNINGDATAX = storagelocationdata = gs_mard storagelocationdatax = gs_mardx valuationdata = gs_mbew valuationdatax = gs_mbewx * WAREHOUSENUMBERDATA = * WAREHOUSENUMBERDATAX = salesdata = gs_mvke salesdatax = gs_mvkex * STORAGETYPEDATA = * STORAGETYPEDATAX = * FLAG_ONLINE = ' ' * FLAG_CAD_CALL = ' ' * NO_DEQUEUE = ' ' * NO_ROLLBACK_WORK = ' ' IMPORTING return = gs_return TABLES materialdescription = gt_makt unitsofmeasure = gt_marm unitsofmeasurex = gt_marmx internationalartnos = gt_mean * MATERIALLONGTEXT = taxclassifications = gt_mlan * RETURNMESSAGES = * PRTDATA = * PRTDATAX = * EXTENSIONIN = * EXTENSIONINX = * NFMCHARGEWEIGHTS = * NFMCHARGEWEIGHTSX = * NFMSTRUCTURALWEIGHTS = * NFMSTRUCTURALWEIGHTSX = . IF gs_return-type = 'S'."如果主数据创建成功 CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. ELSEIF gs_return-type = 'E' OR gs_return-type = 'A'. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. MESSAGE ID gs_return-id TYPE gs_return-type NUMBER gs_return-number WITH gs_return-message_v1 gs_return-message_v2 gs_return-message_v3 gs_return-message_v4 INTO gs_template-log. gs_template-icon = icon_led_red. ENDIF. ENDFORM.
"-----------------------------@斌将军-----------------------------