0% found this document useful (0 votes)
510 views35 pages

CRM - BUPA Creation

The document contains code for a function that creates a business partner record (BP) in SAP based on data from a CRM survey. It retrieves survey response data, maps it to BP fields, and calls SAP APIs to create the BP and related records for addresses, contacts, etc. The summary is: 1. It retrieves survey response data from a CRM survey about a business partner. 2. It maps the survey response values to SAP BP fields like name, address, phone numbers, contacts. 3. It calls SAP APIs to create the BP record along with related records for addresses, contacts using the mapped survey response values.

Uploaded by

andro666
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
510 views35 pages

CRM - BUPA Creation

The document contains code for a function that creates a business partner record (BP) in SAP based on data from a CRM survey. It retrieves survey response data, maps it to BP fields, and calls SAP APIs to create the BP and related records for addresses, contacts, etc. The summary is: 1. It retrieves survey response data from a CRM survey about a business partner. 2. It maps the survey response values to SAP BP fields like name, address, phone numbers, contacts. 3. It calls SAP APIs to create the BP record along with related records for addresses, contacts using the mapped survey response values.

Uploaded by

andro666
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 35

FUNCTION zcrm_bp_create .

*"---------------------------------------------------------------------*"*"Local Interface: *" IMPORTING *" VALUE(BP_GUID) TYPE CRMT_OBJECT_GUID *" EXPORTING *" VALUE(BP_NO) TYPE BU_PARTNER *" TABLES *" LT_ERROR_MESSAGES *" EXCEPTIONS *" NOTHING_FOUND *"---------------------------------------------------------------------DATA: partner_category TYPE bapibus1006_head-partn_cat, partner_role TYPE bapibus1006_bproles-partnerrole, centraldata TYPE bapibus1006_central, zsearchterm1(20) TYPE c, bp_data TYPE bapibus1006_central_organ, bp_data_person LIKE bapibus1006_central_person, bp_contact_data TYPE bapibus1006_central_person, bp_contact_no_1 TYPE bu_partner, bp_contact_no_2 TYPE bu_partner, address_data TYPE bapibus1006_address, address_data_cyrl LIKE addr1_data, bp_contact_address_1 TYPE bapibus1006002_address, bp_contact_address_2 TYPE bapibus1006002_address, bp_contact_no_1_central LIKE bapibus1006002_central, bp_contact_no_2_central LIKE bapibus1006002_central, lt_telephondata TYPE TABLE OF bapiadtel, ls_telephondata TYPE bapiadtel, lt_faxdata TYPE TABLE OF bapiadfax, ls_faxdata TYPE bapiadfax, lt_uri TYPE TABLE OF bapiaduri, ls_uri TYPE bapiaduri, lt_maildata TYPE TABLE OF bapiadsmtp, ls_maildata TYPE bapiadsmtp, bp_addressdata LIKE bapibus1006_address, bp_addressdata_x LIKE bapibus1006_address_x, lt_communicationnotes LIKE TABLE OF bapicomrem, ls_communicationnotes LIKE bapicomrem, lt_communicationnotesaddress LIKE TABLE OF bapicomrem, ls_communicationnotesaddress LIKE bapicomrem, bp_addressdata_change LIKE bapibus1006_address, lt_return TYPE TABLE OF bapiret2, lt_return_cyrl TYPE TABLE OF bapiret2, lt_return_contact_1 TYPE TABLE OF bapiret2, lt_return_contact_2 TYPE TABLE OF bapiret2, lt_return_realtionship_1 TYPE TABLE OF bapiret2, lt_return_realtionship_2 TYPE TABLE OF bapiret2, lt_return_realtionship_3 TYPE TABLE OF bapiret2, lt_return_tax TYPE TABLE OF bapiret2, lt_return_address TYPE TABLE OF bapiret2, lt_error_table TYPE TABLE OF addr_error, partner_grp TYPE bapibus1006_head-partn_grp, title_key TYPE ad_title, title(2) TYPE c, bpdisti TYPE bapibus1006_head-bpartner, lt_return1 TYPE TABLE OF bapiret2, lt_mobile TYPE TABLE OF adtel, ls_mobile TYPE adtel,

reltype TYPE bapibus1006_relations-relationshipcategory. DATA: lo_survey_texts TYPE REF TO cl_crm_svy_survey_texts, lt_survey_wrk_latest_version TYPE crmt_survey_wrkt, survey TYPE crmt_survey_wrk. DATA: lt_all_values ls_all_values lt_texts TYPE ls_texts TYPE TYPE survy_t_all_values, TYPE survy_s_all_values, crm_svy_api_survey_text_t, crm_svy_api_survey_text.

DATA: ls_longtext TYPE bus_ei_longtext, lt_return_text TYPE TABLE OF bapiret2, zls_longtext TYPE bus_ei_bupa_longtext, zline TYPE tline. FIELD-SYMBOLS: <lf_survey_wrk_latest_version> TYPE crmt_survey_wrk, <lf_texts> TYPE crm_svy_api_survey_text, <lf_return> TYPE bapiret2, <addr_error> TYPE addr_error.

****************************************************************** * BERI PODATKE Z ANKETE ****************************************************************** CALL FUNCTION 'CRM_SURVEY_READ_OW' EXPORTING iv_guid = iv_kind = IMPORTING et_survey_wrk_latest_version = EXCEPTIONS parameter_error = record_not_found = at_least_one_record_not_found = OTHERS =

bp_guid 'A' lt_survey_wrk_latest_version 1 2 3 4.

LOOP AT lt_survey_wrk_latest_version ASSIGNING <lf_survey_wrk_latest_version>. MOVE-CORRESPONDING <lf_survey_wrk_latest_version> TO survey. ENDLOOP. CREATE OBJECT lo_survey_texts EXPORTING i_survey_id = survey-surveyid i_survey_version = survey-surveyversion i_language = sy-langu i_valueguid = survey-valueguid i_valueversion = survey-valueversion. CALL METHOD lo_survey_texts->get_all_values IMPORTING e_all_values = lt_all_values. CALL METHOD lo_survey_texts->get_all_texts IMPORTING et_texts = lt_texts.

" zberi odgovore o partnerju CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_name'. DATA bp_name TYPE string. bp_name = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_street'. DATA bp_street TYPE string. bp_street = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_street_no '. DATA bp_street_no TYPE string. bp_street_no = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_postalcod e'. DATA bp_postalcode TYPE string. bp_postalcode = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_city'. DATA bp_city TYPE string. bp_city = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_country'. DATA bp_country TYPE string. bp_country = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_language' . DATA bp_language TYPE string. bp_language = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_phone'. DATA bp_phone TYPE string. bp_phone = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_phone_ext '. DATA bp_phone_ext TYPE string. bp_phone_ext = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_phone_mob '. DATA bp_phone_mob TYPE string. bp_phone_mob = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_phone_mob _ext'. DATA bp_phone_mob_ext TYPE string.

bp_phone_mob_ext = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_fax'. DATA bp_fax TYPE string. bp_fax = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_fax_ext'. DATA bp_fax_ext TYPE string. bp_fax_ext = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_email'. DATA bp_email TYPE string. bp_email = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_url'. DATA bp_url TYPE string. bp_url = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_date_foun ded'. DATA bp_date_founded TYPE string. bp_date_founded = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_name_cyrl '. DATA bp_name_cyrl TYPE string. bp_name_cyrl = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_street_cy rl'. DATA bp_street_cyrl TYPE string. bp_street_cyrl = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_street_no _cyr'. DATA bp_street_no_cyrl TYPE string. bp_street_no_cyrl = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_city_cyrl '. DATA bp_city_cyrl TYPE string. bp_city_cyrl = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_salesman' . DATA bp_salesman TYPE string. bp_salesman = ls_all_values-value. " zberi odgovore o kontaktni osebi (1) CLEAR ls_all_values.

READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_t itle_1'. DATA bp_contact_title_1 TYPE string. bp_contact_title_1 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_n ame_1'. DATA bp_contact_name_1 TYPE string. bp_contact_name_1 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_f irst_name_1'. DATA bp_contact_first_name_1 TYPE string. bp_contact_first_name_1 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_f unction_1'. DATA bp_contact_function_1 TYPE string. bp_contact_function_1 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_d epartment_1'. DATA bp_contact_department_1 TYPE string. bp_contact_department_1 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_p hone_1'. DATA bp_contact_phone_1 TYPE string. bp_contact_phone_1 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_p hone_ext_1'. DATA bp_contact_phone_ext_1 TYPE string. bp_contact_phone_ext_1 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_f ax_1'. DATA bp_contact_fax_1 TYPE string. bp_contact_fax_1 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_f ax_ext_1'. DATA bp_contact_fax_ext_1 TYPE string. bp_contact_fax_ext_1 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_e mail_1'. DATA bp_contact_email_1 TYPE string. bp_contact_email_1 = ls_all_values-value. " zberi odgovore o kontaktni osebi (2)

CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_t itle_2'. DATA bp_contact_title_2 TYPE string. bp_contact_title_2 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_n ame_2'. DATA bp_contact_name_2 TYPE string. bp_contact_name_2 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_f irst_name_2'. DATA bp_contact_first_name_2 TYPE string. bp_contact_first_name_2 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_f unction_2'. DATA bp_contact_function_2 TYPE string. bp_contact_function_2 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_d epartment_2'. DATA bp_contact_department_2 TYPE string. bp_contact_department_2 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_p hone_2'. DATA bp_contact_phone_2 TYPE string. bp_contact_phone_2 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_p hone_ext_2'. DATA bp_contact_phone_ext_2 TYPE string. bp_contact_phone_ext_2 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_f ax_2'. DATA bp_contact_fax_2 TYPE string. bp_contact_fax_2 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_f ax_ext_2'. DATA bp_contact_fax_ext_2 TYPE string. bp_contact_fax_ext_2 = ls_all_values-value. CLEAR ls_all_values. READ TABLE lt_all_values INTO ls_all_values WITH KEY answer_id = 'bp_contact_e mail_2'. DATA bp_contact_email_2 TYPE string. bp_contact_email_2 = ls_all_values-value.

" zberi odgovore o 'Primary business' CLEAR ls_texts. DATA bp_primary_business TYPE TABLE OF string. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_primary_business' type = 'Answer' text ='Service provider' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Service provider' TO bp_primary_business. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_primary_business' type = 'Answer' text ='Reseller' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Reseller' TO bp_primary_business. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_primary_business' type = 'Answer' text ='Equipment manufacturer' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Equipment manufacturer' TO bp_primary_business. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_primary_business' type = 'Answer' text ='Goverment' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Goverment' TO bp_primary_business. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_primary_business' type = 'Answer' text ='Educational institut' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Educational institut' TO bp_primary_business. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_primary_business' type = 'Answer' text ='System integrator' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'System integrator' TO bp_primary_business. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_primary_business' type = 'Answer'

text ='Designer' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Designer' TO bp_primary_business. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_primary_business' type = 'Answer' text ='Other' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Other' TO bp_primary_business. ENDIF.

" zberi odgovore o 'Job function' CLEAR ls_texts. DATA bp_job_function TYPE TABLE OF string. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_job_function' type = 'Answer' text ='Corporate management' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Corporate management' TO bp_job_function. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_job_function' type = 'Answer' text ='Investment/finance' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Investment/finance' TO bp_job_function. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_job_function' type = 'Answer' text ='Information system' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Information system' TO bp_job_function. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_job_function' type = 'Answer' text ='Planning/analyst' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Planning/analyst' TO bp_job_function. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_job_function' type = 'Answer' text ='Engineering'

selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Engineering' TO bp_job_function. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_job_function' type = 'Answer' text ='R&D/product management' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'R&D/product management' TO bp_job_function. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_job_function' type = 'Answer' text ='Purchase/corporate buyer' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Purchase/corporate buyer' TO bp_job_function. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_job_function' type = 'Answer' text ='Sales/marketing' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Sales/marketing' TO bp_job_function. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_job_function' type = 'Answer' text ='Other' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Other' TO bp_job_function. ENDIF. " zberi odgovore o 'Position on market' CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_position_on_market' type = 'Answer'. DATA bp_position_on_market TYPE string. bp_position_on_market = ls_texts-text. " zberi odgovore o 'Strategical directions' CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_strategic_direction s' type = 'Answer'. DATA bp_strategic_directions TYPE string. bp_strategic_directions = ls_texts-text. " zberi odgovore o 'Product' CLEAR ls_texts.

DATA bp_product TYPE TABLE OF string. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_product' type = 'Answer' text ='Network access' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Network access' TO bp_product. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_product' type = 'Answer' text ='Network control' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Network control' TO bp_product. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_product' type = 'Answer' text ='Network management' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Network management' TO bp_product. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_product' type = 'Answer' text ='Transport networks' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'Transport networks' TO bp_product. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_product' type = 'Answer' text ='VAS, services' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'VAS, services' TO bp_product. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_product' type = 'Answer' text ='CPE' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'CPE' TO bp_product. ENDIF. " zberi odgovore o 'SI3000 Product' CLEAR ls_texts. DATA bp_si3000_product TYPE TABLE OF string.

READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_si3000_product' type = 'Answer' text ='SI3000 CS' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'SI3000 CS' TO bp_si3000_product. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_si3000_product' type = 'Answer' text ='SI3000 iCS' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'SI3000 iCS' TO bp_si3000_product. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_si3000_product' type = 'Answer' text ='SI3000 SMG' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'SI3000 SMG' TO bp_si3000_product. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_si3000_product' type = 'Answer' text ='SI3000 AS' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'SI3000 AS' TO bp_si3000_product. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_si3000_product' type = 'Answer' text ='SI3000 MSAN' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'SI3000 MSAN' TO bp_si3000_product. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_si3000_product' type = 'Answer' text ='SI3000 Fiber Access' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'SI3000 Fiber Access' TO bp_si3000_product. ENDIF. CLEAR ls_texts. READ TABLE lt_texts INTO ls_texts WITH KEY answer_id = 'bp_si3000_product' type = 'Answer' text ='SI3000 DSL Access' selected = 'X'. IF ls_texts IS NOT INITIAL. APPEND 'SI3000 DSL Access' TO bp_si3000_product.

