避免CRM_IB 013 error message
Created by Jerry Wang on Jul 27, 2014
當(dāng)創(chuàng)建一個(gè)IBASE的object component時(shí),如果assign的object 已經(jīng)存在于系統(tǒng)里已有的其他IBASE object component上,就會(huì)遇到如下error message:
在CHECK_FOR_COMPONENT里拋出error message:
在用代碼生成大批量IBASE 測(cè)試數(shù)據(jù)用于性能測(cè)試時(shí),如果要避免這個(gè)error message, 可以參考系統(tǒng)里點(diǎn)了Yes button之后的標(biāo)準(zhǔn)實(shí)現(xiàn):
實(shí)際上是調(diào)用了IBASE genil model里的MOVE_COMPONENT:
另一種思路是,每次生成一個(gè)IBASE object component時(shí),都預(yù)先用代碼生成一個(gè)unique的object,這樣能保證assign 到object component里的object不會(huì)出現(xiàn)被其他IBASE component使用到的情況。
執(zhí)行report,輸入待創(chuàng)建的Object component包含Object的ID,object family和object category:
report執(zhí)行成功,打印創(chuàng)建好的IBASE ID:
根據(jù)IBASE ID到UI上check,發(fā)現(xiàn)Object component包含的Object 信息和執(zhí)行report時(shí)維護(hù)的信息一致。
report和創(chuàng)建object的class ZCL_OBJECT_GENERATOR代碼如下:
REPORT zibase_create_unique.PARAMETERS: txt TYPE char40 OBLIGATORY DEFAULT 'description test',eid TYPE char30 OBLIGATORY DEFAULT 'PROGRAM',oid TYPE comm_product-product_id OBLIGATORY DEFAULT 'CHILDOBJ8',fam TYPE comm_product-object_family OBLIGATORY DEFAULT '0401',cat TYPE COMT_CATEGORY_ID OBLIGATORY DEFAULT 'OBJ_0401'.DATA: lt_param TYPE crmt_name_value_pair_tab,ls_param TYPE crmt_name_value_pair,lr_core TYPE REF TO cl_crm_bol_core,ls_object TYPE comm_product,lr_root TYPE REF TO if_bol_entity_col,entity TYPE REF TO cl_crm_bol_entity.CHECK zcl_object_generator=>create_object( iv_id = oid iv_family = fam iv_catid = cat ) = abap_true.ls_param-name = cl_crm_ibase_il_constant=>createparam. ls_param-value = '01'. APPEND ls_param TO lt_param.lr_core = cl_crm_bol_core=>get_instance( ). lr_core->load_component_set('IBASE_ONLY').CALL METHOD lr_core->root_createEXPORTINGiv_object_name = cl_crm_ibase_il_constant=>root_objectiv_create_param = lt_paramiv_number = 1RECEIVINGrv_result = lr_root.CHECK lr_root IS BOUND. entity ?= lr_root->get_current( ).CHECK entity IS BOUND. IF entity->lock( ) = abap_true.entity->switch_to_change_mode( ). ENDIF.entity->set_property_as_string( iv_attr_name = 'DESCR' iv_value = CONV #( txt ) ). entity->set_property_as_string( iv_attr_name = 'EXTID' iv_value = CONV #( eid ) ). "entity->set_property_as_string( iv_attr_name = 'IBTYP' iv_value = '01' ). lr_core->modify( ). DATA(lv_ibase_id) = entity->get_property_as_string( 'IBASE' ).DATA(component) = entity->create_related_entity( 'FirstLevelComponent' ).CHECK component IS NOT INITIAL.DATA(obj_comp) = component->create_related_entity( 'IBCompObj').CHECK obj_comp IS NOT INITIAL.obj_comp->set_property_as_string( iv_attr_name = 'OBJECT_ID' iv_value = CONV #( oid ) ).SELECT SINGLE * INTO ls_object FROM comm_product WHERE product_id = oid. ASSERT sy-subrc = 0.obj_comp->set_property_as_string( iv_attr_name = 'OBJECT_GUID' iv_value = CONV #( ls_object-product_guid ) ). obj_comp->set_property_as_string( iv_attr_name = 'OBJECT_FAMILY' iv_value = CONV #( ls_object-product_guid ) ). lr_core->modify( ).DATA(lo_message_container) = entity->get_message_container( ). CALL METHOD lo_message_container->get_messagesEXPORTINGiv_message_type = if_genil_message_container=>mt_allIMPORTINGet_messages = DATA(lt_msg1). LOOP AT lt_msg1 ASSIGNING FIELD-SYMBOL(<msg1>).WRITE:/ <msg1>-message COLOR COL_NEGATIVE. ENDLOOP.CHECK lt_msg1 IS INITIAL.DATA(lo_transaction) = lr_core->get_transaction( ). DATA(lv_changed) = lo_transaction->check_save_needed( ).CHECK lv_changed EQ abap_true.DATA(lv_success) = lo_transaction->save( ).DATA(lo_glb_msg_cont) = lr_core->get_global_message_cont( ). CALL METHOD lo_glb_msg_cont->if_genil_message_container~get_messagesEXPORTINGiv_message_type = if_genil_message_container=>mt_allIMPORTINGet_messages = DATA(lt_msg). LOOP AT lt_msg ASSIGNING FIELD-SYMBOL(<msg>).WRITE:/ <msg>-message. ENDLOOP.IF lv_success = abap_true.lo_transaction->commit( ).WRITE:/ 'IBASE Created Successfully: ', lv_ibase_id COLOR COL_NEGATIVE. ELSE.lo_transaction->rollback( ). ENDIF.CLASS zcl_object_generator DEFINITIONPUBLICFINALCREATE PUBLIC .PUBLIC SECTION.TYPE-POOLS abap .CLASS-METHODS create_objectIMPORTING!iv_id TYPE comm_product-product_id!iv_family TYPE comm_product-object_family!iv_catid TYPE comt_category_idRETURNINGVALUE(rv_create_ok) TYPE abap_bool .CLASS-METHODS class_constructor .PROTECTED SECTION.PRIVATE SECTION.CLASS-DATA so_core TYPE REF TO cl_crm_bol_core .CLASS-DATA so_fact TYPE REF TO cl_crm_bol_entity_factory .CLASS-DATA sv_id TYPE comm_product-product_id .CLASS-DATA sv_fam TYPE comm_product-object_family .CLASS-DATA sv_catid TYPE comt_category_id .CLASS-METHODS initIMPORTING!iv_id TYPE comm_product-product_id!iv_family TYPE comm_product-object_family!iv_catid TYPE comt_category_id .CLASS-METHODS create_header .TYPE-POOLS abap .CLASS-METHODS saveRETURNINGVALUE(rv_create_ok) TYPE abap_bool . ENDCLASS.CLASS ZCL_OBJECT_GENERATOR IMPLEMENTATION.* <SIGNATURE>---------------------------------------------------------------------------------------+ * | Static Public Method ZCL_OBJECT_GENERATOR=>CLASS_CONSTRUCTOR * +-------------------------------------------------------------------------------------------------+ * +--------------------------------------------------------------------------------------</SIGNATURE>METHOD class_constructor.so_core = cl_crm_bol_core=>get_instance( ).so_core->load_component_set( 'PROD_ALL' ).so_fact = so_core->get_entity_factory( 'Product' ).ENDMETHOD.* <SIGNATURE>---------------------------------------------------------------------------------------+ * | Static Private Method ZCL_OBJECT_GENERATOR=>CREATE_HEADER * +-------------------------------------------------------------------------------------------------+ * +--------------------------------------------------------------------------------------</SIGNATURE>METHOD create_header.DATA: lt_param TYPE crmt_name_value_pair_tab,ls_param TYPE crmt_name_value_pair.ls_param-name = 'PRODUCT_ID'.ls_param-value = sv_id.APPEND ls_param TO lt_param.ls_param-name = 'PRODUCT_TYPE'.ls_param-value = '01'.APPEND ls_param TO lt_param.ls_param-name = 'ROOT_CAT_ID'.ls_param-value = sv_catid.APPEND ls_param TO lt_param.ls_param-name = 'ROOT_HIER_ID'.ls_param-value = 'R3PRODSTYP'.APPEND ls_param TO lt_param.ls_param-name = 'SHORT_TEXT'.ls_param-value = 'Dummy'.APPEND ls_param TO lt_param.ls_param-name = 'OBJECT_FAMILY'.ls_param-value = sv_fam.APPEND ls_param TO lt_param.DATA(lr_product) = so_fact->create( lt_param ).IF lr_product IS INITIAL.DATA(lo_glb_msg_cont) = so_core->get_global_message_cont( ).CALL METHOD lo_glb_msg_cont->if_genil_message_container~get_messagesEXPORTINGiv_message_type = if_genil_message_container=>mt_allIMPORTINGet_messages = DATA(lt_msg).LOOP AT lt_msg ASSIGNING FIELD-SYMBOL(<msg>).WRITE:/ <msg>-message.ENDLOOP.ENDIF.ENDMETHOD.* <SIGNATURE>---------------------------------------------------------------------------------------+ * | Static Public Method ZCL_OBJECT_GENERATOR=>CREATE_OBJECT * +-------------------------------------------------------------------------------------------------+ * | [--->] IV_ID TYPE COMM_PRODUCT-PRODUCT_ID * | [--->] IV_FAMILY TYPE COMM_PRODUCT-OBJECT_FAMILY * | [--->] IV_CATID TYPE COMT_CATEGORY_ID * | [<-()] RV_CREATE_OK TYPE ABAP_BOOL * +--------------------------------------------------------------------------------------</SIGNATURE>METHOD create_object.init( iv_id = iv_id iv_family = iv_family iv_catid = iv_catid ).create_header( ).rv_create_ok = save( ).ENDMETHOD.* <SIGNATURE>---------------------------------------------------------------------------------------+ * | Static Private Method ZCL_OBJECT_GENERATOR=>INIT * +-------------------------------------------------------------------------------------------------+ * | [--->] IV_ID TYPE COMM_PRODUCT-PRODUCT_ID * | [--->] IV_FAMILY TYPE COMM_PRODUCT-OBJECT_FAMILY * | [--->] IV_CATID TYPE COMT_CATEGORY_ID * +--------------------------------------------------------------------------------------</SIGNATURE>METHOD init.sv_id = iv_id.sv_fam = iv_family.sv_catid = iv_catid.ENDMETHOD.* <SIGNATURE>---------------------------------------------------------------------------------------+ * | Static Private Method ZCL_OBJECT_GENERATOR=>SAVE * +-------------------------------------------------------------------------------------------------+ * | [<-()] RV_CREATE_OK TYPE ABAP_BOOL * +--------------------------------------------------------------------------------------</SIGNATURE>METHOD save.DATA(lo_transaction) = so_core->get_transaction( ).DATA(lv_changed) = lo_transaction->check_save_needed( ).CHECK lv_changed EQ abap_true.DATA(lv_success) = lo_transaction->save( ).IF lv_success = abap_true.lo_transaction->commit( ).rv_create_ok = abap_true.ELSE.lo_transaction->rollback( ).ENDIF.so_core->reset( ).ENDMETHOD. ENDCLASS.總結(jié)
以上是生活随笔為你收集整理的避免CRM_IB 013 error message的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 通过SAP customizing修改显
- 下一篇: s11机器人怎么出装比较猛 LOL出装顺