12-10-2008 10:35 AM
Hi guys,
I am using the MODIFY statement in my program to insert/update records in the Database table. Initially it used to insert all 5 records from my excel sheet into the database table. But when i converted a key field of the database table into a non-key field, only one record ( last one ) of the Excel sheet gets updated. Kindly let me know as to why is this happening.
<removed_by_moderator>
Thanks and regards,
frank
Edited by: Julius Bussche on Dec 10, 2008 11:47 AM
12-10-2008 10:37 AM
Hello frank,
Check the DB table design and find if you are using unique primary keys or not..
Edited by: Sandeep Kumar on Dec 10, 2008 4:07 PM
12-10-2008 10:38 AM
Hi,
if you don´t define it as an key and you have allways the same field in the excel-shield, sap identify it as the same record and update it instead of insert
Regards
Nicole
12-10-2008 10:38 AM
Hi
What doesn "But when i converted a key field of the database table into a non-key field" mean?
Probably the problem is here, check all values of the keys: u make sure they are correct.
Max
12-10-2008 10:50 AM
Hi Max,
What i meant was initially the ZTABLE that i am updating had PERNR as the key field. Later on, i changed PERNR to a non-key field and this occured. What could be the problem with that??
Kindly help
Thanks and regards,
frank
12-10-2008 10:57 AM
Hi
So now which is/are the key fields for your ZTABLE?
If now there's only MANDT as key field u can store only one record: that could explain why u can update the data of the last record of your file.
Max
12-10-2008 10:42 AM
Hi,
If you have one primary key you can have only one reocrd for each unique value
if you have 2 primary key fields you can have n number of records for the first field as long as the value of second field is unique. and it goes on so.
if you have 3 primary key fields you can have n number of records for the first 2 fields as long as the value of 3 key field is unique and it goes on
Please check key field combination carefully
Best Regards
Ramchander Rao.K
12-10-2008 10:46 AM
hi Frank
There should be two ways
1.) MODIFY <table> from TABLE itab.
2.)MODIFY DBTAB/ (DBTAB) FROM WA/ITAB.
(DBTAB) -
represents dbtab at runtime
The MODIFY statement inserts one or several lines specified in source in the database table specified in target, or overwrites existing lines.
System fields
The MODIFY statement sets the values of the sy-subrc and sy-dbcnt system fields.
Regards
Sachin