2017 May 19 11:26 PM
Dear Experts,
Currently I need to delete the entire bank data associated to a vendor from table LFBK, I’m using class “VMD_EI_API” since it allows modifying vendor data in its method “MAINTAIN_BAPI”, in a test programs I have been able to insert new bank data and modify existing one without issues, but is not working when I try to delete it, I wonder if this class can truly be use to achieve that goal or if I need another class or function.
This is my test program for deleting bank data, first I’m using method “GET_DATA” of class “VMD_EI_API_EXTRACT” to get the complete data of the vendor, then I try to update it and set all the current bank data to a delete task but in the end it isn’t deleting the information, not sure if I’m missing something in the class configuration
REPORT ytest_update_vendor_del.
PARAMETERS: p_lifnr TYPE lifnr OBLIGATORY.
START-OF-SELECTION.
PERFORM update_data.
FORM update_data .
DATA: lo_vmd_ei_api TYPE REF TO vmd_ei_api.
DATA: l_ti_is_master_data TYPE vmds_ei_main,
l_ti_is_master_data_in TYPE vmds_ei_main.
DATA: ls_vmds_ei_extern TYPE vmds_ei_extern.
DATA: lc_lifnr TYPE lifnr.
**********************************************************************
CHECK p_lifnr IS NOT INITIAL.
CREATE OBJECT lo_vmd_ei_api.
ls_vmds_ei_extern-header-object_instance-lifnr = p_lifnr.
ls_vmds_ei_extern-header-object_task = 'U'.
APPEND ls_vmds_ei_extern TO l_ti_is_master_data_in-vendors.
* Capture all the vendor data
CALL METHOD vmd_ei_api_extract=>get_data
EXPORTING
is_master_data = l_ti_is_master_data_in
IMPORTING
es_master_data = DATA(l_ti_is_master_data_es)
es_error = DATA(l_error).
* Get the current vendor data into a structure
READ TABLE l_ti_is_master_data_es-vendors INTO ls_vmds_ei_extern WITH KEY header-object_instance-lifnr = p_lifnr.
IF sy-subrc EQ 0.
ls_vmds_ei_extern-header-object_instance-lifnr = p_lifnr.
ls_vmds_ei_extern-header-object_task = 'U'.
LOOP AT ls_vmds_ei_extern-central_data-bankdetail-bankdetails ASSIGNING FIELD-SYMBOL(<lfs_bank>).
* This is the delete order
<lfs_bank>-task = 'D'.
* I try to check all the fields to see if it helped but it didn´t
<lfs_bank>-datax-bkont = abap_true.
<lfs_bank>-datax-bvtyp = abap_true.
<lfs_bank>-datax-xezer = abap_true.
<lfs_bank>-datax-bkref = abap_true.
<lfs_bank>-datax-koinh = abap_true.
<lfs_bank>-datax-iban = abap_true.
<lfs_bank>-datax-iban_from_date = abap_true.
ENDLOOP.
APPEND ls_vmds_ei_extern TO l_ti_is_master_data-vendors.
CALL METHOD lo_vmd_ei_api->maintain_bapi
EXPORTING
is_master_data = l_ti_is_master_data
iv_collect_messages = abap_true
IMPORTING
es_master_data_correct = DATA(ls_es_master_data_correct)
es_message_correct = DATA(ls_es_message_correct)
es_master_data_defective = DATA(ls_es_master_data_defective)
es_message_defective = DATA(ls_es_message_defective).
IF ls_es_message_defective-is_error IS INITIAL AND
ls_es_message_defective-messages[] IS INITIAL.
COMMIT WORK AND WAIT.
ELSE.
ROLLBACK WORK.
ENDIF.
ENDIF.
As always any help is appreciated, thanks for the time.
2017 Jun 16 3:16 PM
Sadly I wasn’t able to achieve this, I couldn’t delete Bank vendor data, but I did find something interesting, if you update all the Bank vendor data items with the same data in the fields banks, bankl and bankn. The BAPI class “CMD_EI_API” in its method “MAINTAIN_BAPI” it will delete all but one item, in the end this was the solution we used.
2021 Feb 11 2:14 PM
I know that question has been asked long time ago but here is an answer:
Since you have got all of yours bank accounts accquired from vmd_ei_api_extract class, then you have to simply remove bank accounts, which you want to be deleted, from table:
ls_vmds_ei_extern-central_data-bankdetail-bankdetails
Unfortunately deletion of bank accounts is not possible with "D" indicator.
2024 Mar 21 1:10 PM
Hi,
Thanks for the update.
I'm facing similar issue, my requirement was to delete the customer bank details based on Kunnr. I've tried by deleting the bankdetails table entirely, still it does not delete the bank details from KNBK.
Please find logic below. Please advise on how to fix.
DATA: l_is_master_data TYPE cmds_ei_main,
l_es_master_data TYPE cmds_ei_main,
l_es_error TYPE cvis_message.
DATA: t_customers TYPE cmds_ei_extern_t,
s_customers TYPE LINE OF cmds_ei_extern_t.
s_customers-header-object_instance-kunnr = lv_kunnr
s_customers-header-object_task = 'M' .
APPEND s_customers TO t_customers.
l_is_master_data-customers = t_customers.
cmd_ei_api_extract=>get_data(
EXPORTING
is_master_data = l_is_master_data
IMPORTING
es_master_data = l_es_master_data
es_error = l_es_error ).
IF l_es_master_data IS NOT INITIAL.
s_customers = l_es_master_data-customers[ header-object_instance-kunnr = ls_cdhdr-objectid ].
LOOP AT s_customers-central_data-bankdetail-bankdetails ASSIGNING FIELD-SYMBOL(<lfs_bankdetails>).
CLEAR <lfs_bankdetails>.
<lfs_bankdetails>-task = 'D'.
CLEAR l_es_master_data-customers.
s_customers-header-object_task = 'U' .
s_customers-central_data-bankdetail-current_state = space.
APPEND s_customers TO l_es_master_data-customers.
cmd_ei_api=>maintain_bapi(
EXPORTING
iv_test_run = space
iv_collect_messages = space
is_master_data = l_es_master_data
IMPORTING
es_master_data_correct = DATA(es_master_data_correct)
es_message_correct = DATA(es_message_correct)
es_master_data_defective = DATA(es_master_data_defective)
es_message_defective = DATA(es_message_defective)
).
IF es_message_defective-is_error IS INITIAL AND es_message_defective-messages[] IS INITIAL.
COMMIT WORK AND WAIT.
ELSE.
ROLLBACK WORK.
ENDIF.
ENDLOOP.
ENDIF.