cancel
Showing results for 
Search instead for 
Did you mean: 

Business Partner Creation S4/HANA with external ID

EnnoWulff
Active Contributor
4,733

Hey there!

I am creating a business Partner using method cl_md_bp_maintain=>validate_single and cl_md_bp_maintain=>maintain.

This code works:

  DATA is_address  TYPE bapiaddr1.
  DATA is_noc_partner_data  TYPE bapiparnr.
  DATA rv_bu_partner TYPE bu_partner.

  is_address-name       = 'Harry Hirsch'.
  is_address-name_2     = 'Vertrieb'.
  is_address-city       = 'Hannover'.
  is_address-postl_cod1 = '30855'.
  is_address-street     = 'Otto-Waalkes-Platz'.
  is_address-street_no  = '2'.
  is_address-country    = 'DE'.
  is_address-langu      = 'D'.
  is_address-sort1      = 'HARRYHIRSCH'.
  is_address-sort2      = 'HIRSCHHARRY'.
  is_address-xpcpt      = 'X'. "Standardaddress

  TRY.
      DATA(guid) = cl_system_uuid=>create_uuid_x16_static( ).
    CATCH cx_uuid_error.
      RETURN.
  ENDTRY.

  DATA(lx_data) = VALUE cvis_ei_extern(
    partner-header-object_task     = 'I'
    partner-header-object          = 'BUS1006' "Business Partner
    partner-header-object_instance = VALUE #(
      bpartner               = '' "use guid for creation
      bpartnerguid           = guid
      identificationcategory = 'ZCUST'
      identificationnumber   = 'EXTID01234' )

      partner-central_data-common = VALUE #(
        data = VALUE #(
          bp_control      = VALUE #(
                              category = '2' "organization
                              grouping = 'SHIP' ) "ship-to
          bp_organization = VALUE #(
                              name1 = is_address-name
                              name2 = is_address-name_2
                              name3 = is_address-name_3
                              name4 = is_address-name_4 )
          bp_centraldata  = VALUE #(
                              searchterm1 = is_address-sort1
                              searchterm2 = is_address-sort2
                              title_key   = '0003'      "company
                              partnertype = '0020') ) ) "ship-to
      partner-central_data-role-roles = VALUE #( (
        data_key = 'FLCU01'
        data     = VALUE #( rolecategory = 'FLCU01' ) ) )
      partner-central_data-address = VALUE #(
        current_state  = 'C'
        time_dependent = abap_false
        addresses = VALUE #( (
           task               = 'I'
           data_key-operation = 'I'
           currently_valid    = abap_true
           data               = VALUE #(
             postal = VALUE #( data =                    VALUE #( BASE CORRESPONDING #( is_address ) standardaddress = 'X' ) )                     remark = VALUE #(                                current_state = 'C'                                remarks = VALUE #(
                         ( task = 'I'
                           data = VALUE #(
                                    langu     = 'D'
                                    adr_notes = 'Testharry' ) ) ) )
             addr_usage-current_state = 'C'
             addr_usage-addr_usages   = VALUE #(
               ( task                 = 'I'
                 currently_valid      = 'X'
                 data_key-addresstype = 'XXDEFAULT' "'FIRMA' " '0003' "business address
                 data-standard        = abap_true )
               ( task                 = 'I'
                 currently_valid      = 'X'
                 data_key-addresstype = 'FIRMA' " '0003' "business address
                 data-standard        = abap_true ) ) ) ) ) )
             customer-header-object_instance-kunnr = space
             customer-header-object_task = 'I'
             ensure_create-create_customer = abap_true
             customer-sales_data-sales = VALUE #( (
               task = 'I'
               data_key-vkorg = '1000'
               data_key-vtweg = '10'
               data_key-spart = '10'
               data-lprio     = '2' "Delivery priority
               data-vsbed     = '01' "shipping conditions
               data-antlf     = '9' "maximum number of permitted part deliveries per item
               ) ) ).

  cl_md_bp_maintain=>validate_single(
    EXPORTING
      i_data                   = lx_data
      iv_test_run_mode         = ' '
    IMPORTING
      et_return_map            = DATA(lt_return_map)  ).
  IF NOT line_exists( lt_return_map[ type = 'E' ] ).
    SET UPDATE TASK LOCAL.
    cl_md_bp_maintain=>maintain(
      EXPORTING
        i_data     = VALUE #( ( lx_data ) )
        i_test_run = space
      IMPORTING
        e_return   = DATA(ls_return) ).
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

    IMPORT lv_partner TO rv_bu_partner FROM MEMORY ID 'BUP_MEMORY_PARTNER'.
    MESSAGE |{ rv_bu_partner } created| TYPE 'I'.
  ENDIF.

This code creates the business partner.

Except: the external Id will not be created. I have no clue, why not.

The identification category ZCUST exists. There are no errors or warnings.

Do you have any clues or example code where the external identification will be created?

Thanks in advance!

separate set of external id works with this code

    CALL FUNCTION 'BAPI_IDENTIFICATION_ADD'
      EXPORTING
        businesspartner        = rv_bu_partner
        identificationcategory = 'ZCUST'
        identificationnumber   = 'ABC11'
        identification         = ls_identification
      TABLES
        return                 = lt_return.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

in one system but no in an other system... 😞

Accepted Solutions (1)

Accepted Solutions (1)

Domi
Active Contributor

Hi

partner-header-object_instance

is only for identification.

To create/change the ID number use

i_data-partner-central_data-ident_number

regards

Domi

EnnoWulff
Active Contributor

Thanks dominik.bigl2 !

this is the missing code:

    partner-central_data-ident_number  =value#( ident_numbers =value#((task='I'
        data_key =value#( identificationcategory ='ZCUST' 
                            identificationnumber   ='TEST123')data=value#())))

:beer:

Answers (3)

Answers (3)

a1965_1250
Discoverer
0 Kudos

that's what return brings.... (sorry missed it in the last post)

a1965_1250
Discoverer
0 Kudos

Hi,

i'm using this class... works as designed, but i need to create a partner with external number:

...grouping = (ZAPA)

What am i missing?

category and grouping a set

guid ist filled

Any advice is welcome....

0 Kudos

Hi Enno Wulff / Dominik,

Is it possible to maintain External BP Number using this API Class?

EnnoWulff
Active Contributor
0 Kudos

I didn't find the field in the CMDS_EI_MAIN structures... 😞