ENDIF. " zberi odgovore o 'Technology' DATA bp_technology TYPE TABLE OF string. LOOP AT lt_texts ASSIGNING <lf_texts> WHERE answer_id = 'bp_technology' AND type = 'Answer' AND selected = 'X'. CLEAR ls_texts. MOVE-CORRESPONDING <lf_texts> TO ls_texts. APPEND ls_texts-text TO bp_technology. ENDLOOP. " zberi odgovore o 'Solution' DATA bp_solution TYPE TABLE OF string. LOOP AT lt_texts ASSIGNING <lf_texts> WHERE answer_id = 'bp_solution' AND type = 'Answer' AND selected = 'X'. CLEAR ls_texts. MOVE-CORRESPONDING <lf_texts> TO ls_texts. APPEND ls_texts-text TO bp_solution. ENDLOOP. " zberi odgovore o 'First contact with Iskratel' DATA bp_first_contact TYPE TABLE OF string. LOOP AT lt_texts ASSIGNING <lf_texts> WHERE answer_id = 'bp_first_contact' AND type = 'Answer' AND selected = 'X'. CLEAR ls_texts. MOVE-CORRESPONDING <lf_texts> TO ls_texts. APPEND ls_texts-text TO bp_first_contact. ENDLOOP. " zberi odgovore o 'To be contacted' DATA bp_to_be_contacted TYPE TABLE OF string. LOOP AT lt_texts ASSIGNING <lf_texts> WHERE answer_id = 'bp_to_be_contacted' AND type = 'Answer' AND selected = 'X'. CLEAR ls_texts. MOVE-CORRESPONDING <lf_texts> TO ls_texts. APPEND ls_texts-text TO bp_to_be_contacted. ENDLOOP. " zberi odgovore o 'To be contacted' DATA bp_newsletter TYPE TABLE OF string. DATA bp_newsletter_x TYPE string. LOOP AT lt_texts ASSIGNING <lf_texts> WHERE answer_id = 'bp_newsletter' AND type = 'Answer' AND selected = 'X'. CLEAR ls_texts.

bp_newsletter_x = <lf_texts>-text. ENDLOOP.

****************************************************************** * CONSISTENSY DATA CHECK FOR NEW CUSTOMER ****************************************************************** DATA: error_check TYPE i. error_check = 0. " check bp name IF bp_name IS INITIAL. APPEND 'NAME of business partner is not defined.' TO lt_error_messages. error_check = 1. ENDIF. " check bp country DATA: bp_country_iso TYPE land1. SELECT SINGLE land1 FROM t005t INTO bp_country_iso WHERE spras = 'E' AND landx 50 = bp_country. IF bp_country_iso IS INITIAL. APPEND 'COUNTRY of business partner is not defined.' TO lt_error_messages. error_check = 1. ENDIF. " check bp postal code IF bp_postalcode IS NOT INITIAL AND bp_country_iso IS NOT INITIAL. CLEAR lt_return. DATA lv_postal_code TYPE ad_pstcd1. lv_postal_code = bp_postalcode. CALL FUNCTION 'CRM_ICSS_CHECK_POSTAL_CODE' EXPORTING iv_postal_code = lv_postal_code iv_country = bp_country_iso TABLES et_return = lt_return. IF lt_return IS NOT INITIAL. LOOP AT lt_return ASSIGNING <lf_return> WHERE type = 'E'. APPEND <lf_return>-message TO lt_error_messages. ENDLOOP. error_check = 1. ENDIF. ELSE. DATA: lv_postal_digits TYPE t005-lnplz. SELECT SINGLE lnplz FROM t005 INTO lv_postal_digits WHERE land1 = bp_country _iso. CASE lv_postal_digits. WHEN 0. bp_postalcode = '0'. WHEN 1. bp_postalcode = '0'. WHEN 2. bp_postalcode = '00'. WHEN 3.

bp_postalcode WHEN 4. bp_postalcode WHEN 5. bp_postalcode WHEN 6. bp_postalcode WHEN 7. bp_postalcode WHEN 8. bp_postalcode WHEN 9. bp_postalcode ENDCASE. ENDIF. " EXIT PROCEDURE IF error_check = 1. EXIT. ENDIF.

= '000'. = '0000'. = '00000'. = '000000'. = '0000000'. = '00000000'. = '000000000'.

****************************************************************** * CREATE CUSTOMER ****************************************************************** partner_category = '2'. "Organization partner_grp = 'ZIN2'. partner_role = 'BUP002'. " zamanjaj dvojne narekovaje v nazivu z enojnimi zaradi web klienta "REPLACE ALL OCCURRENCES OF '"' IN bp_name WITH ''. bp_data-name1 = bp_name. IF bp_date_founded IS NOT INITIAL. DATA bp_date_founded_convered TYPE datum. " kontrola, e je datum e konvertiran v pravi format CALL FUNCTION 'RP_CHECK_DATE' EXPORTING date = bp_date_founded EXCEPTIONS date_invalid = 1 OTHERS = 2. IF sy-subrc <> 0. CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL' EXPORTING date_external = bp_date_founded IMPORTING date_internal = bp_date_founded_convered. bp_data-foundationdate = bp_date_founded_convered. ELSE. bp_data-foundationdate = bp_date_founded. ENDIF. ENDIF. zsearchterm1 = bp_name. centraldata-searchterm1 = zsearchterm1. " adress IF bp_country_iso IS NOT INITIAL.

address_data-standardaddress = 'X'. address_data-street = bp_street. address_data-house_no = bp_street_no. address_data-postl_cod1 = bp_postalcode. address_data-city = bp_city. address_data-country = bp_country_iso. address_data-countryiso = bp_country_iso. address_data-langu = 'EN'. address_data-languiso = 'EN'. ENDIF. " adress (Cyrilic) IF bp_name_cyrl IS NOT INITIAL. "REPLACE ALL OCCURRENCES OF '"' IN bp_name_cyrl WITH ''. address_data_cyrl-name1 = bp_name_cyrl. address_data_cyrl-sort1 = bp_name_cyrl. address_data_cyrl-street = bp_street_cyrl. address_data_cyrl-house_num1 = bp_street_no_cyrl. address_data_cyrl-post_code1 = bp_postalcode. address_data_cyrl-city1 = bp_city_cyrl. address_data_cyrl-country = bp_country_iso. ENDIF. " fix telephone IF bp_phone IS NOT INITIAL. ls_telephondata-country = bp_country_iso. ls_telephondata-extension = bp_phone_ext. ls_telephondata-telephone = bp_phone. ls_telephondata-std_no = 'X'. ls_telephondata-r_3_user = '1'. ls_telephondata-home_flag = 'X'. APPEND ls_telephondata TO lt_telephondata. ENDIF. " mobile telephone IF bp_phone_mob IS NOT INITIAL. CLEAR ls_telephondata. ls_telephondata-country = bp_country_iso. ls_telephondata-extension = bp_phone_mob_ext. ls_telephondata-telephone = bp_phone_mob. ls_telephondata-std_no = 'X'. ls_telephondata-r_3_user = '3'. ls_telephondata-home_flag = 'X'. APPEND ls_telephondata TO lt_telephondata. ENDIF. " fax IF bp_fax IS NOT INITIAL. ls_faxdata-country = bp_country_iso. ls_faxdata-extension = bp_fax_ext. ls_faxdata-fax = bp_fax. APPEND ls_faxdata TO lt_faxdata. ENDIF. " e-mail IF bp_email IS NOT INITIAL. ls_maildata-e_mail = bp_email. ls_maildata-std_no = 'X'. APPEND ls_maildata TO lt_maildata. ENDIF.

" URL IF bp_url IS NOT INITIAL. ls_uri-uri_type = 'HPG'. ls_uri-uri = bp_url. APPEND ls_uri TO lt_uri. ENDIF. " communication data ls_communicationnotes-comm_type = 'TEL'. ls_communicationnotes-langu = 'E'. APPEND ls_communicationnotes TO lt_communicationnotes. APPEND ls_communicationnotes TO lt_communicationnotesaddress. "bp_data_person-correspondlanguage = 'E'. CALL FUNCTION 'BAPI_BUPA_CREATE_FROM_DATA' EXPORTING partnercategory = partner_category partnergroup = partner_grp centraldata = centraldata centraldataorganization = bp_data " centraldataperson = bp_data_person addressdata = address_data accept_error = 'X' IMPORTING businesspartner = bp_no TABLES telefondata = lt_telephondata faxdata = lt_faxdata e_maildata = lt_maildata uriaddressdata = lt_uri " communicationnotes = lt_communicationnotes " communicationnotesnonaddress = lt_communicationnotesaddress return = lt_return. "napolnim errorje IF lt_return IS NOT INITIAL. LOOP AT lt_return ASSIGNING <lf_return> WHERE type = 'E'. APPEND <lf_return>-message TO lt_error_messages. ENDLOOP. ENDIF. " add business role CALL FUNCTION 'BAPI_BUPA_ROLE_ADD_2' EXPORTING businesspartner = bp_no businesspartnerrole = partner_role. " add account group classification DATA: bp_account_group LIKE bapibus1006040_salesclass. bp_account_group-is_prospect = 'X'. bp_account_group-account_group = 'ZIN2'. CALL FUNCTION 'BAPI_BUPA_FRG0040_CREATE' EXPORTING businesspartner = bp_no data = bp_account_group

