Chinaunix首页 | 论坛 | 博客
  • 博客访问: 691209
  • 博文数量: 145
  • 博客积分: 3446
  • 博客等级: 中校
  • 技术积分: 1567
  • 用 户 组: 普通用户
  • 注册时间: 2006-08-30 13:58
文章分类

全部博文(145)

文章存档

2021年(1)

2020年(1)

2019年(1)

2018年(6)

2017年(1)

2016年(10)

2015年(12)

2014年(10)

2013年(15)

2012年(33)

2011年(21)

2010年(9)

2009年(18)

2008年(2)

2006年(5)

我的朋友

分类: 系统运维

2012-07-18 11:39:59


  DATA le_partner_guid TYPE bu_partner_guid .
  DATA ls_header       TYPE crmst_header_object_buil .
  DATA: lv_bol_core    TYPE REF TO cl_crm_bol_core.
  DATA: lv_root        TYPE REF TO cl_crm_bol_entity.
  DATA: lv_address     TYPE REF TO cl_crm_bol_entity.
  DATA: ls_address     TYPE crmst_address_buil .
  DATA: lc_id_name     TYPE REF TO if_bol_bo_col.
  DATA: lt_id_name     TYPE REF TO if_bol_bo_col_iterator.
  DATA: lv_id_name     TYPE REF TO cl_crm_bol_entity.
  DATA: ls_id_name     TYPE crmt_bupa_il_identification .
  DATA: lc_ind_sector  TYPE REF TO if_bol_bo_col.
  DATA: lt_ind_sector  TYPE REF TO if_bol_bo_col_iterator.
  DATA: lv_ind_sector  TYPE REF TO cl_crm_bol_entity.
  DATA: ls_ind_sector  TYPE crmt_bupa_il_industrysector .
  DATA le_lock TYPE c .
 
* 1. Build parameters to create an entity:
* here an order entity with technical name ‘BTOrder’
* Start BOL Core module
  DATA: lv_bol_core TYPE REF TO cl_crm_bol_core.
  lv_bol_core = cl_crm_bol_core=>get_instance( ).
  lv_bol_core->start_up( 'ONEORDER' ).
  DATA: lt_params TYPE crmt_name_value_pair_tab,
  ls_params TYPE crmt_name_value_pair.
  ls_params-name = 'PROCESS_TYPE'.
  ls_params-value = ls_plan-process_type.
  APPEND ls_params TO lt_params.
* 2. Get factory for business object
  DATA: lv_bol_factory TYPE REF TO cl_crm_bol_entity_factory.
  lv_bol_factory = lv_bol_core->get_entity_factory( 'BTOrder' ).
* 3. Create root entity
  DATA: lv_root TYPE REF TO cl_crm_bol_entity.
  lv_root = lv_bol_factory->create( lt_params ).

*******************************************************************************
  SELECT SINGLE partner_guid INTO le_partner_guid
    FROM but000
    WHERE partner = in_bupa-partner .
  CHECK le_partner_guid IS NOT INITIAL .
  lv_bol_core = cl_crm_bol_core=>get_instance( ).
  lv_bol_core->start_up( 'BP_APPL' ).
  TRY.
      CALL METHOD lv_bol_core->get_root_entity
        EXPORTING
          iv_object_name = 'BuilHeader'
          iv_object_guid = le_partner_guid
        RECEIVING
          rv_result      = lv_root.
    CATCH cx_crm_genil_model_error .
  ENDTRY.
* Create child objects
  IF lv_root IS BOUND .
    le_lock = lv_root->lock( ).
    CHECK le_lock = 'X' .
************header
    CLEAR ls_header .
    CALL METHOD lv_root->if_bol_bo_property_access~get_properties
      IMPORTING
        es_attributes = ls_header.
    ls_header-name1       = in_bupa-name .
    ls_header-zzfld00000x = in_bupa-zzfld00000x .
    ls_header-ZZTPPSTATUS = in_bupa-ZZTPPSTATUS .
    CALL METHOD lv_root->if_bol_bo_property_access~set_properties
      EXPORTING
        is_attributes = ls_header.
    lv_address = lv_root->get_related_entity( iv_relation_name = 'BuilStandardAddressRel' ).
    IF lv_address IS NOT BOUND.
      lv_address = lv_root->create_related_entity( iv_relation_name = 'BuilStandardAddressRel' ).
    ENDIF.
    CLEAR ls_address .
    CALL METHOD lv_address->if_bol_bo_property_access~get_properties
      IMPORTING
        es_attributes = ls_address.
*    ls_address-street     = in_bupa-street .
*    ls_address-postl_cod1 = in_bupa-post_code .
*    ls_address-city       = in_bupa-city .
*    ls_address-region     = in_bupa-region .
*    ls_address-country    = in_bupa-country .
*    ls_address-regiogroup = in_bupa-regiogroup .
*    ls_address-telephonetel = in_bupa-tel_no .
*    ls_address-faxfax     = in_bupa-fax_no .
*
*    CALL METHOD lv_address->if_bol_bo_property_access~set_properties
*      EXPORTING
*        is_attributes = ls_address.

**************** 外部号码
    IF in_bupa-ref_no IS NOT INITIAL .
      FREE lv_id_name .
      lc_id_name = lv_root->get_related_entities( iv_relation_name = 'BuilIdentificationRel' ).
      IF lc_id_name IS BOUND .
        lt_id_name = lc_id_name->get_iterator( ).
        IF lt_id_name IS BOUND .
          lv_id_name ?= lt_id_name->find_by_property( iv_attr_name = 'IDENTIFICATIONTYPE'
                                                      iv_value = 'CRM001' ).
        ENDIF .
      ENDIF .
      IF lv_id_name IS NOT BOUND .
        lv_id_name = lv_root->create_related_entity( iv_relation_name = 'BuilIdentificationRel' ).
      ENDIF .
      IF lv_id_name IS BOUND .
        CLEAR ls_id_name .
        CALL METHOD lv_id_name->if_bol_bo_property_access~get_properties
          IMPORTING
            es_attributes = ls_id_name.
        ls_id_name-identificationcategory = 'CRM001' .
        ls_id_name-identificationtype     = 'CRM001' .
        ls_id_name-identificationnumber   = in_bupa-ref_no .
        CALL METHOD lv_id_name->if_bol_bo_property_access~set_properties
          EXPORTING
            is_attributes = ls_id_name.
      ENDIF .
    ENDIF .
**************** 类型
    IF in_bupa-ind_sector IS NOT INITIAL .
      FREE lv_ind_sector .
      lc_ind_sector = lv_root->get_related_entities( iv_relation_name = 'BuilIndustrySectorRel' ).
      IF lc_ind_sector IS BOUND .
        lt_ind_sector = lc_ind_sector->get_iterator( ).
        IF lt_ind_sector IS BOUND .
          lv_ind_sector ?= lt_ind_sector->get_first( ).
          WHILE lv_ind_sector IS BOUND.
            lv_ind_sector->delete( ).
            lv_ind_sector ?= lt_ind_sector->get_next( ).
          ENDWHILE .
        ENDIF .
      ENDIF .
      lv_ind_sector = lv_root->create_related_entity( iv_relation_name = 'BuilIndustrySectorRel' ).
      IF lv_ind_sector IS BOUND .
        CLEAR ls_ind_sector .
        CALL METHOD lv_ind_sector->if_bol_bo_property_access~get_properties
          IMPORTING
            es_attributes = ls_ind_sector.
        ls_ind_sector-industrysectorkeysystem = 'Z001' .
        ls_ind_sector-industrysector          = in_bupa-ind_sector .
        ls_ind_sector-defaultindustrysector   = 'X' .
        CLEAR: ls_ind_sector-ind_sector_text , ls_ind_sector-ind_sector_text_short .
        CALL METHOD lv_ind_sector->if_bol_bo_property_access~set_properties
          EXPORTING
            is_attributes = ls_ind_sector.
      ENDIF .
    ENDIF .
 

  ENDIF.
* Submit child objects created
  lv_bol_core->modify( ).
* Save and commit changes using global transaction context
  DATA: lv_transaction TYPE REF TO if_bol_transaction_context.
  lv_transaction = lv_bol_core->get_transaction( ).
  lv_transaction->save( ).
  lv_transaction->commit( ).

* 1) Use the message container manager
  DATA: lv_mcm TYPE REF TO cl_crm_genil_mess_cont_manager.
  lv_mcm = lv_bol_core->get_message_cont_manager( ).
* 2) ... to obtain the message container
  DATA: lv_object_name TYPE crmt_ext_obj_name,
        lv_object_id TYPE crmt_genil_object_id.
  lv_object_name = lv_root->get_name( ).
  lv_object_id = lv_root->get_key( ).
  DATA: lv_mc TYPE REF TO if_genil_message_container.
  lv_mc = lv_mcm->get_message_cont( iv_object_name = lv_object_name
                                    iv_object_id = lv_object_id ).
* 3) Access messages
  DATA: lv_number_of_errors TYPE int4,
  lt_error_messages TYPE crmt_genil_message_tab.
  lv_number_of_errors = lv_mc->get_number_of_messages( lv_mc->mt_error ).
  IF lv_number_of_errors <> 0.
    CALL METHOD lv_mc->get_messages
      EXPORTING
        iv_message_type = lv_mc->mt_error
        iv_for_display  = abap_false
      IMPORTING
        et_messages     = lt_error_messages.
    le_message = 'E' .
    le_error = lt_error_messages.
  ELSE .
    le_message = 'S' .
  ENDIF.
 
 
阅读(3438) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~