*&---------------------------------------------------------------------* *& Report ZZCUSTCREATE *&---------------------------------------------------------------------* *& Test program to create a customer *&---------------------------------------------------------------------* report zzcustcreate. data: lt_data type cvis_ei_extern_t, lt_return type bapiretm, ls_return type bapireti, ls_retmsg type line of bapiretct, lv_text type string. data: wa_data like line of lt_data, wa_role type bus_ei_bupa_roles, wa_relation type burs_ei_extern, wa_paadr type bus_ei_bupa_address, wa_company type cmds_ei_company. data: lv_guid type guid_32, lv_pguid like but000-partner_guid, lv_partner like wa_data-partner-header-object_instance-bpartner. start-of-selection. lv_partner = '0017100152'. select single partner_guid from but000 into lv_pguid where partner = lv_partner. if sy-subrc = 0. lv_guid = lv_pguid. else. call method cl_system_uuid=>if_system_uuid_static~create_uuid_c32 receiving uuid = lv_guid. endif. * Create customer wa_data-partner-header-object_task = 'M'. wa_data-partner-header-object_instance-bpartner = lv_partner. "Because BP03 is externally numbered wa_data-partner-header-object_instance-bpartnerguid = lv_guid. *--- Partner / Central data / common -------------------------------- wa_data-partner-central_data-common-data-bp_control-category = '2'. "Organization wa_data-partner-central_data-common-data-bp_control-grouping = 'BP03'. "Grouping wa_data-partner-central_data-common-data-bp_centraldata-searchterm1 = 'MARKLANGENHOVEN'. wa_data-partner-central_data-common-data-bp_organization-name1 = 'Marks LLC'. wa_data-partner-central_data-common-data-bp_group-namegroup1 = 'MARKLLC'. wa_data-partner-central_data-common-datax-bp_centraldata-searchterm1 = abap_true. wa_data-partner-central_data-common-datax-bp_organization-name1 = abap_true. wa_data-partner-central_data-common-datax-bp_group-namegroup1 = abap_true. *--- Partner / Central data / Address ------------------------------- wa_paadr-task = 'M'. wa_paadr-data_key-operation = 'XXDFLT'. wa_paadr-data-postal-data-city = 'Beverly Hills'. wa_paadr-data-postal-data-postl_cod1 = '90210'. wa_paadr-data-postal-data-street = '1234 Main St'. wa_paadr-data-postal-data-country = 'US'. wa_paadr-data-postal-data-region = 'CA'. wa_paadr-data-postal-data-langu = 'E'. wa_paadr-data-postal-datax-city = abap_true. wa_paadr-data-postal-datax-postl_cod1 = abap_true. wa_paadr-data-postal-datax-street = abap_true. wa_paadr-data-postal-datax-country = abap_true. wa_paadr-data-postal-datax-region = abap_true. wa_paadr-data-postal-datax-langu = abap_true. wa_paadr-currently_valid = abap_true. append wa_paadr to wa_data-partner-central_data-address-addresses. *--- Partner / Central data / role ---------------------------------- wa_role-task = 'M'. "Modify wa_role-data_key = 'FLCU01'. "Role key - customer wa_role-data-rolecategory = 'FLCU01'. wa_role-data-valid_from = sy-datum. wa_role-data-valid_to = '99991231'. wa_role-currently_valid = abap_true. wa_role-datax-valid_from = abap_true. wa_role-datax-valid_to = abap_true. append wa_role to wa_data-partner-central_data-role-roles. wa_data-partner-central_data-role-current_state = abap_true. *--- Partner relation / header --------------------------------- wa_relation-header-object_instance-partner1-identificationcategory = 'FLCU01'. append wa_relation to wa_data-partner_relation. wa_relation-header-object_task = 'I'. *--- Customer / Company data ------------------------------------ wa_company-task = 'M'. "Modify wa_company-data_key = '1710'. " company code wa_company-data-zterm = '0002'. " terms of payment wa_company-datax-zterm = 'X'. append wa_company to wa_data-customer-company_data-company. *--- Customer / Header -------------------------------------------- wa_data-customer-header-object_task = 'I'. wa_data-customer-header-object_instance = lv_partner. *--- Customer / Central data ------------------------------------- wa_data-customer-central_data-address-task = 'M'. "Modify wa_data-customer-central_data-address-postal-data-from_date = sy-datum. wa_data-customer-central_data-address-postal-data-to_date = '99991231'. wa_data-customer-central_data-address-postal-data-name = 'Mark Langenhoven'. wa_data-ensure_create-create_customer = abap_true. "Finally fill the main data structure append wa_data to lt_data. call function 'CVI_EI_INBOUND_MAIN' exporting i_data = lt_data importing e_return = lt_return. call function 'BAPI_TRANSACTION_COMMIT'. loop at lt_return into ls_return. loop at ls_return-object_msg into ls_retmsg. message id ls_retmsg-id type 'S' number ls_retmsg-number into lv_text with ls_retmsg-message_v1 ls_retmsg-message_v2 ls_retmsg-message_v3 ls_retmsg-message_v4. write: / ' ', ls_retmsg-type, ls_retmsg-id, ls_retmsg-number, / '>>', lv_text. endloop. endloop. write: / 'Done'.
Thursday, May 12, 2016
Creating a customer in HANA 1511
Creating a customer in HANA 1511 isn't as easy as it used to be. There's a new function, CVI_EI_INBOUND_MAIN, that is used to create all Business Partners. This has to be fed a lot of information before it will create a new customer. The code below will create a bare-bones customer with a single address.
Subscribe to:
Post Comments (Atom)
Thanks for the post !!
ReplyDeleteThanks for your help. I am able to successfully create BP customers via function module CVI_EI_INBOUND_MAIN. However it doesn't create the corresponding KNA1 customer record.
ReplyDeleteAny thoughts?
Have you filled the customer data on wa_data-customer? Ensure create customer field as well?
DeleteDo you have the post processing active? Check tcode mds_ppo2 for errors.
i am try fill tables knb1 and knvv but it don't rule, Have you any idea?
ReplyDeleteI fill the sales_data and the customer_company but only have row in but000 and kna1.
thanks!
Hi Vareto,
ReplyDeleteI am facing the same issue. were you able to fill sales and company data?
Thanks,
Ajeeth
How can I make this FM work with an Internal Number Range? What would I have to enter in the BP number and GUID places?
ReplyDelete