Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to change Customer Sales Block (AUFSD) using CVI_EI_INBOUND_MAIN

juan_suros
Contributor
0 Kudos

I am trying to change the Customer Sales Block field (AUFSD) of an existing customer using the recommended function module CVI_EI_INBOUND_MAIN (See OSS note 2650140). My system is S/4 HANA 1909.

Running the code below, I get no validation nor processing errors and no update happens. The last system error is as follows:

E125(R11): "Business partner 1004199 has not been assigned to any role"

I tried entering a role as commented out below and see no validation nor processing errors and no update happens. The last system error in this case is as follows:

E248(R1): "The local memory does not contain any data for business partner 1004199"

Can anyone advise me on use of this Function Module. Did I miss a key field or something?

  DATA:
    lv_partner  TYPE bu_partner,
    lv_block    TYPE aufsd_v,
    lt_return   TYPE bapiretm,
    lt_validate TYPE mdg_bs_bp_msgmap_t,
    lt_data     TYPE cvis_ei_extern_t,
    ls_data     TYPE cvis_ei_extern,
    lv_guid     TYPE bu_partner_guid,
    lv_vkorg    TYPE knvv-vkorg,
    lv_vtweg    TYPE knvv-vtweg,
    lv_spart    TYPE knvv-spart.

* Make update data structure
  ls_data = VALUE cvis_ei_extern(
    partner  = VALUE #( header = VALUE #( object_instance = VALUE #( bpartner = lv_partner 
bpartnerguid = lv_guid )
                                          object_task     = 'U' ) "Update
*                        central_data = VALUE #( role = VALUE #( current_state = abap_true
*                                                                roles         = VALUE #( ( task     = ' ' data_key = 'Z00101' ) ) "Sold-to
*                                               ) ) "CENTRAL_DATA
                      ) "PARTER
    customer = VALUE #( header = VALUE #( object_instance-kunnr = existing_partner object_task = 'U' ) "Change
                        sales_data   = VALUE #( current_state = 'X' "Yes
                                                sales         = VALUE #( (  task = 'U' "Change
                                                                            data_key = VALUE #( vkorg = lv_vkorg vtweg = lv_vtweg spart = lv_spart )
                                                                            data  = VALUE #( aufsd  = lv_block )
                                                                            datax = VALUE #( aufsd  = abap_true )
                                                                        ) ) "SALES
                                               ) "SALES_DATA
                       ) "CUSTOMER
    ensure_create = VALUE #( create_customer = abap_false )
  ).
  APPEND ls_data TO lt_data.


* Send data thru validation checks
  CALL METHOD cl_md_bp_maintain=>validate_single
  EXPORTING
    i_data = ls_data
  IMPORTING
    et_return_map = lt_validate.


* Attempt Customer Master update
  CALL FUNCTION 'CVI_EI_INBOUND_MAIN'
    EXPORTING
      i_data   = lt_data
    IMPORTING
      e_return = lt_return.

COMMIT WORK AND WAIT.<br>
1 REPLY 1

former_member189962
Active Participant
0 Kudos

Hi Juan,

You want to create a Business Partner in a Customer role but also setting the flag - ensure_create as 'false'.

This would mean that the Customer is not created, only the Business Partner is created.

Now you want to UPDATE the customer (by setting the object task as 'U' which is not there in the system hence the system issues an error - 'Business partner 1004199 has not been assigned to any role'

Do not set the flag ensure_create. You can leave it blank and create the Business Partner in the customer role.

Additionally, the recommended way is to use CL_MD_BP_MAINTAIN=>MAINTAIN to create/update the master data (technically, it is not different from the FM - CVI_EI_INBOUND_MAINTAIN)

Regards,

Ankush