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: 

Update Lfa1, LFA1-SPERQ

hutner
Explorer
0 Kudos
726

Hello,

I want to update the field sperq in the table lfa1.

How can I do this. I tried the fm vendor_update but it didn't worked for me.

My other solution was:

(but I get this message: Eingaben sind unzulässig). If I press the "ok" Button it works fine. But how can I do this in the background without user input. Thanks.

 ls_bdc-program = 'SAPMF02K'.
          ls_bdc-dynpro = 0507.
          ls_bdc-dynbegin = 'X'.
          APPEND ls_bdc TO lt_bdc.

          CLEAR ls_bdc.
          ls_bdc-fnam = 'BDC_CURSOR'.
          ls_bdc-fval = 'RF02K-LIFNR'.
          APPEND ls_bdc TO lt_bdc.

          CLEAR ls_bdc.
          ls_bdc-fnam = 'BDC_OKCODE'.
          ls_bdc-fval = '/00'.
          APPEND ls_bdc TO lt_bdc.

          CLEAR ls_bdc.
          ls_bdc-fnam = 'RF02K-LIFNR'.
          ls_bdc-fval =  i_lifnr.
          APPEND ls_bdc TO lt_bdc. 

 ls_bdc-program = 'SAPMF02K'.
          ls_bdc-dynpro = 0510.
          ls_bdc-dynbegin = 'X'.
          APPEND ls_bdc TO lt_bdc.

          CLEAR ls_bdc.
          ls_bdc-fnam = 'BDC_CURSOR'.
          ls_bdc-fval = 'LFA1-SPERQ'.
          APPEND ls_bdc TO lt_bdc.

          CLEAR ls_bdc.
          ls_bdc-fnam = 'BDC_OKCODE'.
          ls_bdc-fval = '=UPDA'.
          APPEND ls_bdc TO lt_bdc.

          CLEAR ls_bdc.
          ls_bdc-fnam = 'LFA1-SPERQ'.
          ls_bdc-fval =  'Z4'.
          APPEND ls_bdc TO lt_bdc.

CALL TRANSACTION 'MK05' WITH AUTHORITY-CHECK USING lt_bdc MODE 'E' UPDATE 'S' MESSAGES INTO it_msg.


1 REPLY 1

234

Hello Stefanie,

You can maintain the table LFA1 by calling this Method:

vmd_ei_api=>maintain_bapi

  DATA: ls_master_data TYPE vmds_ei_main.
  DATA: ls_vmds_extern TYPE vmds_ei_extern.
  DATA: LV_LIFNR TYPE LIFNR.

 LV_LIFNR = 'BP NUMBER'.

 IF LV_LIFNR IS NOT INITIAL. 

  ls_vmds_extern-header-object_instance-lifnr = lv_lifnr.
  ls_vmds_extern-header-object_task = 'U'.

  ls_vmds_extern-central_data-central-data-sperq = 'Z4'.
  ls_vmds_extern-central_data-central-datax-sperq = 'X'.

  APPEND ls_vmds_extern TO ls_master_data-vendors.

  vmd_ei_api=>initialize( ).

CALL METHOD vmd_ei_api=>maintain_bapi
    EXPORTING
      is_master_data           = ls_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. 



Thanks,
Leeneshwar