TABLES return

= lt_return.

" add address DATA: bp_addressguid LIKE but020-guid, bp_addr LIKE bapibus1006_head-addr_no, bp_addr_guid LIKE but020-guid. CALL FUNCTION 'BAPI_BUPA_ADDRESS_GET_NUMBERS' EXPORTING businesspartner = bp_no IMPORTING addr_no_out = bp_addr addressguidout = bp_addr_guid TABLES return = lt_return. " international address CALL FUNCTION 'ADDR_VERSION_INSERT' EXPORTING address_data = address_data_cyrl address_number = bp_addr nation = 'R' TABLES error_table = lt_error_table EXCEPTIONS address_not_exist = 1 parameter_error = 2 version_exists = 3 internal_error = 4 OTHERS = 5. " define language for address (because SAP shits) bp_addressdata_change-langu = 'EN'. bp_addressdata_x-langu = 'X'. * CALL FUNCTION 'BAPI_BUPA_ADDRESS_CHANGE' * EXPORTING * businesspartner = bp_no * addressguid = bp_addr_guid * addressdata = bp_addressdata_change * addressdata_x = bp_addressdata_x * IMPORTING * error_table = lt_return_address. * UPDATE adrc SET langu = 'EN' WHERE addrnumber = bp_addr. "napolnim errorje IF lt_error_table IS NOT INITIAL. LOOP AT lt_error_table ASSIGNING <addr_error> WHERE msg_type = 'E'. APPEND <addr_error>-msg_var1 TO lt_error_messages. ENDLOOP. ENDIF. **************************************************************** * ADD TAX CLASSIFICATION ****************************************************************

DATA: bp_taxtype LIKE bapibus1006tax-taxtype, bp_taxnumber LIKE bapibus1006tax-taxnumber. IF bp_country_iso = 'SI'. CALL FUNCTION 'BAPI_BUTX_FRG0010_ADD' EXPORTING businesspartner = bp_no taxcountry = 'SI' taxregion = '' taxtype = 'ZDDV' data = '1' TABLES return = lt_return_tax. ELSEIF bp_country_iso = 'RU'. CALL FUNCTION 'BAPI_BUTX_FRG0010_ADD' EXPORTING businesspartner = bp_no taxcountry = 'SI' taxregion = '' taxtype = 'ZDDV' data = '0' TABLES return = lt_return_tax. CALL FUNCTION 'BAPI_BUTX_FRG0010_ADD' EXPORTING businesspartner = bp_no taxcountry = 'RU' taxregion = '' taxtype = 'ZDDV' data = '0' TABLES return = lt_return_tax. ELSEIF bp_country_iso = 'UA'. CALL FUNCTION 'BAPI_BUTX_FRG0010_ADD' EXPORTING businesspartner = bp_no taxcountry = 'SI' taxregion = '' taxtype = 'ZDDV' data = '0' TABLES return = lt_return_tax. CALL FUNCTION 'BAPI_BUTX_FRG0010_ADD' EXPORTING businesspartner = bp_no taxcountry = 'UA' taxregion = '' taxtype = 'ZDDV' data = '0' TABLES return = lt_return_tax. ELSE. CALL FUNCTION 'BAPI_BUTX_FRG0010_ADD' EXPORTING businesspartner = bp_no

taxcountry taxregion taxtype data TABLES return ENDIF.

= = = =

'SI' '' 'ZDDV' '0'

= lt_return_tax.

* " add taxnumber * CALL FUNCTION 'BAPI_BUPA_TAX_ADD' * EXPORTING * businesspartner = bp_no * taxtype = bp_taxtype * taxnumber = bp_taxnumber * TABLES * return = lt_return_tax. "napolnim errorje IF lt_return_tax IS NOT INITIAL. LOOP AT lt_return_tax ASSIGNING <lf_return> WHERE type = 'E'. APPEND <lf_return>-message TO lt_error_messages. ENDLOOP. ENDIF. **************************************************************** * ADD TEXTS **************************************************************** ls_longtext-current_state = 'I'. * Text 'Position on market' IF bp_position_on_market IS NOT INITIAL. zls_longtext-task = 'I'. zls_longtext-data_key-text_id = 'Z002'. zls_longtext-data_key-langu = 'EN'. " " Subtable TEXT_LINES - wrap text for display " DATA: lv_textline(1500) TYPE c, " lv_out_lines(45) TYPE c, " lt_out_lines LIKE TABLE OF lv_out_lines. " FIELD-SYMBOLS: <lf_out_lines> LIKE lv_out_lines. " lv_textline = " CALL FUNCTION " EXPORTING " textline " delimiter " outputlen " TABLES " out_lines bp_position_on_market. 'Z_WORD_WRAP' = lv_textline = ' ' = 130 = lt_out_lines.

" LOOP AT lt_out_lines ASSIGNING <lf_out_lines>. " zline-tdline = <lf_out_lines>. " APPEND zline TO zls_longtext-data-lines. " ENDLOOP. " s_text-lines = t_text_lines. " APPEND s_text TO t_text.

zline-tdline = bp_position_on_market. APPEND zline TO zls_longtext-data-lines. " zline = bp_position_on_market. " APPEND zline TO zls_longtext-data-lines. APPEND zls_longtext TO ls_longtext-longtexts. ENDIF. * Text 'Strategic directions' IF bp_strategic_directions IS NOT INITIAL. CLEAR zls_longtext. zls_longtext-task = 'I'. zls_longtext-data_key-text_id = 'Z003'. zls_longtext-data_key-langu = 'EN'. CLEAR: zline, zls_longtext-data-lines[]. zline-tdline = bp_strategic_directions. APPEND zline TO zls_longtext-data-lines. APPEND zls_longtext TO ls_longtext-longtexts. ENDIF. IF ls_longtext IS NOT INITIAL. CALL FUNCTION 'BUPA_EXECUTE_LONGTEXT' EXPORTING iv_partner = bp_no is_longtext = ls_longtext iv_object_task = 'BUT000' TABLES et_return = lt_return_text. ENDIF. "napolnim errorje IF lt_return_text IS NOT INITIAL. LOOP AT lt_return_text ASSIGNING <lf_return> WHERE type = 'E'. APPEND <lf_return>-message TO lt_error_messages. ENDLOOP. ENDIF. DATA: lt_return_commit LIKE bapiret2. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X' IMPORTING return = lt_return_commit. **************************************************************** * ADD MARKETING ATTRIBUTES **************************************************************** TYPES: BEGIN OF zcrm_mkt_attr, class LIKE klah-class, imerk LIKE ksml-imerk, indc TYPE c, atfor TYPE atfor, END OF zcrm_mkt_attr. DATA: lv_mkt_att_atinn LIKE cabn-atinn,

