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: 

BAPI for vendor's bank account's deletion

bmierzwi
Participant
0 Kudos

Hello,

I need to delete a vendor's bank account with a custom BAPI delete function, but don't know how to do it.

I have a custom function module that updates and inserts new vendors based on data in an external database (MDS). One of the steps is to check if the account that the incoming vendor has assigned to them is already within the system. It's done by the below form:

PERFORM check_account USING lv_lifnr_tmp l_bank lv_task_tmp.

Which looks like this:

FORM check_account USING p_lifnr
                         p_bank
                         p_task.
DATA: lv_bank TYPE lfbk.
SELECT SINGLE * FROM lfbk INTO lv_bank WHERE lifnr = p_lifnr AND bvtyp = 'A'.<br>IF sy-subrc EQ 0.
*I need to implement that BAPI delete here, within this IF.
   p_task = 'U'.
   p_bank = lv_bank.
ELSE.
  p_task = 'I'.
ENDIF.

ENDFORM.

If that account is present in the system, I need to delete it from the system using that "custom BAPI delete function".

But I can't find any "standard BAPI delete function" to remove a vendor's bank account from the system.

Any ideas how I could locate the standard function I need?

Thank you for your time.

Kind Regards,
Bartek

4 REPLIES 4

gabriel_pill-kahan
Active Participant

Hi,

You can use function module FIN_AP_AR_DELETE_BANK. In case you have business partners, you can use BAPI_BUPA_BANKDETAIL_REMOVE.

0 Kudos

Hello,

Thank you for the reply.

My senior suggested that I should use a BAPI in order to solve this problem, so I studied your suggestion for a time (BAPI_BUPA_BANKDETAIL_REMOVE), but I can't figure it out how can I acquire BANKDETAILID that I need to provide (one of the two parameters that BAPI imports).

I think that the first parameter - BUSINESSPARTNER (like BAPIBUS1006_HEAD-BPARTNER) translates to LIFNR that I have (the vendor's account number).

The second parameter - BANKDETAILID, does not correspond to any field in database table LFBK which is the type of the structure where I hold all the bank details.

Any idea how I could find the BANKDETAILID that the BAPI requires?

Kind Regards,

Bartek

gabriel_pill-kahan
Active Participant

Hi,

You can use related BAPIs to determine which bank detail to use.

BAPI_BUPA_BANKDETAILS_GET to get all bank details data for the specified business partner.

BAPI_BUPA_BANKDETAIL_GETDETAIL to get specific information for one of the bank details.

Please also check table BUT0BK, it should have all the information as in LFBK.

0 Kudos

Hello,

Thank again for the reply.

So I've spent some time trying to work through your suggestions but I am stuck again. 😕

As the result of it all I want bankdetails deleted (via your suggested BAPI_BUPA_BANKDETAIL_REMOVED). In order to use this BAPI, I need to feed "businesspartner" and "bankdetailid" to it.

I have the "businesspartner" as this is my LIFNR.

In order to find "banktdetailid" though, I am trying to use one of your suggestions (BAPI GET or GETDETAIL), but I do not understand how they work.

1. BAPI_BUPA_BANKDETAILS_GET does not export anything… It just takes in my LIFNR as BUSINESSPARTNER and nothing happens. I thought that it does return BANKDETAILS to me as a table, so I created a table LIKE BAPIBUS1006_BANKDETAILS (as per the Tables tab of the BAPI), but BAPI doesn't do anything with it. It leaves my declared table empty.

EDIT: I realized that, when diving deeper into the code of the BAPI, that as it performs its own check, it returns a message saying there's "no such business partner"... but I have it open in XK02, so I know they are there.
So perhaps my LIFNR does not translate directly to the BAPI's "businesspartner"? Could it be that "businesspartner" is made up of more than just the vendor's number?

2. BAPI_BUPA_BANKDETAIL_GETDETAIL requires me to provide BANKDETAILID. I do not have it, because I am trying to get details in order to get this id. xD

Any idea which part of the BAPI I do not understand? Is it that "businesspartner" should be more than just LIFNR?

Many thanks for your time and energy.

Kind Regards,
Bartek