本文主要是介绍CO11N报工使用BAPI_PRODORDCONF_CREATE_TT时无法返回配置错误消息CK466,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
前些天碰到一个问题,CO11N前台报工时,会触发一个配置E类型的消息CK466,但是在调用BAPI_PRODORDCONF_CREATE_TT时,该消息并不会返回,而是返回S类型消息。
错误重现:
1.kp26取消维护变动价格
2.SM30及SE16N将对应的错误消息类型更改为E
视图:V_TCMF9
表:TCMFA
此时前台执行CO11N就会触发CK466的报错,经过代码追踪,发现问题所在:
在Form det_conf_cost中,其实会捕获到配置的E类型消息,但是只会当以下三种情况时才会捕获错误消息且终止报工。
1.前台处理时:
2.后台处理时:
3.当订单类型是网络订单时:
除此以外的情况,都不会打上取消标记并下入下面的错误处理逻辑:
所以问题就在于让BAPI调用时也能够将错误消息收集起来,经过对源码进一步分析,错误最终会返回在内表 t_cost_cmfnr 中,只需要找到合适的增强点,调用上述处理函数CM_F_MESSAGES_GET并触发异常no_costing,即可将配置出来的错误消息返回给BAPI的return参数。
解决方案:重写系统预留增强选项。
ENHANCEMENT 1 ZE_PRODCONF_CATCH_ERR. "active version
* >>> Operation Account Assignment
* In the case of OLC PM/CS order need to initialize and then free
* a buffer for the order operations in the pmco_op update.
* This is due to performance issues when confirming mass operations
* especially during CAT9 transfer.IF cl_erp_co_olc_tools=>is_olc_relevant( caufvd-netzkont ) = abap_true ANDcaufvd-autyp = auftragstyp-inst.CALL FUNCTION 'PMCO_OPS_BUFFER_INIT'.PERFORM det_conf_cost USING caufvd.CALL FUNCTION 'PMCO_OPS_BUFFER_FREE'.ELSE.PERFORM det_conf_cost USING caufvd.ENDIF.* Catch cost error for BAPI BAPI_PRODORDCONF_CREATE_TTIF flg_bapi = abap_true.READ TABLE t_cost_cmfnr INTO DATA(ls_cost_cmfnr)WITH KEY msgty = 'E'.IF sy-subrc = 0.ROLLBACK WORK.DATA lt_cmfmsg TYPE STANDARD TABLE OF cmfmsg.MOVE-CORRESPONDING t_cost_cmfnr[] TO lt_cmfmsg.* Bei Storno Fehlermeldung aus CO anzeigenCALL FUNCTION 'CM_F_MESSAGES_GET'EXPORTINGaplid = aplid_ppruTABLESe_msgprot = lt_cmfmsgEXCEPTIONSnot_active = 1OTHERS = 2.IF sy-subrc IS INITIAL.
* Erste Fehlermeldung ausgebenREAD TABLE lt_cmfmsg INTO DATA(ls_cmfmsg)WITH KEY msgty = message_type-error.MESSAGE ID ls_cmfmsg-arbgb TYPE message_type-errorNUMBER ls_cmfmsg-msgnr WITH ls_cmfmsg-msgv1ls_cmfmsg-msgv2 ls_cmfmsg-msgv3 ls_cmfmsg-msgv4RAISING no_costing.ENDIF.IF caufvd-autyp NE auftragstyp-netw.MESSAGE a085 WITH caufvd-aufnr RAISING no_costing.ELSE.MESSAGE a087 WITH caufvd-aufnr RAISING no_costing.ENDIF.ENDIF.ENDIF.
* <<< Operation Account Assignment
ENDENHANCEMENT.
代码测试:
REPORT ztest_13065_co11n.DATA:ls_propose TYPE bapi_pp_conf_prop,lt_timetickets TYPE STANDARD TABLE OF bapi_pp_timeticket,ls_timetickets TYPE bapi_pp_timeticket,lt_goodsmovements TYPE STANDARD TABLE OF bapi2017_gm_item_create,ls_goodsmovements TYPE bapi2017_gm_item_create,lt_link_conf_goodsmov TYPE STANDARD TABLE OF bapi_link_conf_goodsmov,lt_return TYPE STANDARD TABLE OF bapi_coru_return,ls_return TYPE bapiret1.ls_propose-quantity = 'X'.
ls_propose-activity = 'X'.
ls_propose-date_and_time = 'X'.
ls_propose-goodsmovement = 'X'.ls_timetickets-orderid = '000001001322'.
ls_timetickets-operation = '0010'.
APPEND ls_timetickets TO lt_timetickets.ls_goodsmovements-orderid = '000001001322'.
ls_goodsmovements-order_itno = '0010'.
APPEND ls_goodsmovements TO lt_goodsmovements.CALL FUNCTION 'BAPI_PRODORDCONF_GET_TT_PROP'EXPORTINGpropose = ls_proposeIMPORTINGreturn = ls_returnTABLEStimetickets = lt_timeticketsgoodsmovements = lt_goodsmovementslink_conf_goodsmov = lt_link_conf_goodsmov
* DETAIL_RETURN =
* FSH_BUNDLES =.CALL FUNCTION 'BAPI_PRODORDCONF_CREATE_TT'EXPORTINGpost_wrong_entries = '2'
* testrun = 'X'
* call_on_inbound_queue = 'A'IMPORTINGreturn = ls_returnTABLEStimetickets = lt_timeticketsgoodsmovements = lt_goodsmovementslink_conf_goodsmov = lt_link_conf_goodsmov
* CHARACTERISTICS_WIPBATCH =
* LINK_CONF_CHAR_WIPBATCH =detail_return = lt_return
* CHARACTERISTICS_BATCH =
* LINK_GM_CHAR_BATCH =.cl_demo_output=>new( )->begin_section( 'ls_return' )->write_data( ls_return)->begin_section( 'lt_return' )->write_data( lt_return)->display( ).
BAPI返回结果:
同理应该可以解决类似情况的相同问题,以上。
这篇关于CO11N报工使用BAPI_PRODORDCONF_CREATE_TT时无法返回配置错误消息CK466的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!