lv_mkt_att_atnam LIKE cabn-atnam, lv_mkt_att_atfor LIKE cabn-atfor, lv_mkt_att_atzhl LIKE cawn-atzhl, lv_mkt_att_atwrt LIKE cawn-atwrt, ls_marketing_attribute LIKE crmt_mktpfchr_attribute_line, lt_marketing_attribute LIKE TABLE OF crmt_mktpfchr_attribute_line, lt_marketing_attribute_2 LIKE TABLE OF crmt_mktpfchr_attribute_line, lt_marketing_attribute_3 LIKE TABLE OF crmt_mktpfchr_attribute_line. DATA: lt_partner_mkt TYPE crmt_mktbp_partner_tab OCCURS 0, ls_partner_mkt LIKE LINE OF lt_partner_mkt, lt_return_mkt LIKE bapiret2 OCCURS 0, lt_return_mkt_2 LIKE bapiret2 OCCURS 0, lt_return_mkt_3 LIKE bapiret2 OCCURS 0. FIELD-SYMBOLS: <lf_bp_primary_business> LIKE LINE OF bp_primary_business, <lf_bp_job_function> TYPE string, <lf_bp_first_contact> TYPE string, <lf_bp_product> TYPE string, <lf_bp_si3000_product> TYPE string, <lf_bp_technology> TYPE string, <lf_bp_solution> TYPE string, <lf_bp_newsletter> TYPE string, <lf_bp_to_be_contacted> TYPE string. " partner reference ls_partner_mkt-partner = bp_no. SELECT SINGLE partner_guid FROM but000 INTO ls_partner_mkt-partner_guid WHERE partner = bp_no. APPEND ls_partner_mkt TO lt_partner_mkt. * Primary business IF bp_primary_business IS NOT INITIAL. " Convert Marketing Attribute Name to SAP format CLEAR: lv_mkt_att_atinn, lv_mkt_att_atnam, lv_mkt_att_atfor. SELECT SINGLE atinn FROM cabnt INTO lv_mkt_att_atinn WHERE atbez = 'Primary business' AND spras = 'E'. SELECT atnam atfor FROM cabn INTO (lv_mkt_att_atnam, lv_mkt_att_atfor) UP TO 1 ROWS WHERE atinn = lv_mkt_att_atinn. ENDSELECT. IF sy-subrc = 0. LOOP AT bp_primary_business ASSIGNING <lf_bp_primary_business>. CLEAR: lv_mkt_att_atzhl, lv_mkt_att_atwrt. SELECT SINGLE atzhl INTO lv_mkt_att_atzhl FROM cawnt WHERE atinn = lv_mkt_att_atinn AND atwtb = <lf_bp_pr imary_business>. SELECT SINGLE atwrt INTO lv_mkt_att_atwrt FROM cawn WHERE atinn = lv_mkt_att_atinn AND atzhl = lv_mkt_at

t_atzhl. IF lv_mkt_att_atwrt IS NOT INITIAL. CLEAR ls_marketing_attribute. ls_marketing_attribute-atname = lv_mkt_att_atnam. "SHIFT lv_mkt_att_atwrt LEFT DELETING LEADING '0'. ls_marketing_attribute-atvalue = lv_mkt_att_atwrt. ls_marketing_attribute-datatype = lv_mkt_att_atfor. APPEND ls_marketing_attribute TO lt_marketing_attribute. ENDIF. ENDLOOP. ENDIF. ENDIF. * Primary job function IF bp_job_function IS NOT INITIAL. " Convert Marketing Attribute Name to SAP format CLEAR: lv_mkt_att_atinn, lv_mkt_att_atnam, lv_mkt_att_atfor. SELECT SINGLE atinn FROM cabnt INTO lv_mkt_att_atinn WHERE atbez = 'Primary job function' AND spras = 'E'. SELECT atnam atfor FROM cabn INTO (lv_mkt_att_atnam, lv_mkt_att_atfor) UP TO 1 ROWS WHERE atinn = lv_mkt_att_atinn. ENDSELECT. IF sy-subrc = 0. LOOP AT bp_job_function ASSIGNING <lf_bp_job_function>. CLEAR: lv_mkt_att_atzhl, lv_mkt_att_atwrt. SELECT SINGLE atzhl INTO lv_mkt_att_atzhl FROM cawnt WHERE atinn = lv_mkt_att_atinn AND atwtb = <lf_bp_jo b_function>. SELECT SINGLE atwrt INTO lv_mkt_att_atwrt FROM cawn WHERE atinn = lv_mkt_att_atinn AND atzhl = lv_mkt_at t_atzhl. IF lv_mkt_att_atwrt IS NOT INITIAL. CLEAR ls_marketing_attribute. ls_marketing_attribute-atname = lv_mkt_att_atnam. "SHIFT lv_mkt_att_atwrt LEFT DELETING LEADING '0'. ls_marketing_attribute-atvalue = lv_mkt_att_atwrt. ls_marketing_attribute-datatype = lv_mkt_att_atfor. APPEND ls_marketing_attribute TO lt_marketing_attribute. ENDIF. ENDLOOP. ENDIF. ENDIF. * First contact with Iskratel IF bp_first_contact IS NOT INITIAL. " Convert Marketing Attribute Name to SAP format CLEAR: lv_mkt_att_atinn, lv_mkt_att_atnam, lv_mkt_att_atfor. SELECT SINGLE atinn FROM cabnt

INTO lv_mkt_att_atinn WHERE atbez = 'First contact with Iskratel' AND spras = 'E'. SELECT atnam atfor FROM cabn INTO (lv_mkt_att_atnam, lv_mkt_att_atfor) UP TO 1 ROWS WHERE atinn = lv_mkt_att_atinn. ENDSELECT. IF sy-subrc = 0. LOOP AT bp_first_contact ASSIGNING <lf_bp_first_contact>. CLEAR: lv_mkt_att_atzhl, lv_mkt_att_atwrt. SELECT SINGLE atzhl INTO lv_mkt_att_atzhl FROM cawnt WHERE atinn = lv_mkt_att_atinn AND atwtb = <lf_bp_fi rst_contact>. SELECT SINGLE atwrt INTO lv_mkt_att_atwrt FROM cawn WHERE atinn = lv_mkt_att_atinn AND atzhl = lv_mkt_at t_atzhl. IF lv_mkt_att_atwrt IS NOT INITIAL. CLEAR ls_marketing_attribute. ls_marketing_attribute-atname = lv_mkt_att_atnam. "SHIFT lv_mkt_att_atwrt LEFT DELETING LEADING '0'. ls_marketing_attribute-atvalue = lv_mkt_att_atwrt. ls_marketing_attribute-datatype = lv_mkt_att_atfor. APPEND ls_marketing_attribute TO lt_marketing_attribute. ENDIF. ENDLOOP. ENDIF. ENDIF. * Inserting the New Marketing Attribute for given Business Partner. IF lt_marketing_attribute[] IS NOT INITIAL. CALL FUNCTION 'CRM_MKTBP_ASSIGN_ATTRIBUT_TAB' EXPORTING iv_attribute_set = '01_BUSINESS_DATA' iv_msa = 'X' iv_commit = 'X' iv_obtyp = 'BUT000' TABLES it_partner = lt_partner_mkt et_return = lt_return_mkt it_attributes = lt_marketing_attribute. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X' IMPORTING return = lt_return_commit. "napolnim errorje IF lt_return_mkt IS NOT INITIAL. LOOP AT lt_return_mkt ASSIGNING <lf_return> WHERE type = 'E'. APPEND <lf_return>-message TO lt_error_messages.

