Skip to Content

  CALL FUNCTION ‘GUID_CREATE’
     IMPORTING
       ev_guid_16 = lv_guid.

   lr_headerguid  = lv_guid.
   lr_headerprocess_type = process_type.“类型
   lr_headerobject_id = object_id.
   lr_headerdescr_language  = sylangu.
   lr_headerlangu_iso = sylangu.
   lr_headerdescription = description.“description
*日程
   IF process_type EQ ‘ZSC1’.
     lr_headercategory = ‘Z01’.
*交互日志日报
   ELSEIF process_type EQ ‘ZRB1’ OR process_type EQ  ‘ZRB2’.
     lr_headercategory = ‘201’.“客户拜访
*预约
   ELSE.
     lr_headercategory = ‘301’.
   ENDIF.
   lr_headerpriority = priority.
   lr_headerposting_date = sydatum.
   lr_headermode = ‘A’.
   lr_headerdirection = 0.

   APPEND lr_header TO lt_header.

   lr_headerxguid  = ‘X’.
   lr_headerxprocess_type = ‘X’.“类型
   lr_headerxobject_id = ‘X’.
   lr_headerxdescr_language = ‘X’.
   lr_headerxlangu_iso = ‘X’.
   lr_headerxdescription = ‘X’.“description
   lr_headerxcategory = ‘X’.
   lr_headerxpriority = ‘X’.
   lr_headerxposting_date = ‘X’ .
   lr_headerxmode = ‘A’.
   lr_headerxdirection = 0.

   APPEND lr_headerx TO lt_headerx.

*status
*—————————————————————–
   lr_statusxref_guid = ‘X’.
   lr_statusxref_kind = ‘X’.
   lr_statusxstatus = ‘X’.
   lr_statusxactivate = ‘X’.
   APPEND lr_statusx TO lt_statusx.

   lr_statusref_guid = lv_guid.
   lr_statusref_kind = ‘A’.
   lr_statusstatus = act_status.            “状态
   lr_statusactivate = ‘X’.
   APPEND lr_status TO lt_status.

*TIME
*—————————————————————–
   “时间戳转换
   CONVERT DATE date_from TIME time_from
   INTO TIME STAMP timestamp_from
   TIME ZONE zcl_common_object=>timezone.

   CONVERT DATE date_to TIME time_to
   INTO TIME STAMP timestamp_to
   TIME ZONE zcl_common_object=>timezone.

   lw_datexref_guid = ‘X’.
   lw_datexref_kind = ‘X’.
   lw_datexappt_type = ‘X’.
   lw_datexmode = ‘X’.
   lw_datextimestamp_from = ‘X’.
   lw_datextimestamp_to = ‘X’.
   lw_datextimezone_from = ‘X’.
   lw_datextimezone_to = ‘X’.
   APPEND lw_datex TO lt_datex.

   lw_dateref_guid = lv_guid.
   lw_dateref_kind = ‘A’.
   IF process_type EQ ‘ZRB1’ OR process_type EQ ‘ZRB2’.
     lw_dateappt_type = ‘ORDERPLANNED’.
   ELSE.
     lw_dateappt_type = ‘ORDERACTUAL’.
   ENDIF.
   lw_datemode = ‘A’.
   lw_datetimestamp_from = timestamp_from.
   lw_datetimestamp_to = timestamp_to.
   lw_datetimezone_from = zcl_common_object=>timezone.
   lw_datetimezone_to = zcl_common_object=>timezone.
   APPEND lw_date TO lt_date.

*note
*————————————————————————-
   IF gt_text IS NOT INITIAL.

     lr_textxref_guid = ‘X’.
     lr_textxref_kind = ‘X’.
     lr_textxtdid = ‘X’.
     lr_textxtdspras = ‘X’.
     lr_textxlangu_iso = ‘X’.
     lr_textxtdline = ‘X’.
     lr_textxtdstyle = ‘X’.
     lr_textxtdform = ‘X’.
     lr_textxtdformat = ‘X’.
     lr_textxmode = ‘X’.
     APPEND lr_textx TO lt_textx.

     lt_text_app = gt_text.

     LOOP AT lt_text_app INTO lw_text_app.
       lr_textref_guid = lv_guid.
       lr_textref_kind = ‘A’.
       lr_texttdid = lw_text_appident.      “文本类型
       lr_texttdspras = lw_text_applangu.   “语言
       lr_textlangu_iso = lw_text_applangu. “语言
       lr_texttdline = lw_text_applines.    “文本内容
       lr_texttdstyle = ‘SYSTEM’.
       lr_texttdform = ‘SYSTEM’.
       lr_texttdformat = ‘*’.
       lr_textmode = ‘A’.
       APPEND lr_text TO lt_text.
       CLEAR lr_text.
     ENDLOOP.
   ENDIF.

