Quantcast
Channel: SCN : Discussion List - Customer Relationship Management (SAP CRM)
Viewing all articles
Browse latest Browse all 4296

Updating Address Usage of a BP

$
0
0

Hi All,

 

    I need help in updating the address type for a standard address for a BP. The intent is to add a z address type to the standard address, along with XXDEFAULT which is added automatically.

 

   For this I identified the BADI  - BUPA_GENERAL_UPDATE and created an Update Task FM , which in turn calls the FM BUPA_ADDRESS_CHANGE

( as Calling BUPA_ADDRESS_CHANGE directly in the change_before_update method of the BADI throws a Commit interrupt exception ).

 

The data I pass to this FM looks something like this-

 

ls_addressusage-addresstype = 'ZZABC'.

 

READ TABLE lt_but020_n INTO ls_but020_n WITH KEY addrnumber = lv_addrnum. " Obtained from Callback

IF sy-subrc EQ 0.

lv_addrguid = ls_but020_n-address_guid.

ENDIF.

ls_addressusage-standardaddressusage = 'X'.

APPEND ls_addressusage TO lt_addressusage.

READ TABLE lt_but021_fs_new INTO ls_but021_fs_new WITH KEY partner = lv_partner  adr_kind = 'XXDEFAULT' addrnumber = lv_addrnum.

" Obtained from address callback.

clear ls_addressusage.

ls_addressusage-addresstype = 'XXDEFAULT'.

APPEND ls_addressusage TO lt_addressusage.

 

CALL FUNCTION 'ZBUPA_ADDRUSG_UPDATE' in update task

  EXPORTING

            IV_PARTNER    = LV_PARTNER

            IV_ADDRNUMBER = LV_ADDRNUM

          TABLES

            ET_ADUSE      = lt_addressusage.

 

---------------------------------------------------------------------------------------------------------------------

ZBUPA_ADDRUSG_UPDT

----------------------------------------------------------------------------------------------------------------------

 

data: IT_ADUSE_X type standard table of  BAPIBUS1006_ADDRESSUSAGE_X,

         ls_aduse_x type BAPIBUS1006_ADDRESSUSAGE_X,

         ls_aduse type BAPIBUS1006_ADDRESSUSAGE.

 

 

" Doing this because the standard fm checks for equal number of rows in it_aduse and it_aduse_x and exits if they are not equal.

 

   loop at et_aduse into ls_aduse.

     ls_aduse_x-STANDARDADDRESSUSAGE    = ls_aduse-STANDARDADDRESSUSAGE.

     ls_aduse_x-ADDRESSTYPE             = ls_aduse-ADDRESSTYPE.

 

     ls_aduse_x-USAGEVALIDFROM          = ls_aduse-USAGEVALIDFROM.

     ls_aduse_x-USAGEVALIDTO            = ls_aduse-USAGEVALIDTO.

 

     append ls_aduse_x to it_aduse_x.

   endloop.

 

   CALL FUNCTION 'BUPA_ADDRESS_CHANGE'

     EXPORTING

       IV_PARTNER    = iv_partner

       IV_ADDRNUMBER = iv_addrnumber

     TABLES

       IT_ADUSE      = et_aduse

       IT_ADUSE_X    = it_aduse_x.

 

  This basically does not add the additional data type I am trying to add. I am unsure about the data structure I am exporting to BUPA_ADDRESS_CHANGE so if anyone has familiarity with this then please guide.

 

I tried this with - FINISHED method of BUPA_ADDRESS_UPDATE BADI as well but met no success.

 

What i am looking for is whether there is a badi that can be used after the Business Partner is saved. Can we directly add the record with the addresstype directly to the BUT021_FS table.

 

Also will the approach with BUPA_GENERAL_UPDATE BADI work only with existing accounts? Because when a new account is created there is no value in the database for the BP and the fm BUPA_ADDRESS_CHANGE fails at some point( observed via debugging ).

 


Viewing all articles
Browse latest Browse all 4296

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>