ENDLOOP. ENDIF. ENDIF. *////////////////////////////// * Product IF bp_product IS NOT INITIAL. " Convert Marketing Attribute Name to SAP format CLEAR: lv_mkt_att_atinn, lv_mkt_att_atnam, lv_mkt_att_atfor. SELECT SINGLE atinn FROM cabnt INTO lv_mkt_att_atinn WHERE atbez = 'Product' AND spras = 'E'. SELECT atnam atfor FROM cabn INTO (lv_mkt_att_atnam, lv_mkt_att_atfor) UP TO 1 ROWS WHERE atinn = lv_mkt_att_atinn. ENDSELECT. IF sy-subrc = 0. LOOP AT bp_product ASSIGNING <lf_bp_product>. CLEAR: lv_mkt_att_atzhl, lv_mkt_att_atwrt. SELECT SINGLE atzhl INTO lv_mkt_att_atzhl FROM cawnt WHERE atinn = lv_mkt_att_atinn AND atwtb = <lf_bp_pr oduct>. SELECT SINGLE atwrt INTO lv_mkt_att_atwrt FROM cawn WHERE atinn = lv_mkt_att_atinn AND atzhl = lv_mkt_at t_atzhl. IF lv_mkt_att_atwrt IS NOT INITIAL. CLEAR ls_marketing_attribute. ls_marketing_attribute-atname = lv_mkt_att_atnam. "SHIFT lv_mkt_att_atwrt LEFT DELETING LEADING '0'. ls_marketing_attribute-atvalue = lv_mkt_att_atwrt. ls_marketing_attribute-datatype = lv_mkt_att_atfor. APPEND ls_marketing_attribute TO lt_marketing_attribute_2. ENDIF. ENDLOOP. ENDIF. ENDIF. * SI3000 Product IF bp_si3000_product IS NOT INITIAL. " Convert Marketing Attribute Name to SAP format CLEAR: lv_mkt_att_atinn, lv_mkt_att_atnam, lv_mkt_att_atfor. SELECT SINGLE atinn FROM cabnt INTO lv_mkt_att_atinn WHERE atbez = 'SI3000 Product' AND spras = 'E'. SELECT atnam atfor FROM cabn INTO (lv_mkt_att_atnam, lv_mkt_att_atfor) UP TO 1 ROWS WHERE atinn = lv_mkt_att_atinn. ENDSELECT.

IF sy-subrc = 0. LOOP AT bp_si3000_product ASSIGNING <lf_bp_si3000_product>. CLEAR: lv_mkt_att_atzhl, lv_mkt_att_atwrt. SELECT SINGLE atzhl INTO lv_mkt_att_atzhl FROM cawnt WHERE atinn = lv_mkt_att_atinn AND atwtb = <lf_bp_si 3000_product>. SELECT SINGLE atwrt INTO lv_mkt_att_atwrt FROM cawn WHERE atinn = lv_mkt_att_atinn AND atzhl = lv_mkt_at t_atzhl. IF lv_mkt_att_atwrt IS NOT INITIAL. CLEAR ls_marketing_attribute. ls_marketing_attribute-atname = lv_mkt_att_atnam. "SHIFT lv_mkt_att_atwrt LEFT DELETING LEADING '0'. ls_marketing_attribute-atvalue = lv_mkt_att_atwrt. ls_marketing_attribute-datatype = lv_mkt_att_atfor. APPEND ls_marketing_attribute TO lt_marketing_attribute_2. ENDIF. ENDLOOP. ENDIF. ENDIF. * Technology IF bp_technology IS NOT INITIAL. " Convert Marketing Attribute Name to SAP format CLEAR: lv_mkt_att_atinn, lv_mkt_att_atnam, lv_mkt_att_atfor. SELECT SINGLE atinn FROM cabnt INTO lv_mkt_att_atinn WHERE atbez = 'Technology' AND spras = 'E'. SELECT atnam atfor FROM cabn INTO (lv_mkt_att_atnam, lv_mkt_att_atfor) UP TO 1 ROWS WHERE atinn = lv_mkt_att_atinn. ENDSELECT. IF sy-subrc = 0. LOOP AT bp_technology ASSIGNING <lf_bp_technology>. CLEAR: lv_mkt_att_atzhl, lv_mkt_att_atwrt. SELECT SINGLE atzhl INTO lv_mkt_att_atzhl FROM cawnt WHERE atinn = lv_mkt_att_atinn AND atwtb = <lf_bp_te chnology>. SELECT SINGLE atwrt INTO lv_mkt_att_atwrt FROM cawn WHERE atinn = lv_mkt_att_atinn AND atzhl = lv_mkt_at t_atzhl. IF lv_mkt_att_atwrt IS NOT INITIAL. CLEAR ls_marketing_attribute. ls_marketing_attribute-atname = lv_mkt_att_atnam. "SHIFT lv_mkt_att_atwrt LEFT DELETING LEADING '0'. ls_marketing_attribute-atvalue = lv_mkt_att_atwrt.

ls_marketing_attribute-datatype = lv_mkt_att_atfor. APPEND ls_marketing_attribute TO lt_marketing_attribute_2. ENDIF. ENDLOOP. ENDIF. ENDIF. * Solution IF bp_solution IS NOT INITIAL. " Convert Marketing Attribute Name to SAP format CLEAR: lv_mkt_att_atinn, lv_mkt_att_atnam, lv_mkt_att_atfor. SELECT SINGLE atinn FROM cabnt INTO lv_mkt_att_atinn WHERE atbez = 'Solution' AND spras = 'E'. SELECT atnam atfor FROM cabn INTO (lv_mkt_att_atnam, lv_mkt_att_atfor) UP TO 1 ROWS WHERE atinn = lv_mkt_att_atinn. ENDSELECT. IF sy-subrc = 0. LOOP AT bp_solution ASSIGNING <lf_bp_solution>. CLEAR: lv_mkt_att_atzhl, lv_mkt_att_atwrt. SELECT SINGLE atzhl INTO lv_mkt_att_atzhl FROM cawnt WHERE atinn = lv_mkt_att_atinn AND atwtb = <lf_bp_so lution>. SELECT SINGLE atwrt INTO lv_mkt_att_atwrt FROM cawn WHERE atinn = lv_mkt_att_atinn AND atzhl = lv_mkt_at t_atzhl. IF lv_mkt_att_atwrt IS NOT INITIAL. CLEAR ls_marketing_attribute. ls_marketing_attribute-atname = lv_mkt_att_atnam. "SHIFT lv_mkt_att_atwrt LEFT DELETING LEADING '0'. ls_marketing_attribute-atvalue = lv_mkt_att_atwrt. ls_marketing_attribute-datatype = lv_mkt_att_atfor. APPEND ls_marketing_attribute TO lt_marketing_attribute_2. ENDIF. ENDLOOP. ENDIF. ENDIF. * Inserting the New Marketing Attribute for given Business Partner. IF lt_marketing_attribute_2[] IS NOT INITIAL. CALL FUNCTION 'CRM_MKTBP_ASSIGN_ATTRIBUT_TAB' EXPORTING iv_attribute_set = '02_PRODUCT_INTERST' iv_msa = 'X' iv_commit = 'X' iv_obtyp = 'BUT000' TABLES it_partner = lt_partner_mkt et_return = lt_return_mkt_2 it_attributes = lt_marketing_attribute_2.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X' IMPORTING return = lt_return_commit. "napolnim errorje IF lt_return_mkt_2 IS NOT INITIAL. LOOP AT lt_return_mkt_2 ASSIGNING <lf_return> WHERE type = 'E'. APPEND <lf_return>-message TO lt_error_messages. ENDLOOP. ENDIF. ENDIF. *//////////////////////////////// * Newslatter IF bp_newsletter_x IS NOT INITIAL. " Convert Marketing Attribute Name to SAP format CLEAR: lv_mkt_att_atinn, lv_mkt_att_atnam, lv_mkt_att_atfor. SELECT SINGLE atinn FROM cabnt INTO lv_mkt_att_atinn WHERE atbez = 'Newslatter' AND spras = 'E'. SELECT atnam atfor FROM cabn INTO (lv_mkt_att_atnam, lv_mkt_att_atfor) UP TO 1 ROWS WHERE atinn = lv_mkt_att_atinn. ENDSELECT. IF sy-subrc = 0. CLEAR: lv_mkt_att_atzhl, lv_mkt_att_atwrt. SELECT SINGLE atzhl INTO lv_mkt_att_atzhl FROM cawnt WHERE atinn = lv_mkt_att_atinn AND atwtb = bp_newslett er_x. SELECT SINGLE atwrt INTO lv_mkt_att_atwrt FROM cawn WHERE atinn = lv_mkt_att_atinn AND atzhl = lv_mkt_att_ atzhl. IF lv_mkt_att_atwrt IS NOT INITIAL. CLEAR ls_marketing_attribute. ls_marketing_attribute-atname = lv_mkt_att_atnam. "SHIFT lv_mkt_att_atwrt LEFT DELETING LEADING '0'. ls_marketing_attribute-atvalue = lv_mkt_att_atwrt. ls_marketing_attribute-datatype = lv_mkt_att_atfor. APPEND ls_marketing_attribute TO lt_marketing_attribute_3. ENDIF. ENDIF. ENDIF. * To be contacted IF bp_to_be_contacted IS NOT INITIAL. " Convert Marketing Attribute Name to SAP format CLEAR: lv_mkt_att_atinn, lv_mkt_att_atnam, lv_mkt_att_atfor.

