The last section (part1) covered the steps required to enhance vendor master( table/screens ). In this section I will demonstrate the procedure to update the custom fields of vendor master and generate change pointers for these fields ( to eventually generate IDOCS for changes to field values).

Unfortunately since there is no standard BAPI to update the vendor master record, the only other options available to update custom fields of vendor master are to either 1) Perform a BDC on XK02 transaction to update custom fields on subscreen with these fields. 2) Enhance vendor API class VMD_EI_API to process and update custom fields.

The former (BDC) may not be feasible in many scenarios, specially if the custom screen fields are read only( like in my case) fields or these fields are not added to the subscreen in the first place.

Given this shortcoming of BDC I will only cover ( and recommend ) the second option for vendor master update ( vendor API class).

Step1: Enhance structure of importing parameter to pass values for custom fields.

  • Enhance structure VMDS_EI_EXTERN by appending fields to include structure CI_CUSTOM. The screenshot below shows vendor safety structure (which was also appended to LFA1) is added as a component to CI_CUSTOM. This ensures any additional fields added to this structure for vendor master (general data) enhancement will automatically update importing parameter structure.


  • Enhancing VMDS_EI_EXTEN enables passing of values for custom vendor master fields using interface of method VMD_EI_API=>MAINTAIN( ). This method will be called to update vendor master data.


Step2: Implement enhancement to read the values passed for custom fields and assign them to LFA1 structure which is already being populated by the standard code. The screenshot below shows implementation of explicit enhancement section EHP603_EXTERN_TO_ECC_UPDATE_02 of enhancement spot ES_VMD_EI_API_MAP_STRUCTURE.


    • Although the above shown enhancement only updates custom the central data (general data ) of vendor master, the enhancement spot offers other enhancement sections which can be used in a similar fashion to update other sections of the vendor master ( purchase org, company, banking etc ).
    • As per sap note 1989074 always replace an standard sap implementation instead of changing it.

     This completes the enhancements required in the vendor master API class for updating vendor master.

Step3: The next step involves calling the MAINTAIN method of VMD_EI_API class to update vendor master.  In my scenario I am reading vendor master details from an XML file, transforming it and updating Vendor master, however The code snippet only shows the call to update vendor master, rest is beyond scope of this article.

METHOD update_vendor_master.

  DATA: ls_vmds_ei_main TYPE vmds_ei_main,

        ls_message      TYPE cvis_message,

        lt_return       TYPE bapiret2_t,

        ls_return       LIKE LINE OF lt_return.

  DATA: lt_vmds_ei_extern TYPE vmds_ei_extern_t,

        ls_vmds_ei_extern LIKE LINE OF lt_vmds_ei_extern.

  DATA: lv_success TYPE sap_bool,

        ls_lfa1_new TYPE lfa1.

  DATA: ls_update_err TYPE LINE OF zmmtt_lifnr_update_failed_list.

** Populate the method input parameters.

  ls_vmds_ei_externheaderobject_instance = iv_lifnr.

  ls_vmds_ei_externheaderobject_task     = ‘U’“<- indicator to update

  ls_vmds_ei_externzzvend_safety_compl    = is_safety_score. “<- input parameter to this method, originally read from XML

  APPEND ls_vmds_ei_extern TO lt_vmds_ei_extern.

  ls_vmds_ei_mainvendors = lt_vmds_ei_extern.



      is_master_data = ls_vmds_ei_main    ” Vendor Total Data


      es_error       ls_message   ).” Error Indicator and System Messages

  IF ls_messageis_error IS INITIAL.

    COMMIT WORK AND WAIT.     “<– Explicit commit required to finalize changes in database

    IF sysubrc EQ 0.

      lv_success = abap_true.



    lv_success = abap_false.


  IF lv_success EQ abap_true.

    ls_lfa1_new = is_lfa1_old.

    ls_lfa1_newzzvscs_company_name     = is_safety_scorezzvscs_company_name.

    ls_lfa1_newzzvscs_isn_code         = is_safety_scorezzvscs_isn_code.

    ls_lfa1_newzzvscs_naics_code       = is_safety_scorezzvscs_naics_code.

    ls_lfa1_newzzvscs_trir_3_years     = is_safety_scorezzvscs_trir_3_years.

    ls_lfa1_newzzvscs_fatality_3_years = is_safety_scorezzvscs_fatality_3_years.

    ls_lfa1_newzzvscs_scq_v_score      = is_safety_scorezzvscs_scq_v_score.

    ls_lfa1_newzzvscs_emr_3_years      = is_safety_scorezzvscs_emr_3_years.

    ls_lfa1_newzzvscs_ravs_score       = is_safety_scorezzvscs_ravs_score.

    ls_lfa1_newzzvscs_citation_info    = is_safety_scorezzvscs_citation_info.

    ls_lfa1_newzzvscs_dashboard_score  = is_safety_scorezzvscs_dashboard_score.

    ls_lfa1_newzzvscs_hes_showstpr     = is_safety_scorezzvscs_hes_showstpr.

    ls_lfa1_newzzvscs_eval_rept        = is_safety_scorezzvscs_eval_rept.

    ls_lfa1_newzzvscs_score_accept_hdr = is_safety_scorezzvscs_score_accept_hdr.

    ls_lfa1_newzzvscs_changed_by       = is_safety_scorezzvscs_changed_by.

    ls_lfa1_newzzvscs_changed_at       = is_safety_scorezzvscs_changed_at.

    ls_lfa1_newzzvscs_changed_on       = is_safety_scorezzvscs_changed_on.

    rv_success = me->perform_update_change_pointers( iv_lifnr = iv_lifnr is_lfa1_old = is_lfa1_old is_lfa1_new = ls_lfa1_new ).
     ” perform_update_change_pointers -> covered in next step

     ” custom error handling logic based on requirements.
    ls_update_errlifnr = iv_lifnr.

    ls_update_errname  = is_lfa1_oldname1.

    ls_update_errchanged_on = sydatum.

    ls_update_errtext       = texte06.

    lt_return = ls_messagemessages.

    READ TABLE lt_return INTO ls_return WITH KEY type = ‘E’.

    IF sysubrc EQ 0.

      REPLACE FIRST OCCURRENCE OF ‘&’ IN ls_update_errtext WITH ls_returnmessage.


    APPEND ls_update_err TO me->mt_lfa1_failed.

    CLEAR ls_update_err.



