Skip to Content
avatar image
Former Member

Deleting Bank vendor data using class VMD_EI_API

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Jun 16, 2017 at 02: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.

    Add comment
    10|10000 characters needed characters exceeded