SELECT SINGLE atinn FROM cabnt INTO lv_mkt_att_atinn WHERE atbez = 'To be contacted' AND spras = 'E'. SELECT atnam atfor FROM cabn INTO (lv_mkt_att_atnam, lv_mkt_att_atfor) UP TO 1 ROWS WHERE atinn = lv_mkt_att_atinn. ENDSELECT. IF sy-subrc = 0. LOOP AT bp_to_be_contacted ASSIGNING <lf_bp_to_be_contacted>. CLEAR: lv_mkt_att_atzhl, lv_mkt_att_atwrt. SELECT SINGLE atzhl INTO lv_mkt_att_atzhl FROM cawnt WHERE atinn = lv_mkt_att_atinn AND atwtb = <lf_bp_to _be_contacted>. SELECT SINGLE atwrt INTO lv_mkt_att_atwrt FROM cawn WHERE atinn = lv_mkt_att_atinn AND atzhl = lv_mkt_at t_atzhl. IF lv_mkt_att_atwrt IS NOT INITIAL. CLEAR ls_marketing_attribute. ls_marketing_attribute-atname = lv_mkt_att_atnam. "SHIFT lv_mkt_att_atwrt LEFT DELETING LEADING '0'. ls_marketing_attribute-atvalue = lv_mkt_att_atwrt. ls_marketing_attribute-datatype = lv_mkt_att_atfor. APPEND ls_marketing_attribute TO lt_marketing_attribute_3. ENDIF. ENDLOOP. ENDIF. ENDIF. * Inserting the New Marketing Attribute for given Business Partner. IF lt_marketing_attribute_3[] IS NOT INITIAL. CALL FUNCTION 'CRM_MKTBP_ASSIGN_ATTRIBUT_TAB' EXPORTING iv_attribute_set = '03_COMMUNICATION' iv_msa = 'X' iv_commit = 'X' iv_obtyp = 'BUT000' TABLES it_partner = lt_partner_mkt et_return = lt_return_mkt_3 it_attributes = lt_marketing_attribute_3. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X' IMPORTING return = lt_return_commit. "napolnim errorje IF lt_return_mkt_3 IS NOT INITIAL. LOOP AT lt_return_mkt_3 ASSIGNING <lf_return> WHERE type = 'E'. APPEND <lf_return>-message TO lt_error_messages.

ENDLOOP. ENDIF. ENDIF.

****************************************************************** * CREATE CONTACT PERSON 1 ****************************************************************** IF bp_contact_name_1 IS NOT INITIAL AND bp_contact_first_name_1 IS NOT INITIAL . partner_category = '1'. "Person partner_grp = 'ZCON'. partner_role = 'BUP001'. bp_contact_data-firstname = bp_contact_first_name_1. bp_contact_data-lastname = bp_contact_name_1. bp_contact_data-correspondlanguage = 'EN'. zsearchterm1 = bp_contact_name_1. centraldata-searchterm1 = zsearchterm1. IF bp_contact_title_1 = 'Mr.'. centraldata-title_key = '0001'. ELSE. centraldata-title_key = '0002'. ENDIF. "address IF bp_country_iso IS NOT INITIAL. CLEAR address_data. address_data-country = bp_country_iso. ENDIF. " fix telephone IF bp_contact_phone_1 IS NOT INITIAL. CLEAR: ls_telephondata, lt_telephondata. ls_telephondata-country = bp_country_iso. ls_telephondata-extension = bp_contact_phone_ext_1. ls_telephondata-telephone = bp_contact_phone_1. ls_telephondata-std_no = 'X'. ls_telephondata-r_3_user = '1'. ls_telephondata-home_flag = 'X'. APPEND ls_telephondata TO lt_telephondata. ENDIF. " fax IF bp_contact_fax_1 IS NOT INITIAL. CLEAR: ls_faxdata, lt_faxdata. ls_faxdata-country = bp_country_iso. ls_faxdata-extension = bp_contact_fax_ext_1. ls_faxdata-fax = bp_contact_fax_1. APPEND ls_faxdata TO lt_faxdata. ENDIF. " e-mail IF bp_contact_email_1 IS NOT INITIAL. CLEAR: ls_maildata, lt_maildata.

ls_maildata-e_mail = bp_contact_email_1. ls_maildata-std_no = 'X'. APPEND ls_maildata TO lt_maildata. ENDIF. CALL FUNCTION 'BAPI_BUPA_CREATE_FROM_DATA' EXPORTING partnercategory = partner_category partnergroup = partner_grp centraldata = centraldata centraldataperson = bp_contact_data addressdata = address_data IMPORTING businesspartner = bp_contact_no_1 TABLES telefondata = lt_telephondata faxdata = lt_faxdata e_maildata = lt_maildata uriaddressdata = lt_uri return = lt_return_contact_1. "napolnim errorje IF lt_return_contact_1 IS NOT INITIAL. LOOP AT lt_return_contact_1 ASSIGNING <lf_return> WHERE type = 'E'. APPEND <lf_return>-message TO lt_error_messages. ENDLOOP. ENDIF. CALL FUNCTION 'BAPI_BUPA_ROLE_ADD_2' EXPORTING businesspartner = bp_contact_no_1 businesspartnerrole = partner_role. IF bp_contact_department_1 IS NOT INITIAL OR bp_contact_function_1 IS NOT IN ITIAL. DATA: bp_contact_function_1_no TYPE tb913-pafkt, bp_contact_department_1_no TYPE tb911-abtnr. SELECT SINGLE pafkt FROM tb913 INTO bp_contact_function_1_no WHERE spras = 'E' AND bez30 = bp_contact_function_1. SELECT SINGLE abtnr FROM tb911 INTO bp_contact_department_1_no WHERE spras = 'E' AND bez20 = bp_contact_department_1. bp_contact_address_1-department = bp_contact_department_1_no. bp_contact_address_1-function = bp_contact_function_1_no. CALL FUNCTION 'BAPI_BUPR_CONTP_ADDR_ADD' EXPORTING businesspartner = bp_no contactperson = bp_contact_no_1 addressdata = bp_contact_address_1. ENDIF.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X' IMPORTING return = lt_return_commit. ENDIF.

