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: <fs_knvp_new> LIKE LINE OF lt_knvp_new. FIELD-SYMBOLS: <fs_knvp_old> LIKE LINE OF lt_knvp_old. FIELD-SYMBOLS: <fs_team> 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 <fs_team>. CLEAR lv_parza. APPEND INITIAL LINE TO lt_knvp_new ASSIGNING <fs_knvp_new>. <fs_knvp_new>-kunnr = <fs_team>-kunnr. <fs_knvp_new>-vkorg = <fs_team>-vkorg. <fs_knvp_new>-vtweg = <fs_team>-vtweg. <fs_knvp_new>-spart = <fs_team>-spart. <fs_knvp_new>-parvw = <fs_team>-parvw. <fs_knvp_new>-pernr = <fs_team>-pernr. CLEAR <fs_knvp_new>-parza. " Get number PARZA READ TABLE lt_knvp_old INTO ls_knvp_old WITH KEY kunnr = <fs_knvp_new>-kunnr vkorg = <fs_knvp_new>-vkorg vtweg = <fs_knvp_new>-vtweg spart = <fs_knvp_new>-spart parvw = <fs_knvp_new>-parvw BINARY SEARCH. IF sy-subrc = 0 . lv_index = sy-tabix. ELSE. CONTINUE. ENDIF. LOOP AT lt_knvp_old ASSIGNING <fs_knvp_old> FROM lv_index. IF NOT ( <fs_knvp_old>-kunnr = <fs_knvp_new>-kunnr AND <fs_knvp_old>-vkorg = <fs_knvp_new>-vkorg AND <fs_knvp_old>-vtweg = <fs_knvp_new>-vtweg AND <fs_knvp_old>-spart = <fs_knvp_new>-spart AND <fs_knvp_old>-parvw = <fs_knvp_new>-parvw ) . EXIT. ENDIF. ADD 1 TO lv_parza. ENDLOOP. <fs_knvp_new>-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.?