‎2010 Jan 18 9:36 AM
Hi,
I am updating(or Insert) database table in a user - Exit, using MODIFY statement.
On a particualr date, they have created 100 documents. But, in that 96 documents are inserted into the Custom data base table. But, 4 documents are not inserted.
So, can you please tell me. what are the chances of a "MODIFY" statment can fail.
If the 2 users are inserting simultaneuously, is there any chance of fail in MODIFY?
I am not using any locks in my code.
I am not using an Commit work here as this is user exit.
Please help me.
Code :
MODIFY DBTAB from WA.
‎2010 Jan 18 9:54 AM
Hi Sandeep,
No Need for locks,
As MODIFY statement automatically sets a database lock until the next database commit or database rollback.
The Possible cause for not updating the records could be.
At least one line could not be processed as there is already a line with the same unique name secondary index in the database table.
means duplicay of records,
For ex 96 records are inserted so these 96 records contains unique entries in there primary key fields, rest 4 records doesn't contain unique entries in primary key fields.
for ex in table MSEG- document number is a key field, so you can not put same material number twice,
Kindly check your data which you are updating in your table, As key fields should have unique entries. This will definately solve your problem.
Thanks
Saurabh siwach
‎2010 Jan 18 9:50 AM
Modify statement updates the existing entries and inserts new entries.
You can check the sy-subrc value after modify statement.
‎2010 Jan 18 9:52 AM
Hello
1. You doing INSERT. If exist record with same key field your new record will not insert.
2. You doing MODIFY. If not exist record - line could not be updated.
‎2010 Jan 18 9:54 AM
Hi Sandeep,
No Need for locks,
As MODIFY statement automatically sets a database lock until the next database commit or database rollback.
The Possible cause for not updating the records could be.
At least one line could not be processed as there is already a line with the same unique name secondary index in the database table.
means duplicay of records,
For ex 96 records are inserted so these 96 records contains unique entries in there primary key fields, rest 4 records doesn't contain unique entries in primary key fields.
for ex in table MSEG- document number is a key field, so you can not put same material number twice,
Kindly check your data which you are updating in your table, As key fields should have unique entries. This will definately solve your problem.
Thanks
Saurabh siwach
‎2010 Jan 18 10:09 AM
Hi Sourabh,
Thanks for your reply.
I checked my entries. The document number is unique. So, there is no problem is Primary key.
So, if 2 users are simultaneously inserting into database, then because of these locks, is there any chance that, for the second user , the MODIFY can fail?
Thanks,
Sandeep
‎2010 Jan 19 5:24 AM
Hi Sandeep,
Yes If 2 users simeltaneously Modify records in standard table, Then Modify will fail for second user. SAP Suggests that there has to be a fraction of seconds difference between 2 modify on same standard table.
You can use Dequeue Function module to unlock the entries, BUt That is not the right approach and not recommended by SAP.
Thanks
Saurabh
‎2010 Jan 19 5:39 AM
sy-subrc Meaning for modify statement
0 At least one line was changed.
4 No lines were changed, since no suitable line was found for the insertion using the table key, or the specified index was greater than the current number of lines for the insertion using the table index.