Skip to Content
0

Updating Vendor master data with class VMD_EI_API

May 18, 2017 at 02:48 PM

1.1k

avatar image
Former Member

Hello Experts,

I’m trying to update vendor basic data from table “LFA1”, in my search I was told to use class “VMD_EI_API” in its method “MAINTAIN_BAPI” to achieve that, I created a basic test program to update the name and the street of a vendor, yet even though the process does not generate any error the data is not getting updated, this is the test program I’m currently using:

REPORT ytest_update_vendors.

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.
  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'.

  ls_vmds_ei_extern-central_data-address-task = 'U'.
  ls_vmds_ei_extern-central_data-address-postal-data-name = 'Name 1'.
  ls_vmds_ei_extern-central_data-address-postal-data-name_2 = 'Name 2'.
  ls_vmds_ei_extern-central_data-address-postal-data-name_3 = 'Name 3'.
  ls_vmds_ei_extern-central_data-address-postal-data-name_4 = 'Name 4'.
  ls_vmds_ei_extern-central_data-address-postal-data-street = 'Street 123'.

  ls_vmds_ei_extern-central_data-address-postal-datax-name = abap_true.
  ls_vmds_ei_extern-central_data-address-postal-datax-name_2 = abap_true.
  ls_vmds_ei_extern-central_data-address-postal-datax-name_3 = abap_true.
  ls_vmds_ei_extern-central_data-address-postal-datax-name_4 = abap_true.
  ls_vmds_ei_extern-central_data-address-postal-datax-street = abap_true.

  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.

I’m almost sure something is missing, but since it doesn’t generate any error I have no idea what’s going on, I follow the process in a debug but didn’t see anything weird. The one thing that caught my attention is that in class “VMD_EI_API_MEMORY” method “UPDATE_GLOBAL_FROM_CURRENT” the system assigned the “Set indicator for text memory” flag to table LFA1 data, but no idea if this is a normal part of the process.

Any help is appreciated, thanks for the time.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
avatar image
Former Member May 18, 2017 at 10:28 PM
0

We found the problem, it seems there are some issues in the way the system manage processes in update task, for some weird reason is not working in the method “MAINTAIN_BAPI” since it execute function "VMD_DATA_SAVE" in a on commit method, we are investigating what’s going on but we have a partial solution right now, if you call method “UPDATE_MODULES” from class “VMD_EI_API” before the commit this will update the data anyway.

      CALL METHOD vmd_ei_api=>update_modules
        IMPORTING
          es_error = DATA(ls_error).

Once again thanks everyone for your time.

Share
10 |10000 characters needed characters left characters exceeded
Raymond Giuseppi
May 18, 2017 at 03:02 PM
1

Usually to change vendor I start with a call of vmd_ei_api_extract=>get_data to build the initial deep structure from database.

Then;navigating in the deep structure, I maintain the task flags (I/U), change/insert some values in the DATA records and set required update flag in the DATAX records, some cleaning of unrequired sub-structures can also be performed.

Finally I call the vmd_ei_api=>maintain_bapi and analyze returned/changed parameters.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks for the answer, didn’t knew of that method, I will try to use it and see if maybe my system requires more data to correctly change the vendor information

0
avatar image
Former Member May 18, 2017 at 03:35 PM
1

Hey I dont know what you are doing.. but I copied the same code; did some changes to it & it works.

I agree it doesnt give any messages but seriously it works

Heres my scenario: Changing the vendor names

After running the program:

capture.jpg

Below is the code I executed:

REPORT  ZATEST1.

*REPORT ytest_update_vendors.



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.

DATA: ls_vmds_ei_extern TYPE vmds_ei_extern.

DATA: lc_lifnr TYPE lifnr.



DATA:a TYPE VMDS_EI_MAIN,

     b TYPE CVIS_MESSAGE,

     c TYPE VMDS_EI_MAIN,

     d TYPE CVIS_MESSAGE.



**********************************************************************

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'.



ls_vmds_ei_extern-central_data-address-TASK = 'U'.

ls_vmds_ei_extern-central_data-address-postal-DATA-name = 'Name 1'.

ls_vmds_ei_extern-central_data-address-postal-DATA-name_2 = 'Name 2'.

ls_vmds_ei_extern-central_data-address-postal-DATA-name_3 = 'Name 3'.

ls_vmds_ei_extern-central_data-address-postal-DATA-name_4 = 'Name 4'.

ls_vmds_ei_extern-central_data-address-postal-DATA-street = 'Street 123'.



ls_vmds_ei_extern-central_data-address-postal-datax-name = 'X'.

ls_vmds_ei_extern-central_data-address-postal-datax-name_2 = 'X'.

ls_vmds_ei_extern-central_data-address-postal-datax-name_3 = 'X'.

ls_vmds_ei_extern-central_data-address-postal-datax-name_4 = 'X'.

ls_vmds_ei_extern-central_data-address-postal-datax-street = 'X'.



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      = 'X'

IMPORTING

es_master_data_correct   = a

es_message_correct       = b

es_master_data_defective = c

es_message_defective     = d.




IF d-is_error   IS INITIAL AND

d-messages[] IS INITIAL.



  COMMIT WORK AND WAIT.

ELSE.

  ROLLBACK WORK.

ENDIF.



endform.


capture.jpg (50.1 kB)
capture.jpg (40.0 kB)
Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Well this is interesting, just to be sure I copied your code in my system, but in the same way that my original code it did not work, unless I’m mistaken the change in data should be reflected in the table LFA1, since it doesn't work in my system I believe that maybe an enhancement or some external code must be interfering, will have to confirm that, but thank you for the answers

0
Former Member

While calling, put a break point on message statement; check if someone has written a custom code in enhancement.

Also check if you have access to do that change or not..

1