cancel
Showing results for 
Search instead for 
Did you mean: 

Need your assistance

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

edy_simon
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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..

This entry all ready exists in the following table...

Former Member
0 Kudos

Hi Edy,

Thanks for your reply... but can you please explain me now what can I do now? What do you prefer in this situation. ?

I have attached my child table structure. While I have not bind the matrix's line number column to any field of the table. Plz help me.

Former Member
0 Kudos

Hi,

Plz reply to my question..Still no success...

Regards

edy_simon
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Edy,

attached is the detail required.

Here is the structure of child table:

Please help me to solve this problem.

Plz its uregent.

Regards

edy_simon
Active Contributor
0 Kudos

Hi Amit,

Can you attach the screenshot of the SBO screen when the error occurs?

And also 'Point 3' of my previous post ?

Regards
Edy

Former Member
0 Kudos

Hi Edy,

When I update the form data having matrix on it. Then i get the error tht This entry already exist.

I have not tried your point no. 3 because i didn't got it. can you please explain me that. ?

I need an solution for this urgently. I am stuck on it.

Regards

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Amit,

If I am not wrong, Edy is trying to debug the Code & LineId value on the form data add event. Meanwhile, Edy can explain you better.

Thanks

edy_simon
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

Hi

When I tried following code on update mode in BeforeAction = true

  1. Dim db As SAPbouiCOM.DBDataSource = form.DataSources.DBDataSources.Item("DetailTableName"
  2.             For i As Integer = 0 To db.Size - 1 
  3.                 System.Diagnostics.Debug.WriteLine(String.Format("Line {0} : Code = {1} ; LineID = {2}", i + 1, db.GetValue("Code", i), db.GetValue("LineId", i))) 
  4.             Next 

My SAP is not responding.

Regards


edy_simon
Active Contributor
0 Kudos

Hi Amit,

If you need to replace the 'DetailTableName' with your actual child table name.

Regards,

Edy

Former Member
0 Kudos

Hi ,

I have changed my child table name too. Child table name is [@ITEMDETAIL]

Regards

edy_simon
Active Contributor
0 Kudos

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


Former Member
0 Kudos

Hi   Sir,

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

edy_simon
Active Contributor
0 Kudos

Hi Amit,

Post me the result of your System.Diagnostics.Debug.WriteLine.

Copy from your VS Immediate Window / Output window and paste it here.

Regards

Edy

Former Member
0 Kudos

Hi Sir,

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


edy_simon
Active Contributor
0 Kudos

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


Former Member
0 Kudos

Hi Sir,

I have checked everything sir. DbDataSource is correct, matrix is also bound to correct DbDataSource.

But still no success. While it showing db.size = 5

Please help to find..

Regards

edy_simon
Active Contributor
0 Kudos

Hi Amit,

Go to your project property

Go to the Build folder.

Check the check boxes beside 'DEFINE DEBUG CONSTANT' and 'DEFIND TRACE CONSTANT'


Regards

Edy

Answers (3)

Answers (3)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

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