on 06-05-2013 7:32 AM
Dear Experts,
I need your help in one of my question. When I update my user defined form having matrix in it, I generally get an error that 'This Entry already Exist'. I discussed this problem with one of my friend & he suggested me that I should delete the matrix data first & then try to update. He gave me a solution something like this :
Delete From ChildTableName Where code = 'AnyCode'
But I have read somewhere that we should not do that Delete & update by query. But I have seen in SDK help samples to use the Update query in Blanket agreement sample. So can you please tell me whether it is right to use this query in this way or not.
Else tell me if there is something else through which I can delete the matrix data first & my database also does not get corrupted. I want to delete the matrix data because through this I am able to update properly.
Please give your valueable suggestion.
Regards
Hi Amit,
The cause of error is indeed a duplicate record in the DB.
But the question should be 'Why is there a duplicate record ?'
The fix should be targeted to the question. Not by simply removing the record in the DB.
Any record modifying query is not allowed.
My suggestion is, you should debug your program and answer the question first,
then you can decide on what your solution is.
Most problem would lies in wrong Unique ID numbering in your matrix, or binding the LineNum to the Matrix's line number column.
I have never delete any record just to get by this error message.
Regards
Edy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi. Amit
What Edy says is currect
have a look on this post
may be it will be helpful
the main cause is duplicate records..
Hi Amit,
I am sorry, I thought you had get by this already.
Can you replicate this error? I will try to guide you on trouble shooting this.
When you encounter this problem, i need few information as a start :
1. a Screenshot of your screen with the detail row shown clearly and the error message.
2. Query your child table and post the screenshot of this.
3. I need you to create an event handler On Before Form Data Add and put this code inside :
Dim db As SAPbouiCOM.DBDataSource = form.DataSources.DBDataSources.Item("DetailTableName")
For i As Integer = 0 To db.Size - 1
System.Diagnostics.Debug.WriteLine(String.Format("Line {0} : Code = {1} ; LineID = {2}", i + 1, db.GetValue("Code", i), db.GetValue("LineId", i)))
Next
Take a screen shot of the result of the codes here also.
Regards
Edy
Hi Amit,
Post your sbo screen here for us to see what you are doing.
The third point, you need to insert the codes i gave you in your projects.
It should print out some values on your debug window after you click on the update button.
Take a screen shot of your debug window and post here.
Your problem is data problem, so what we need to do is analyze the data and provide a fix on what cause the data.
Regards,
Edy.
When I tried following code on update mode in BeforeAction = true
My SAP is not responding.
Regards
Hi Amit,
Ok, so your code should look like this :
oMatrix.FlushToDataSource()
Dim db As SAPbouiCOM.DBDataSource = form.DataSources.DBDataSources.Item("@ITEMDETAIL")
For i As Integer = 0 To db.Size - 1
System.Diagnostics.Debug.WriteLine(String.Format("Line {0} : Code = {1} ; LineID = {2}", i + 1, db.GetValue("Code", i), db.GetValue("LineId", i)))
Next
Run it, it should print something in your immediate/Output window of Visual Studio.
Copy the output and paste it here.
+ Query the SQL server : "SELECT * FROM [@ITEMDETAIL] WHERE Code = 'Give your code for the records here'.
Post the ScreenShot of the result here.
Regards
Edy
I also tried your code. But it is coming into the for loop. While there are 5 rows in the matrix. I have tried this :
oMatrix.FlushToDataSource();
SAPbouiCOM.DBDataSource db = form.DataSources.DBDataSources.Item("@Service_Detail_I");
for (int i = 0; i <= db.Size - 1; i++) {
System.Diagnostics.Debug.WriteLine(string.Format("Line {0} : Code = {1} ; LineID = {2}", i + 1, db.GetValue("Code", i), db.GetValue("LineId", i)));
}
While here is the record query..
Please reply...
Regards
I think you have not seen my comment sir. When I am writing these line
for (int i = 0; i <= db.Size - 1; i++)
{
System.Diagnostics.Debug.WriteLine(string.Format("Line {0} : Code = {1} ; LineID = {2}", i + 1, db.GetValue("Code", i), db.GetValue("LineId", i)));
}
In any condition my code is not entering into the for loop..
Please suggest.
Regards
Hi Amit,
I read your comment :
'I also tried your code. But it is coming into the for loop.'
You said it is coming into the for loop. that's why I asked you.
If it is not coming into the loop. You need to debug why it is not coming into the loop.
It will not go into loop if db size is 0. Which is impossible when you say you have 5 detail lines.
Did you check on the correct dbdatasource ?
Is the matrix bound to the correct dbdatasource ?
anyhow, it should go into the loop.
When you have the result of the loop, post it here.
Regards
Edy
Hi Amit,
You just need to pt your code here. So that it will be easy to understand what you are trying to do & where the problem lies. ?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amit,
In my opinion if you try to modify SAP tables then you are violating the SAP support rules.
Your any action shouldn't involve a direct updation, deletion or insertion in SAP tables.
I you tables i think you can.
What you are doing when you press the update button ?
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pari,
Till now, on BeforeAction = True, I was deleting all the record from the child table against a particular code. Thats it.
But Edy & Ankit & even you have told that its not a good idea to do this way. Can you please help me what should I do for this ? What do you do for this problem. ?
Regards
Hi Amit,
As far as I know about SAP SDK, You should not use an query just for modifying any record in the table. This will void your SAP support.
Hope it helps.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
110 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.