Create Crm Activity

Embed Size (px)

DESCRIPTION

Create Crm Activity

Citation preview

FUNCTION zcss001_create_crm_activity.*"----------------------------------------------------------------------*"*"Local Interface:*" IMPORTING*" VALUE(X_PARTNER) TYPE BU_PARTNER*" VALUE(X_CONT_ACCT) TYPE CRMT_BUAG_ID*" VALUE(X_DESCRIPTION) TYPE CHAR40 OPTIONAL*" VALUE(X_REASON) TYPE CHAR2 OPTIONAL*" VALUE(X_GOAL) TYPE CRMT_OBJECTIVE OPTIONAL*" VALUE(X_BOD_MODE) TYPE CHAR1 OPTIONAL*" VALUE(X_FLEX_BILL) TYPE CHAR1 OPTIONAL*" VALUE(X_SDA) TYPE CHAR1 OPTIONAL*" VALUE(X_SDA_PROCESS) TYPE CRMT_PROCESS_TYPE_DB OPTIONAL*" EXPORTING*" VALUE(Y_CONTACT_ID) TYPE CHAR10*" TABLES*" XT_TEXT_LINES STRUCTURE TLINE OPTIONAL*"----------------------------------------------------------------------*======================================================================** Name.......... ZCSS001_CREATE_CRM_ACTIVITY* Reference.....*======================================================================** OVERVIEW* This RFC Enables function module is written for the purpose of the AGL* Online Self Service project for creation of CRM Contacts when the customer* does certain activities online with regard to his/her AGL Accout**======================================================================*** CHANGE HISTORY** Date Name Reference Description**======================================================================*** CHANGE HISTORY** Date Name Reference Description* 29/09/2010 Mishan L N/A Initial implementation* 31/05/2013 Chandan Gupta INC000000263100 Create Contact Notes separately for Flexible Billing* 15/07/2013 Shiney John SDA Defect Create Contact note for SDA*======================================================================**Tables declarations DATA: lt_orderadm_h TYPE crmt_orderadm_h_comt, lt_activity_h TYPE crmt_activity_h_comt, lt_customer_h TYPE crmt_customer_h_comt, lt_status TYPE crmt_status_comt, lt_partner TYPE crmt_partner_comt, lt_object_to_save TYPE crmt_object_guid_tab, lt_saved_objects TYPE crmt_return_objects, lt_field_names TYPE crmt_input_field_names_tab, lt_input_fields TYPE crmt_input_field_tab, lt_document_flow TYPE TABLE OF bapibus20001_doc_flow_ins, lt_partner_new LIKE bapibus20001_partner_ins OCCURS 0, lt_status_bapi TYPE TABLE OF bapibus20001_status_ins, lt_service_os TYPE crmt_srv_osset_comt, lt_osset TYPE crmt_srv_osset_comt1, lt_subject TYPE crmt_srv_subject_comt, lt_codes TYPE TABLE OF com_code_f4, lt_header TYPE TABLE OF bapibus20001_header_upd, lt_return8 LIKE bapiret2 OCCURS 0, lt_inputfields LIKE bapibus20001_input_fields OCCURS 0. DATA: lt_text TYPE crmt_text_comt, lt_lines TYPE comt_text_lines_t, lt_doc_link TYPE crmt_doc_flow_extdt, lt_maint_doc_flow TYPE crmt_doc_flow_comt.*Structure Declaration DATA: ls_orderadm_h LIKE LINE OF lt_orderadm_h , ls_activity_h LIKE LINE OF lt_activity_h, ls_customer_h LIKE LINE OF lt_customer_h , ls_status LIKE LINE OF lt_status, ls_activity LIKE LINE OF gt_activity, ls_saved_objects LIKE LINE OF lt_saved_objects, ls_partner LIKE LINE OF lt_partner, ls_input_fields LIKE LINE OF lt_input_fields, ls_field_names LIKE LINE OF lt_field_names, ls_partner_new LIKE LINE OF lt_partner_new, lst_document_flow LIKE LINE OF lt_document_flow, lst_header LIKE LINE OF lt_header, lst_inputfields LIKE bapibus20001_input_fields, ls_return8 LIKE LINE OF lt_return8, ls_text TYPE crmt_text_com, ls_lines TYPE tline, ls_status_bapi TYPE bapibus20001_status_ins, ls_text_lines TYPE tline, ls_service_os TYPE crmt_srv_osset_com, ls_osset TYPE crmt_srv_osset_com1, ls_subject TYPE crmt_srv_subject_com, ls_codes TYPE com_code_f4, ls_doc_link LIKE LINE OF lt_doc_link, ls_maint_doc_flow TYPE crmt_doc_flow_com,* Variable Declaration. lv_guid TYPE crmt_object_guid, lv_partner TYPE bu_partner, lv_subject_prof TYPE crmt_subject_profile, lv_buag_id TYPE crmt_buag_id, lv_buag_guid TYPE crmt_buag_guid. DATA: lv_process_type TYPE crmt_process_type_db,* >>> Start of insertion by Chandan Gupta for INC000000263100 on 31/05/2013 >>> lv_activity_category TYPE crmt_activity_category.* >>> End of insertion by Chandan Gupta for INC000000263100 on 31/05/2013 >>>*Constant declarations CONSTANTS: lc_direction_out(1) TYPE c VALUE '1', lc_direction_in(1) TYPE c VALUE '0', lc_wait TYPE bapita-wait VALUE 'X', lc_activity_categ(3) TYPE c VALUE 'URL',* >>> Start of insertion by Chandan Gupta for INC000000263100 on 31/05/2013 >>> lc_internal_activity TYPE crmt_activity_category VALUE 'Z05',* >>> End of insertion by Chandan Gupta for INC000000263100 on 31/05/2013 >>> lc_proces_type TYPE crmt_object_name VALUE 'PROCESS_TYPE', lc_description TYPE crmt_object_name VALUE 'DESCRIPTION', lc_direction TYPE crmt_object_name VALUE 'DIRECTION', lc_category TYPE crmt_object_name VALUE 'CATEGORY', lc_objective TYPE crmt_object_name VALUE 'OBJECTIVE', lc_priority TYPE crmt_object_name VALUE 'PRIORITY', lc_campaign_id TYPE crmt_object_name VALUE 'ZZCUSTOMER_H0201', lc_orderadm_h TYPE crmt_object_name VALUE 'ORDERADM_H', lc_customer_h TYPE crmt_object_name VALUE 'CUSTOMER_H', lc_text TYPE crmt_object_name VALUE 'TEXTS', lc_service_os TYPE crmt_object_name VALUE 'SERVICE_OS', lc_lines TYPE crmt_object_name VALUE 'LINES', lc_z_icamp TYPE crm_j_stsma VALUE 'Z_CMP01', lc_z_act TYPE crm_j_stsma VALUE 'Z_CONACT', lc_activity_h TYPE crmt_object_name VALUE 'ACTIVITY_H', lc_partner TYPE crmt_object_name VALUE 'PARTNER', lc_status TYPE crmt_object_name VALUE 'STATUS', lc_activate TYPE crmt_object_name VALUE 'ACTIVATE', lc_a TYPE crmt_brel_kind VALUE 'A', lc_open(5) TYPE c VALUE 'E0001', lc_closed(5) TYPE c VALUE 'E0006', lc_code TYPE crmt_object_name VALUE 'CODE ', lc_codegruppe TYPE crmt_object_name VALUE 'CODEGRUPPE', lc_defectclass TYPE crmt_object_name VALUE 'DEFECTCLASS', lc_defquantity TYPE crmt_object_name VALUE 'DEFQUANTITY', lc_katalogart TYPE crmt_object_name VALUE 'KATALOGART', lc_listcode TYPE crmt_object_name VALUE 'LISTCODE', lc_quality TYPE crmt_object_name VALUE 'QUALITY'. lv_process_type = 'Z029'.* >>> Start of insertion by Chandan Gupta for INC000000263100 on 31/05/2013 >>> lv_activity_category = lc_activity_categ.* >>> End of insertion by Chandan Gupta for INC000000263100 on 31/05/2013 >>> IF x_bod_mode EQ 'A' OR x_bod_mode EQ 'E'. lv_process_type = 'Z029'. ELSEIF x_bod_mode EQ 'B' OR x_bod_mode EQ 'S'. lv_process_type = 'Z143'.* >>> Start of insertion by Chandan Gupta for INC000000263100 on 31/05/2013 >>> lv_activity_category = lc_internal_activity.* >>> End of insertion by Chandan Gupta for INC000000263100 on 31/05/2013 >>> ELSEIF x_flex_bill = 'C' OR x_flex_bill = 'U' OR x_flex_bill = 'T'. lv_process_type = 'Z141'.* >>> Start of insertion by Chandan Gupta for INC000000263100 on 31/05/2013 >>> lv_activity_category = lc_internal_activity.* >>> End of insertion by Chandan Gupta for INC000000263100 on 31/05/2013 >>> ENDIF.*Begin for SDA Changee - SJ - 15/7/2013 IF x_sda IS NOT INITIAL. lv_process_type = x_sda_process. lv_activity_category = lc_internal_activity. ENDIF.*End for SDA Changee - SJ - 15/7/2013* Get a activity guid. CALL FUNCTION 'CRM_GUID_CREATE' IMPORTING ev_guid = ls_activity_h-ref_guid. INSERT ls_activity_h-ref_guid INTO TABLE lt_object_to_save. lv_guid = ls_activity_h-ref_guid.* Make the Partner Number compatible to the Activity CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = x_partner IMPORTING output = lv_partner.* Set activity 'category','direction' 'Priority' in activity table ls_activity_h-ref_guid = lv_guid.* >>> Start of replacement by Chandan Gupta for INC000000263100 on 31/05/2013 >>>* ls_activity_h-category = lc_activity_categ. ls_activity_h-category = lv_activity_category.* >>> End of replacement by Chandan Gupta for INC000000263100 on 31/05/2013 >>> ls_activity_h-direction = lc_direction_in. ls_activity_h-priority = '5'. ls_activity_h-objective = x_goal. INSERT ls_activity_h INTO TABLE lt_activity_h.* Fill the Input field Names for the activity table CLEAR ls_field_names. ls_field_names-fieldname = lc_category. INSERT ls_field_names INTO TABLE lt_field_names. CLEAR ls_field_names. ls_field_names-fieldname = lc_priority . INSERT ls_field_names INTO TABLE lt_field_names. CLEAR ls_field_names. ls_field_names-fieldname = lc_direction. INSERT ls_field_names INTO TABLE lt_field_names. CLEAR ls_field_names. ls_field_names-fieldname = lc_objective. INSERT ls_field_names INTO TABLE lt_field_names.* Fill the Input fields for the Activity Table ls_input_fields-ref_guid = lv_guid. ls_input_fields-ref_kind = lc_a. ls_input_fields-objectname = lc_activity_h. ls_input_fields-field_names = lt_field_names[]. INSERT ls_input_fields INTO TABLE lt_input_fields.* Set partner no. in partner table ls_partner-ref_guid = lv_guid . ls_partner-ref_kind = lc_a. ls_partner-ref_handle = '0001'. ls_partner-partner_fct = '00000009'. ls_partner-partner_no = lv_partner. ls_partner-no_type = 'BP'. ls_partner-display_type = 'BP'. ls_partner-mainpartner = 'X'. APPEND ls_partner TO lt_partner.* Fill the Input field Names for the partner table CLEAR ls_field_names. REFRESH lt_field_names. ls_field_names-fieldname = 'PARTNER_FCT'. INSERT ls_field_names INTO TABLE lt_field_names. CLEAR ls_field_names. ls_field_names-fieldname = 'PARTNER_NO'. INSERT ls_field_names INTO TABLE lt_field_names. CLEAR ls_field_names. ls_field_names-fieldname = 'NO_TYPE'. INSERT ls_field_names INTO TABLE lt_field_names. CLEAR ls_field_names. ls_field_names-fieldname = 'DISPLAY_TYPE'. INSERT ls_field_names INTO TABLE lt_field_names.*777777 CLEAR ls_field_names. ls_field_names-fieldname = 'KIND_OF_ENTRY'. INSERT ls_field_names INTO TABLE lt_field_names.* Fill the Input fields for the Partner Table ls_input_fields-ref_guid = lv_guid. ls_input_fields-ref_kind = lc_a. ls_input_fields-logical_key = '0001'. ls_input_fields-objectname = lc_partner. ls_input_fields-field_names = lt_field_names[]. INSERT ls_input_fields INTO TABLE lt_input_fields.* Set the User Status to 'Closed' ls_status-ref_guid = ls_activity_h-ref_guid. ls_status-ref_kind = lc_a. ls_status-activate = 'X'. ls_status-status = lc_closed. ls_status-user_stat_proc = lc_z_act. APPEND ls_status TO lt_status.* Fill the Input field Names for the Status table CLEAR ls_field_names. REFRESH lt_field_names. ls_field_names-fieldname = lc_activate . INSERT ls_field_names INTO TABLE lt_field_names.* Fill the Input fields for the Status Table ls_input_fields-ref_guid = ls_activity_h-ref_guid. ls_input_fields-ref_kind = lc_a. CONCATENATE lc_closed lc_z_act INTO ls_input_fields-logical_key.* ls_input_fields-logical_key = 'E0006Z_CONACT'. ls_input_fields-objectname = lc_status. ls_input_fields-field_names = lt_field_names[]. INSERT ls_input_fields INTO TABLE lt_input_fields.* Fill the ORDERADM_H fields ls_orderadm_h-guid = ls_activity_h-ref_guid. ls_orderadm_h-mode = lc_a.* ls_orderadm_h-process_type = 'Z010'. ls_orderadm_h-process_type = lv_process_type . "'Z029'.* ls_orderadm_h-process_type = 'Y111'. ls_orderadm_h-description = x_description. APPEND ls_orderadm_h TO lt_orderadm_h.* Fill the Input field Names for the orderadm_h table CLEAR ls_field_names. REFRESH lt_field_names. ls_field_names-fieldname = lc_proces_type . INSERT ls_field_names INTO TABLE lt_field_names.* Fill the Input field Names for the orderadm_h table CLEAR ls_field_names. ls_field_names-fieldname = lc_description . INSERT ls_field_names INTO TABLE lt_field_names.* Fill the Input fields for the orderadm_h Table ls_input_fields-ref_guid = ls_activity_h-ref_guid. ls_input_fields-ref_kind = lc_a. ls_input_fields-objectname = lc_orderadm_h. ls_input_fields-field_names = lt_field_names[]. INSERT ls_input_fields INTO TABLE lt_input_fields.* Fill the Input fields for the orderadm_h Table ls_input_fields-ref_guid = ls_activity_h-ref_guid. ls_input_fields-ref_kind = lc_a. ls_input_fields-objectname = lc_text. ls_input_fields-field_names = lt_field_names[]. INSERT ls_input_fields INTO TABLE lt_input_fields.*