Step3: If the vendor master update is successful in the previous method, the next step is creation of change documents for the custom fields, which will eventually create the change pointers ( for IDOC creation).

  • To ensure change documents are created for custom fields, your code needs to keep a copy of vendor master before and after the change ( is_lfa1_old and ls_lfa1_new in the above code ).

METHOD perform_update_change_pointers.


        l_lfb1      TYPE lfb1,

        l_lfm1      TYPE lfm1,

        l_ylfa1     TYPE lfa1,

        l_ylfb1     TYPE lfb1,

        l_ylfm1     TYPE lfm1,

        lt_xlfas    TYPE STANDARD TABLE OF flfas,

        lt_xlfb5    TYPE STANDARD TABLE OF flfb5,

        lt_xlfbk    TYPE STANDARD TABLE OF flfbk,

        lt_xlfza    TYPE STANDARD TABLE OF flfza,

        lt_ylfas    TYPE STANDARD TABLE OF flfas,

        lt_ylfb5    TYPE STANDARD TABLE OF flfb5,

        lt_ylfbk    TYPE STANDARD TABLE OF flfbk,

        lt_ylfza    TYPE STANDARD TABLE OF flfza,

        lt_xknvk    TYPE STANDARD TABLE OF fknvk,

        lt_xlfat    TYPE STANDARD TABLE OF flfat,

        lt_xlfbw    TYPE STANDARD TABLE OF flfbw,

        lt_xlfei    TYPE STANDARD TABLE OF flfei,

        lt_xlflr    TYPE STANDARD TABLE OF flflr,

        lt_xlfm2    TYPE STANDARD TABLE OF flfm2,

        lt_xwyt1    TYPE STANDARD TABLE OF fwyt1,

        lt_xwyt1t   TYPE STANDARD TABLE OF fwyt1t,

        lt_xwyt3    TYPE STANDARD TABLE OF fwyt3.

  DATA: lv_objectid TYPE cdobjectv,


  lv_objectid = iv_lifnr.

  GET TIME.         “<- Gets the latest date and time.



      objectid                = lv_objectid

      tcode                   = me->gc_tcode_change

      utime                   = syuzeit

      udate                   = sydatum

      username                = syuname

      planned_change_number   = ‘ ‘

      object_change_indicator = me->gc_update

      planned_or_real_changes = ‘ ‘

      no_change_pointers      = ‘ ‘

      upd_knvk                = space

      n_lfa1                  = is_lfa1_new

      o_ylfa1                 = is_lfa1_old

      upd_lfa1                = abap_true

      upd_lfas                = ‘ ‘

      upd_lfat                = ‘ ‘

      n_lfb1                  = l_lfb1

      o_ylfb1                 = l_lfb1

      upd_lfb1                = ‘ ‘

      upd_lfb5                = ‘ ‘

      upd_lfbk                = ‘ ‘

      upd_lfbw                = ‘ ‘

      upd_lfei                = ‘ ‘

      upd_lflr                = ‘ ‘

      n_lfm1                  = l_lfm1

      o_ylfm1                 = l_lfm1

      upd_lfm1                = ‘ ‘

      upd_lfm2                = ‘ ‘

      upd_lfza                = ‘ ‘

      upd_wyt1                = ‘ ‘

      upd_wyt1t               = ‘ ‘

      upd_wyt3                = ‘ ‘


      xknvk                   = lt_xknvk

      yknvk                   = lt_xknvk

      xlfas                   = lt_xlfas

      ylfas                   = lt_xlfas

      xlfat                   = lt_xlfat

      ylfat                   = lt_xlfat

      xlfb5                   = lt_xlfb5

      ylfb5                   = lt_xlfb5

      xlfbk                   = lt_xlfbk

      ylfbk                   = lt_ylfbk

      xlfbw                   = lt_xlfbw

      ylfbw                   = lt_xlfbw

      xlfei                   = lt_xlfei

      ylfei                   = lt_xlfei

      xlflr                   = lt_xlflr

      ylflr                   = lt_xlflr

      xlfm2                   = lt_xlfm2

      ylfm2                   = lt_xlfm2

      xlfza                   = lt_xlfza

      ylfza                   = lt_xlfza

      xwyt1                   = lt_xwyt1

      ywyt1                   = lt_xwyt1

      xwyt1t                  = lt_xwyt1t

      ywyt1t                  = lt_xwyt1t

      xwyt3                   = lt_xwyt3

      ywyt3                   = lt_xwyt3.

  if sysubrc eq 0.

    COMMIT WORK AND WAIT. “<– Explicit commit required to finalize changes in database

    if sysubrc eq 0.

      rv_success = abap_true.


     “Custom error handing logic
  if rv_success ne abap_true.

    ls_update_errlifnr = iv_lifnr.

    ls_update_errname  = is_lfa1_newname1.

    ls_update_errchanged_on = SYDATUM.

    ls_update_errtext       = texte05.

    APPEND ls_update_err to me->mt_lfa1_failed.

    CLEAR ls_update_err.



This completes vendor master update. In the next part will cover creation of CREAMAS idocs for vendor master changes.- part3

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply