cancel
Showing results for 
Search instead for 
Did you mean: 

Update matrix system form

Former Member
0 Kudos

Dear SAP experts,

I am trying to edit the matrix of a system form (Sales Order) through a bespoke Add-On.

I successfully managed to add and delete items, but for some reason, the totals are not recalculated. They still show the original totals before the update. I'd rather leave this to the system instead of doing it myself.

I tried to execute the Matrix's method 'FlushToDataSource()' but no luck (it gives me an error 'The item is not a user defined item 66000-8').

I also tried (naïvely) to refresh the form itself.

How can I achieve this and also to commit the changes to the database?

Using SAP B1 8.81 / C#

Regards.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Please post the method/procedure code in which you are trying to accomplish this. From what I've seen, usually when you get an error like that, it means that you're trying to reference a column/row by using a hard coded index value that's different from the column/row that you actually want to update. I do that all the time, and have started to use the IndexOf function instead of hard coding indices to avoid the issue.

Former Member
0 Kudos

Dear Westley,

In a nutshell, it is as follows:


Matrix oMatrix;

oMatrix = (Matrix)SBO_Application.Forms.ActiveForm.Items.Item("38").Specific;

oMatrix.DeleteRow(1);

// Update the totals in the form here. How?

Regards.

Former Member
0 Kudos

Found a similar thread which describes exactly the same problems I have:

http://scn.sap.com/thread/3274451

former_member185682
Active Contributor
0 Kudos

Hi Nicolas,

There is an workaround similar that suggest in thread that you find.

Try something like this:

1. Set focus to the line that you need delete

oMatrix.Columns.Item("select an id of some cell - preference the item code").Cells.Item(line).Click();

2. Call the menuItem DeleteRow

SBO_Application.ActivateMenuItem("1293");

For save your document, you can simulate the user click in add button, like this:

SBO_Application.Forms.ActiveForm.Items.Item("1").Click();

P.S: I suggest that you insert your sales order by DI API if is possible.

Hope it helps,

Diego

Former Member
0 Kudos

That made the trick

Answers (1)

Answers (1)

0 Kudos

try with

oMatrix.Clear()

oColumn.DataBind.UnBind()

oColumn.DataBind('DATASOURCE','DATASOURCE-ALIAS')

oMATRIX.LoadFromDataSource()

regards

Helene

Former Member
0 Kudos

Dear Helene,

Many thanks for your answer.

The solution you propose seems to load from the data source to the form matrix, but I'd like to achieve exactly the oposite: the changes made in the matrix to trigger an update in the form and to commit the changes to the database.

Best regards.