Mass Update Personal Numbers of Customer KNVP: This sample ABAP Code covers mass updating Personal Numbers for Customers.
Mass Update Personal Numbers of Customer KNVP
You can change this program to update ( remplace PERNR by ):Customer number of business partner ( KUNN2 )
- Account Number of Vendor or Creditor ( LIFNR )
- Personnel Number ( PERNR )
- Number of contact person ( PARNR )
DATA: lt_knvp_old TYPE TABLE OF knvp. DATA: lt_knvp_new TYPE TABLE OF knvp. DATA: lv_index TYPE sy-tabix. DATA: ls_knvv LIKE LINE OF lt_knvv. DATA: ls_knvp_old LIKE LINE OF lt_knvp. DATA: ls_knvp_new LIKE LINE OF lt_knvp. DATA: lv_parza TYPE parza. FIELD-SYMBOLS:LIKE LINE OF lt_knvp_new. FIELD-SYMBOLS: LIKE LINE OF lt_knvp_old. FIELD-SYMBOLS: LIKE LIKE OF pt_teams. " lt_teams contains the list of " Customer / Comm. Org / Personal Numbers / Role to be uploaded " Retrive list of existing function partners SELECT * FROM knvp INTO TABLE lt_knvp_old FOR ALL ENTRIES IN pt_teams WHERE kunnr = pt_teams-kunnr AND pernr IS NOT NULL. IF sy-subrc = 0 . SORT lt_knvp_old BY kunnr vkorg vtweg spart parvw ." parza. ENDIF. LOOP AT pt_teams ASSIGNING . CLEAR lv_parza. APPEND INITIAL LINE TO lt_knvp_new ASSIGNING . -kunnr = -kunnr. -vkorg = -vkorg. -vtweg = -vtweg. -spart = -spart. -parvw = -parvw. -pernr = -pernr. CLEAR -parza. " Get number PARZA READ TABLE lt_knvp_old INTO ls_knvp_old WITH KEY kunnr = -kunnr vkorg = -vkorg vtweg = -vtweg spart = -spart parvw = -parvw BINARY SEARCH. IF sy-subrc = 0 . lv_index = sy-tabix. ELSE. CONTINUE. ENDIF. LOOP AT lt_knvp_old ASSIGNING FROM lv_index. IF NOT ( -kunnr = -kunnr AND -vkorg = -vkorg AND -vtweg = -vtweg AND -spart = -spart AND -parvw = -parvw ) . EXIT. ENDIF. ADD 1 TO lv_parza. ENDLOOP. -parza = lv_parza. ENDLOOP. "Mass Update Personal Numbers of Customer KNVP IF lt_knvp_new[] IS NOT INITIAL . MODIFY knvp FROM TABLE lt_knvp_new[]. IF sy-subrc = 0 . COMMIT WORK AND WAIT . ENDIF. ENDIF.
Check also?The 3 ways to Mass Update Contacts of Customer in SAP
Caution: This method updates directly SAP Table which is not recommended by SAP best practise.?