*change history
*———————————————————————-
   IF gt_history[] IS NOT INITIAL.

     DATA:objtype_b TYPE swo_objtyp.
     DATA:objkey_a TYPE crmt_object_guid.

     SELECT SINGLE object_type
     INTO objtype_b
     FROM crmd_orderadm_h
     WHERE process_type = process_type.

     lt_history = gt_history.

     LOOP AT lt_history[] INTO lw_history.
       SELECT SINGLE object_type
       INTO lw_document_flowobjtype_a
       FROM crmd_orderadm_h
       WHERE process_type = lw_historyobject_type.

       SELECT SINGLE guid
       INTO objkey_a
       FROM crmd_orderadm_h
       WHERE process_type = lw_historyobject_type
         AND object_id = lw_historyobject_id.

       IF objkey_a IS NOT INITIAL.
         lw_document_flowobjkey_a = objkey_a.
         lw_document_flowobjtype_b = objtype_b.
         lw_document_flowobjkey_b = lv_guid.
         lw_document_flowref_guid = lv_guid.
         lw_document_flowreltype = ‘VONA’.
         lw_document_flowbrel_kind = ‘A’.
         lw_document_flowref_kind = ‘A’.
       ENDIF.
       APPEND lw_document_flow TO lt_document_flow.
       CLEAR lw_document_flow.
     ENDLOOP.
   ENDIF.

*相关方
*——————————————————————
   IF gt_partner IS NOT INITIAL.
     lt_partner_app = gt_partner.

     LOOP AT lt_partner_app INTO lw_partner_app.
       lr_partnerxref_guid = ‘X’.
       lr_partnerxref_kind = ‘X’.
       lr_partnerxpartner_no = ‘X’.
       lr_partnerxno_type = ‘X’.
       lr_partnerxdisplay_type = ‘X’.
       lr_partnerxpartner_fct = ‘X’.
       lr_partnerxkind_of_entry = ‘X’.
       APPEND lr_partnerx TO lt_partnerx.
       CLEAR lr_partnerx.

       lr_partnerref_guid = lv_guid.
       lr_partnerref_kind = ‘A’.
       lr_partnerpartner_no = lw_partner_apppartner_no.
       lr_partnerno_type = ‘BP’.
       lr_partnerdisplay_type = ‘BP’.
       lr_partnerpartner_fct = lw_partner_apppartner_fct.
       lr_partnerkind_of_entry = ‘A’.
       APPEND lr_partner TO lt_partner.
       CLEAR lr_partner.
     ENDLOOP.
   ENDIF.

*sales group
*——————————————————————
   CLEAR:lr_organisation,lr_organisationx,lt_organisation,lt_organisationx.
   IF gt_salgroup IS NOT INITIAL.
     lr_organisationxref_guid = ‘X’.
     lr_organisationxref_kind = ‘X’.
     lr_organisationxdis_channel = ‘X’.“分销渠道
     lr_organisationxdivision = ‘X’.“部门
     lr_organisationxsales_org = ‘X’.“销售组织
     lr_organisationxsales_office = ‘X’.“销售办事处
     lr_organisationxsales_group = ‘X’.“销售办事处

     APPEND lr_organisationx TO lt_organisationx.

     lr_organisationref_guid = lv_guid.
     lr_organisationref_kind = ‘A’.
     lr_organisationdis_channel = gt_salgroupdis_channel.“分销渠道
     lr_organisationdivision = gt_salgroupdivision.“部门
     lr_organisationsales_org gt_salgroupsales_org_short.“销售组织
     lr_organisationsales_office = gt_salgroupsales_office_short.“销售办事处
     lr_organisationsales_group = gt_salgroupsales_group_short.“销售组
     APPEND lr_organisation TO lt_organisation.

   ENDIF.

   CALL FUNCTION ‘BAPI_BUSPROCESSND_PROCSETTINGS’
     EXPORTING
       process_settings_in = ls_process_settings
     TABLES
       return              = return.

*create actvity
*——————————————————————

   CALL FUNCTION ‘BAPI_ACTIVITYCRM_CREATEMULTI’
     TABLES
       header          = lt_header
       headerx         = lt_headerx
       partner         = lt_partner
       partnerx        = lt_partnerx
       organisation    = lt_organisation
       organisationx   = lt_organisationx
       date            = lt_date
       datex           = lt_datex
       text            = lt_text
       textx           = lt_textx
*     REASON          =
*     REASONX         =
*     OUTCOME         =
*     OUTCOMEX        =
       status          = lt_status
       statusx         = lt_statusx
*     LOCATION        =
*     LOCATIONX       =
       input_fields    = lt_input[]
       created_process = lt_create_process[]
       return          = lt_return[]
       document_flow   = lt_document_flow[]
*     JOURNAL         =
*     JOURNALX        =
*     MATERIAL        =
*     MATERIALX       =
*     EXTENSIONIN     =
     .

   IF sysubrc EQ 0.

     CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
       EXPORTING
         wait = ‘X’
*   IMPORTING
*       RETURN        =
       .

   ENDIF.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply