1、问题介绍
在CL03中看到分类特性配置了制造日期字段,并绑定了生产日期字段MCH1~HSDAT
MSC2N修改批次的生产日期字段时,自动修改了对应的批次特性
但是通过BAPI:BAPI_BATCH_CHANGE修改生产日期时,并没有更新到批次特性中
2、BAPI
根据官方提示,需要使用BAPI:BAPI_BATCH_SAVE_REPLICA来同步更新批次特性
在BAPI_BATCH_SAVE_REPLICA中可以传入基本数据视图中的生产日期
"--------------------@斌将军-------------------- CLEAR:ls_batchattributes,ls_batchattributesx. ls_batchattributes-prod_date = sy-datum."生产日期 ls_batchattributesx-prod_date = 'X' ."生产日期 "--------------------@斌将军--------------------
同时维护批次特性的值
"--------------------@斌将军-------------------- CLEAR:ls_classvaluationschar. ls_classvaluationschar-class_type = lv_klart. *ls_classvaluationschar-objectkey = lv_objectkey. ls_classvaluationschar-objectkey_long = lv_objek. ls_classvaluationschar-objecttable = lv_obtab. ls_classvaluationschar-charact = 'ZSC_BATCH_HSDAT'. ls_classvaluationschar-value_char = sy-datum. APPEND ls_classvaluationschar TO lt_classvaluationschar. "--------------------@斌将军--------------------
完整代码参考
"--------------------@斌将军-------------------- REPORT ytest010. DATA:lv_material TYPE bapibatchkey-material, lv_batch TYPE bapibatchkey-batch, lv_plant TYPE bapibatchkey-plant, lv_matnr TYPE matnr. "40位 DATA:lv_objek TYPE cuobn, lv_obtab TYPE tabelle, lv_klart TYPE klassenart, lv_class TYPE klasse_d. DATA:ls_batchattributes TYPE bapibatchatt, ls_batchattributesx TYPE bapibatchattx, lt_classallocations TYPE TABLE OF bapi3060_allocation, ls_classallocations TYPE bapi3060_allocation, lt_classvaluationschar TYPE TABLE OF bapi3060_valuation_char, ls_classvaluationschar TYPE bapi3060_valuation_char, lt_classvaluationscurr TYPE TABLE OF bapi3060_valuation_curr, ls_classvaluationscurr TYPE bapi3060_valuation_curr, lt_classvaluationsnum TYPE TABLE OF bapi3060_valuation_num, ls_classvaluationsnum TYPE bapi3060_valuation_num, lt_return TYPE TABLE OF bapiret2, ls_return TYPE bapiret2. lv_matnr = '41155126C'."物料 lv_batch = 'P001055009'."批次 lv_plant = 'SC10'."工厂 CLEAR:lv_objek,lv_obtab,lv_klart,lv_class. *lv_matnr = lv_material. CALL FUNCTION 'VB_BATCH_2_CLASS_OBJECT' EXPORTING i_matnr = lv_matnr i_charg = lv_batch i_werks = lv_plant IMPORTING e_objek = lv_objek e_obtab = lv_obtab e_klart = lv_klart e_class = lv_class. *后边可以直接使用lv_objek值, *不需要用BAPI_OBJCL_CONCATENATEKEY专门生成lv_objectkey *lt_objectkeytable = VALUE #( ( key_field = 'MATNR' value_int = LV_material ) * ( key_field = 'WERKS' value_int = lv_plant ) * ( key_field = 'CHARG' value_int = lv_batch ) * ). * *"获取key值objectkey(物料和批次) *REFRESH:lt_return. *CLEAR:lv_objectkey. *CALL FUNCTION 'BAPI_OBJCL_CONCATENATEKEY' * EXPORTING * objecttable = lv_obtab "表名 * IMPORTING * objectkey_conc = lv_objectkey * TABLES * objectkeytable = lt_objectkeytable * return = lt_return. * *LOOP AT lt_return INTO ls_return WHERE type CA 'EAX'. * MESSAGE '获取特性失败:未查询到分类密钥' TYPE 'S' DISPLAY LIKE 'E'. *ENDLOOP. "修改批次数据 CLEAR:ls_batchattributes,ls_batchattributesx. ls_batchattributes-prod_date = sy-datum."生产日期 ls_batchattributesx-prod_date = 'X' ."生产日期 "修改分类特性值 CLEAR:ls_classallocations. ls_classallocations-class_type = lv_klart. *ls_classallocations-objectkey = lv_objectkey. ls_classallocations-objectkey_long = lv_objek. ls_classallocations-objecttable = lv_obtab. ls_classallocations-classnum = lv_class. ls_classallocations-classtype = lv_klart. ls_classallocations-standardclass = 'X'. APPEND ls_classallocations TO lt_classallocations. CLEAR:ls_classvaluationschar. ls_classvaluationschar-class_type = lv_klart. *ls_classvaluationschar-objectkey = lv_objectkey. ls_classvaluationschar-objectkey_long = lv_objek. ls_classvaluationschar-objecttable = lv_obtab. ls_classvaluationschar-charact = 'ZSC_BATCH_HSDAT'. ls_classvaluationschar-value_char = sy-datum. APPEND ls_classvaluationschar TO lt_classvaluationschar. CALL FUNCTION 'BAPI_BATCH_SAVE_REPLICA' EXPORTING material_long = lv_matnr "长物料 * material = lv_material batch = lv_batch plant = lv_plant batchattributes = ls_batchattributes batchattributesx = ls_batchattributesx TABLES return = lt_return classallocations = lt_classallocations classvaluationschar = lt_classvaluationschar classvaluationscurr = lt_classvaluationscurr classvaluationsnum = lt_classvaluationsnum. DATA:lv_check TYPE char1, lv_message TYPE char255. CLEAR:lv_message. LOOP AT lt_return INTO ls_return WHERE type CA 'EAX'. lv_message = lv_message && ls_return-message. lv_check = 'E'. ENDLOOP. IF lv_check = 'E'. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. WRITE:lv_message. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. ENDIF. "--------------------@斌将军--------------------
定期更文,欢迎关注
TRANSLATE with x English TRANSLATE with COPY THE URL BELOW Back EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget: Bing Webmaster Portal Back 此页面的语言为英语 翻译为中文(简体) 标签:BAPI,classvaluationschar,BATCH,lv,lt,objectkey,ls,自动更新,TYPE From: https://www.cnblogs.com/BinGeneral/p/18586561