cancel
Showing results for 
Search instead for 
Did you mean: 

Add Tax IDs to BP on SAVE (new)

Former Member
0 Kudos

I'm trying with the following code to add a Tax ID to the BP while I'm saving it (New).

But I don't get the BP ID.

BUPA_NUMBERS_GET doesn't return BP ID.

'BBP_BUPA_GET_NUMBER' doesn't return BP ID.

How can I solve this issue?

Best regards.

METHOD if_ex_bupa_tax_update~change_before_update.
  break josechau.

  DATA: lv_partner    TYPE  bu_partner,
        lv_tax_type   TYPE  bus_tax-tax_type,
        lv_tax_number TYPE  bus_tax-tax_number,
        lv_guid       TYPE  bu_partner_guid.

  LOOP AT it_changed_instances INTO lv_guid.
  ENDLOOP.

  CALL FUNCTION 'BUPA_NUMBERS_GET'
   EXPORTING
     iv_partner_guid           = lv_guid
   IMPORTING
     ev_partner                = lv_partner
*     EV_PARTNER_GUID           =
*     EV_PARTNER_EXTERNAL       =
*     ES_BUT000                 =
*   TABLES
*     ET_RETURN                 =
*     ET_PARTNER                =
            .

  CALL FUNCTION 'BBP_BUPA_GET_NUMBER'
   EXPORTING
*   PARTNER                 =
     partner_guid            = lv_guid
*   ADDRNUM                 =
   IMPORTING
     ev_partner              = lv_partner
*   EV_PARTNER_GUID         =
*   EV_GUID_32              =
   EXCEPTIONS
     partner_not_valid       = 1
     guid_not_valid          = 2
     no_input                = 3
     OTHERS                  = 4
            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.


  MOVE lv_partner TO lv_tax_number.
  MOVE 'CO1' TO lv_tax_type.

  CALL FUNCTION 'BUPA_TAX_ADD'
    EXPORTING
      iv_partner                  = lv_partner
      iv_tax_type                 = lv_tax_type
      iv_tax_number               = lv_tax_number
* TABLES
*   CT_RETURN                   =
 EXCEPTIONS
   record_already_exists       = 1
   invalid_data                = 2
   foreign_lock                = 3
   OTHERS                      = 4
            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  CALL FUNCTION 'BUPA_TAX_SAVE_COMMIT'.
ENDMETHOD.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Ok.

Now I can read memory data.

I wanted to get the BP ID to use BUPA_TAX_ADD to add a new Tax ID.

I use badi BUPA_GENERAL_UPDATE to achieve this but when I call BUPA_TAX_ADD I receive an error "The BP doesn't exist". Same error when using TAX_GENERAL_UPDATE so I need a BAPI or FM to add a Tax ID to Memory because this FM tries to add the ID to an existing BP in the database.

Any idea?

Best Regards

Former Member
0 Kudos

Hi,

Sure, this can be done - but i'd need some more info -

How are you creating the BP ? Are you using transaction BP, or are you using a report program with BAPIs ?

In SAP BP, the dialog memory and BAPI memory are very different. If you are creating the bp using dialog(transaction BP), then what we can do is default the tax number on the screen, and the dialog memory, so that it automatically gets saved.

If you are using BAPIs / APIs, then there should be no problem using BUPA_TAX_ADD.

Cheers,

Rishu.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

The module BUPA_NUMBERS_GET would not help here. Instead, please try using the module BUP_MEMORY_BUT000_GET.

You can pass the GUID to this module, and it wil return a structure ES_BUT000. You'd need to read the field PARTNER of ES_BUT000 to get the BP id.

This will work. Do let me know in case you still face problems.

Cheers,

Rishu.

Former Member
0 Kudos

Same problem.

The Badi doesn't return any value.

Best Regards

Former Member
0 Kudos

Hi,

Please try using the function module BUPA_GENERAL_CALLBACK - this will surely return data in the structures ET_BUT000_NEW and ET_BUT000_OLD.

You could get the partner number from etiher of these structures.

Also, you could use module BUPA_TAX_CALLBACK, which will actually return the tax data that you have changed, and partner number is a field of the tax data structure.

And one important point - if you want the save of BP to trigger the tax add, you would need to write this particualr code(what you have included in the question) in the implementation of BADI BUPA_GENERAL_UPDATE. Currently, you have written it in the BADI BUPA_TAX_UPDATE, which will get called for changes to TAX number, not for changes to general business partner.

Regards,

Rishu.

Edited by: Rishu Thukral on Apr 16, 2009 8:05 PM