****************************************************************** * CREATE CONTACT PERSON 2 ****************************************************************** IF bp_contact_name_2 IS NOT INITIAL AND bp_contact_first_name_2 IS NOT INITIAL . partner_category = '1'. "Person partner_grp = 'ZCON'. partner_role = 'BUP001'. bp_contact_data-firstname = bp_contact_first_name_2. bp_contact_data-lastname = bp_contact_name_2. bp_contact_data-correspondlanguage = 'EN'. zsearchterm1 = bp_contact_name_2. centraldata-searchterm1 = zsearchterm1. IF bp_contact_title_2 = 'Mr.'. centraldata-title_key = '0001'. ELSE. centraldata-title_key = '0002'. ENDIF. "address IF bp_country_iso IS NOT INITIAL. CLEAR address_data. address_data-country = bp_country_iso. ENDIF. " fix telephone IF bp_contact_phone_2 IS NOT INITIAL. CLEAR: ls_telephondata, lt_telephondata. ls_telephondata-country = bp_country_iso. ls_telephondata-extension = bp_contact_phone_ext_2. ls_telephondata-telephone = bp_contact_phone_2. ls_telephondata-std_no = 'X'. ls_telephondata-r_3_user = '1'. ls_telephondata-home_flag = 'X'. APPEND ls_telephondata TO lt_telephondata. ENDIF. " fax IF bp_contact_fax_2 IS NOT INITIAL. CLEAR: ls_faxdata, lt_faxdata. ls_faxdata-country = bp_country_iso. ls_faxdata-extension = bp_contact_fax_ext_2. ls_faxdata-fax = bp_contact_fax_2. APPEND ls_faxdata TO lt_faxdata. ENDIF. " e-mail

IF bp_contact_email_2 IS NOT INITIAL. CLEAR: ls_maildata, lt_maildata. ls_maildata-e_mail = bp_contact_email_2. ls_maildata-std_no = 'X'. APPEND ls_maildata TO lt_maildata. ENDIF. CALL FUNCTION 'BAPI_BUPA_CREATE_FROM_DATA' EXPORTING partnercategory = partner_category partnergroup = partner_grp centraldata = centraldata centraldataperson = bp_contact_data addressdata = address_data IMPORTING businesspartner = bp_contact_no_2 TABLES telefondata = lt_telephondata faxdata = lt_faxdata e_maildata = lt_maildata uriaddressdata = lt_uri return = lt_return_contact_2. "napolnim errorje IF lt_return_contact_2 IS NOT INITIAL. LOOP AT lt_return_contact_2 ASSIGNING <lf_return> WHERE type = 'E'. APPEND <lf_return>-message TO lt_error_messages. ENDLOOP. ENDIF. CALL FUNCTION 'BAPI_BUPA_ROLE_ADD_2' EXPORTING businesspartner = bp_contact_no_2 businesspartnerrole = partner_role. IF bp_contact_department_1 IS NOT INITIAL OR bp_contact_function_1 IS NOT IN ITIAL. DATA: bp_contact_function_2_no TYPE tb913-pafkt, bp_contact_department_2_no TYPE tb911-abtnr. SELECT SINGLE pafkt FROM tb913 INTO bp_contact_function_2_no WHERE spras = 'E' AND bez30 = bp_contact_function_2. SELECT SINGLE abtnr FROM tb911 INTO bp_contact_department_2_no WHERE spras = 'E' AND bez20 = bp_contact_department_2. bp_contact_address_2-department = bp_contact_department_2_no. bp_contact_address_2-function = bp_contact_function_2_no. CALL FUNCTION 'BAPI_BUPR_CONTP_ADDR_ADD' EXPORTING businesspartner = bp_no contactperson = bp_contact_no_2 addressdata = bp_contact_address_2.

ENDIF. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X' IMPORTING return = lt_return_commit. ENDIF. ****************************************************************** * LINK PARTNER AND CONTACT PERSON ****************************************************************** IF bp_no IS NOT INITIAL AND bp_contact_no_1 IS NOT INITIAL. * * * * * * * * " create relationship CALL FUNCTION 'BAPI_BUPR_RELATIONSHIP_CREATE' EXPORTING businesspartner1 = bp_no businesspartner2 = bp_contact_no_1 relationshipcategory = 'BUR001' TABLES return = lt_return_realtionship_1. bp_contact_no_1_central-function = bp_contact_function_1_no. bp_contact_no_1_central-department = bp_contact_department_1_no. " create relationship + additional data of relationship CALL FUNCTION 'BAPI_BUPR_CONTP_CREATE' EXPORTING businesspartner = bp_no contactperson = bp_contact_no_1 centraldata = bp_contact_no_1_central TABLES return = lt_return_realtionship_1. "napolnim errorje IF lt_return_realtionship_1 IS NOT INITIAL. LOOP AT lt_return_realtionship_1 ASSIGNING <lf_return> WHERE type = 'E'. APPEND <lf_return>-message TO lt_error_messages. ENDLOOP. ENDIF. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X' IMPORTING return = lt_return_commit. ENDIF. IF bp_no IS NOT INITIAL AND bp_contact_no_2 IS NOT INITIAL. * * * * * " create relationship CALL FUNCTION 'BAPI_BUPR_RELATIONSHIP_CREATE' EXPORTING businesspartner1 = bp_no businesspartner2 = bp_contact_no_2

* * *

relationshipcategory = 'BUR001' TABLES return = lt_return_realtionship_2. bp_contact_no_2_central-function = bp_contact_function_2_no. bp_contact_no_2_central-department = bp_contact_department_2_no. " create relationship + additional data of relationship CALL FUNCTION 'BAPI_BUPR_CONTP_CREATE' EXPORTING businesspartner = bp_no contactperson = bp_contact_no_2 centraldata = bp_contact_no_2_central TABLES return = lt_return_realtionship_2. "napolnim errorje IF lt_return_realtionship_2 IS NOT INITIAL. LOOP AT lt_return_realtionship_2 ASSIGNING <lf_return> WHERE type = 'E'. APPEND <lf_return>-message TO lt_error_messages. ENDLOOP. ENDIF. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X' IMPORTING return = lt_return_commit. ENDIF.

****************************************************************** * LINK PARTNER AND SALESMAN ****************************************************************** IF bp_no IS NOT INITIAL AND bp_salesman IS NOT INITIAL. DATA: bp_salesman_lastname TYPE bu_namep_l, bp_salesman_firstname TYPE bu_namep_f, bp_salesman_no TYPE bu_partner. SPLIT bp_salesman AT space INTO bp_salesman_lastname bp_salesman_firstname. SELECT SINGLE partner FROM but000 INTO bp_salesman_no WHERE name_last = bp_salesman_lastname AND name_first = bp_salesman_firstname. * * * * * * * " create BUR011 relationship CALL FUNCTION 'BAPI_BUPR_RESP_EMPLO_CREATE' EXPORTING businesspartner = bp_no responsible_employee = bp_salesman_no TABLES return = lt_return_realtionship_3. " create BUR011 relationship + dela tudi na web ui employee id CALL FUNCTION 'BAPI_BUPR_RELATIONSHIP_CREATE'

EXPORTING businesspartner1 businesspartner2 relationshipcategory xdfrel TABLES return

= = = =

bp_no bp_salesman_no 'BUR011' 'X'

= lt_return_realtionship_3.

"napolnim errorje IF lt_return_realtionship_3 IS NOT INITIAL. LOOP AT lt_return_realtionship_3 ASSIGNING <lf_return> WHERE type = 'E'. APPEND <lf_return>-message TO lt_error_messages. ENDLOOP. ENDIF. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X' IMPORTING return = lt_return_commit. ENDIF. ENDFUNCTION. CRM_MKTBP_CHANGE_BP

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy