Use BAdI to link appointment to a given opportunity during creation
Requirement
This requirement is raised by customer. They have extended a new field “Opportunity id” in My Appointment creation page. During appointment creation, customer choose an opportunity from this extension field via value help, and they would like to automatically generate a document history which links the created appointment with this manually chosen opportunity.
Implementation
create one BAdI implementation on spot CRM_APPT_ODATA_ENH with following source code:
METHOD if_ex_crm_appt_odata~update_appointment_details.INCLUDE: crm_object_names_con,crm_object_types_con,crm_object_kinds_con,crm_mode_con.DATA: ls_doc_flow TYPE crmt_doc_flow_com,lt_doc_flow LIKE ct_doc_flow,ls_doc_link TYPE crmt_doc_flow_extd,ls_appointment LIKE LINE OF ct_appointment,lt_exception TYPE crmt_exception_t,lt_input_fields TYPE crmt_input_field_tab,ls_input LIKE LINE OF ct_input_fields,ls_field LIKE LINE OF ls_input-field_names.IF sy-uname = 'WANGJER'.READ TABLE ct_appointment INTO ls_appointment INDEX 1.ASSERT sy-subrc = 0.ls_doc_flow-ref_handle = ls_appointment-ref_handle.ls_doc_flow-ref_kind = 'A'.ls_doc_link-objkey_a = '0050569F4AEA1ED4BFF22CF79358C400'.ls_doc_link-handle_b = ls_appointment-ref_handle.ls_doc_link-brel_kind = 'A'.ls_doc_link-brel_mode = 'A'.ls_doc_link-reltype = 'VONA'.APPEND ls_doc_link TO ls_doc_flow-doc_link.INSERT ls_doc_flow INTO TABLE lt_doc_flow.CLEAR: ls_input-field_names.ls_field = 'OBJKEY_A'.INSERT ls_field INTO TABLE ls_input-field_names.ls_field-fieldname = 'OBJTYPE_A'.INSERT ls_field INTO TABLE ls_input-field_names.ls_field-fieldname = 'OBJKEY_B'.INSERT ls_field INTO TABLE ls_input-field_names.ls_field-fieldname = 'OBJTYPE_B'.INSERT ls_field INTO TABLE ls_input-field_names.ls_field-fieldname = 'BREL_KIND'.INSERT ls_field INTO TABLE ls_input-field_names.ls_field-fieldname = 'RELTYPE'.INSERT ls_field INTO TABLE ls_input-field_names.ls_input-ref_handle = ls_appointment-ref_handle.ls_input-ref_kind = 'A'.ls_input-objectname = gc_object_name-doc_flow.INSERT ls_input INTO TABLE lt_input_fields.CALL FUNCTION 'CRM_ORDER_MAINTAIN'IMPORTINGet_exception = lt_exceptionCHANGINGct_input_fields = lt_input_fieldsct_doc_flow = lt_doc_flowct_orderadm_h = ct_orderadm_hEXCEPTIONSerror_occurred = 1document_locked = 2no_change_allowed = 3no_authority = 4.ENDIF.ENDMETHOD.Archievement
Appointment 成功創(chuàng)建之后,代碼里hard code的opportunity guid對應(yīng)的opportunity就會出現(xiàn)在Appointment的Transaction History area里:
要獲取更多Jerry的原創(chuàng)文章,請關(guān)注公眾號"汪子熙":
總結(jié)
以上是生活随笔為你收集整理的Use BAdI to link appointment to a given opportunity during creation的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Shell中find中的atime、ct
- 下一篇: My appointment应用点了Ed