SAP4TECH

SAP and ABAP Free Tutorials
Menu
  • SAP Technical
    • ABAP Code Snippets
    • ABAP WebDynPro
    • SAP GW
    • SAP IDOC (ALE)
    • SAP PI (XI)
    • SAP Screen Personas
    • SAP Workflow
  • SAP Functional
    • SAP FI
    • SAP FSCM
    • SAP HR
    • SAP SD & SAP MM
    • SAP PM
    • SAP PP
    • SAP PS
    • SAP QM
    • SAP VIM
    • SAP WM
  • SAP Fiori
  • SAP HANA
  • SAP BW
  • SAP CRM
  • SAP SRM
  • SAP4TECH
    • About Us
    • Contact Us
    • Terms & Conditions
    • Privacy and Cookie Policy

SAP4TECH » Mass Update Personal Numbers of Customer KNVP – Full ABAP Code

ABAP Tutorials

Mass Update Personal Numbers of Customer KNVP – Full ABAP Code

August 7, 2015 John

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 )

Mass Update Personal Numbers of Customer KNVP
ABAP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  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.?

Prev Article
Next Article
Tags:Customer in SAP

Related Articles

page not found 688965 1280 e1467294731652
SAP ST22 SNAP Table: SAP Dumb Table for Error. This …

SAP ST22 SNAP – The SAP Tables for Dumb Message

domino 163522 1280 e1442441105680
This sample code will delete a customer address following :Delete …

Full ABAP Program How to Delete Customer Address in SAP

Search on SAP4TECH

The Most Populars

  • The Most Important SAP ISU Tables
    The Most Important SAP ISU Tables
  • SAP Users Tables
    SAP Users Tables (for Personal, Logon, and Address Data)
  • List of SAP Purchase Order Tables in SAP MM SAP PO Tables
    SAP Purchase Order Tables: Main PO tables in SAP MM – SAP PO Tables
  • Full list of SAP Movement Types
    SAP Good Movement Types – Full list of SAP Movement Types
  • The Main SAP GL Account Tcodes SAP GL Account Tables
    The Main SAP G/L Account Tcodes & SAP GL Account Tables
  • SAP BOM Tables
    SAP BOM Tables for BOM Header, Items and components and Category

Related Posts

  • List of SAP Purchase Order Tables in SAP MM SAP PO Tables
    SAP Purchase Order Tables: Main PO tables in SAP MM – SAP PO Tables
  • SAP License Table
    SAP Address – important Tables and BAPI
  • SAP Info Record Table
    SAP Info Record Table, Info Recort Tcodes and SAP Info Record Report
  • Connection1
    Manage SAP SLG1 – Application Log in ABAP with samples
  • e commerce 402822 1920 e1469785791965
    EDI 870 : Order Status Report SAP ORDERS05 IDoc Explained

SAP4TECH

SAP and ABAP Free Tutorials

Trending Posts

  • The Most Important SAP ISU Tables
  • SAP Users Tables (for Personal, Logon, and Address Data)
  • SAP Purchase Order Tables: Main PO tables in SAP MM – SAP PO Tables
  • SAP Good Movement Types – Full list of SAP Movement Types
  • The Main SAP G/L Account Tcodes & SAP GL Account Tables
  • SAP BOM Tables for BOM Header, Items and components and Category

The Most Recents

  • The Most Important SAP ISU Tables
  • SAP Fiori 3 UX and Design of SAP Fiori Apps for SAP S/4HANA, SAP TechEd Lecture
  • The Main SAP Dunning Transaction Codes
  • SAP Accounts Payable Tcodes & Accounts Receivable Tcodes ( SAP AP Tcodes & SAP AR Tcodes)
  • The Most Important SAP Payment Terms Tables (ZTERM, Text…)

Search

SAP Tutorials by Topics

  • SAP Tables
  • SAP Tcodes
  • SAP BAPI
  • ABAP Snippets
  • Top SAP Courses
  • Top SAP Books
Copyright © 2021 SAP4TECH

Ad Blocker Detected

Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker.

Refresh
This website uses cookies to improve your experience. We'll assume you accept this policy as long as you are using this websiteAcceptView Policy