Hi
How we can update customer_h table using the CRMV_EVENT Where i implemented logic below in the Funtion Module.
data: lt_doc_flow TYPE crmt_doc_flow_wrkt,
lw_cust_h_com TYPE crmt_customer_h_com,
lw_input_field_names TYPE crmt_input_field_names,
lt_input_field_names TYPE crmt_input_field_names_tab,
lt_objects_to_save TYPE crmt_object_guid_tab,
lw_guid TYPE CRMT_OBJECT_GUID.
DATA : lv_process_type TYPE crmt_process_type.
data: wa_doc_flow type CRMT_DOC_FLOW_WRK.
data: wa_customer_h type crmd_customer_h.
* Function module for retriving the Process type.
CALL FUNCTION 'CRM_ORDERADM_H_READ_OW'
EXPORTING
iv_orderadm_h_guid = iv_header_guid
IMPORTING
ev_process_type = lv_process_type
EXCEPTIONS
admin_header_not_found = 1
OTHERS = 2.
if lv_process_type eq 'ZG01'.
CALL FUNCTION 'CRM_DOC_FLOW_READ_OB'
EXPORTING
IV_HEADER_GUID = iv_header_guid
IMPORTING
ET_DOC_FLOW_WRK = lt_doc_flow.
read table lt_doc_flow with key objtype_a = 'BUS2000116' INTO wa_doc_flow. "gc_object_type-service.
if sy-subrc eq 0. "set flag for service order
lw_cust_h_com-ref_guid = wa_doc_flow-objkey_a.
lw_cust_h_com-ZZTRAIL_FLAG = 'X'.
lw_cust_h_com-mode = 'A'.
lw_cust_h_com-ref_handle = '0000000001'.
lw_guid = wa_doc_flow-objkey_a.
INSERT lw_guid INTO TABLE lt_objects_to_save.
endif.
lw_input_field_names-fieldname = 'REF_GUID'.
lw_input_field_names-fieldname = 'ZZTRAIL_FLAG'.
lw_input_field_names-changeable = ' '.
INSERT lw_input_field_names INTO TABLE lt_input_field_names.
Maintain Customer H
CALL FUNCTION 'CRM_CUSTOMER_H_MAINTAIN_OW'
EXPORTING
is_customer_h_com = lw_cust_h_com
CHANGING
ct_input_field_names = lt_input_field_names
EXCEPTIONS
header_change_error = 1
header_create_error = 2
error_occurred = 3.
ENDIF.
*endif.
*Clearing local variables
clear: lv_process_type,
lw_cust_h_com,
lw_input_field_names.
*Free internal tables
free: lt_doc_flow,
lt_input_field_names.