cancel
Showing results for 
Search instead for 
Did you mean: 

Matrix Load not saved Data

Former Member
0 Kudos

Hi all,

I have an UDO with Masterdata and Masterdata Lines.

Loading existing Data is ok and as well Adding a Record (not stored) will be shown in the Matrix.

But then Adding a Record to Masterdata Table , generate a Record into the Lines Table.

Know I want to show the Records, they are not stored at this time, in the Matrix.

But I have not found a solution to show the LinesTable Record to the Matrix.


IMatrix oMatrix = MatrixObject;

          

            //oMatrix.AddRow(1, -1);

            IDBDataSource Con1 = LinesDatasourceObject;

            IDBDataSource ZCON = MasterDatasourceObject;

            int count1 = Con1.Size; // = 1

            int count2 = ZCON.Size; // = 1

           

            //oMatrix.Clear();

          

            oMatrix.LoadFromDataSource();

int count3 = oMatrix.RowCount; //= 0

Are there any Ideas?

Regards

Oliver

Accepted Solutions (1)

Accepted Solutions (1)

pedro_magueija
Active Contributor
0 Kudos

Hi Oliver,

I'm not sure I understood your question, but I'll try to answer it.

Your form should be linked to your UDO and your matrix should be bound with the "Lines" table.

When this is the case the navigation (loading of records from the DB) is automatic and you can see them in the matrix.

In a matrix object you have to bind each column to the correct field. You can use the Databind of the Column object in the Columns collection.

There is a sample that demonstrates how to bind grid and matrix (C:\Program Files (x86)\SAP\SAP Business One SDK\Samples\COM UI\CSharp\26. MatrixAndGridFeatures). Look for the cmdAddMat_Click method.


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn

Former Member
0 Kudos

Hi Pedro,

Yes I know. Thanks. This works for Search and Update perfect. Now it comes to ADD Mode.

The Add Mode generate a Record in DBDatasource Master and one into DBDatasource Line.

There I set the Code to a new value.... Up to this everything is OK. But now I want to display the added Row ( Through automatic ADD) in DBDatasource of the Line Table to the Matrix. At this Time I  won't save the Record to DB. Like the behavior of ex. Order etc.

I like to work on this added sentence up to the Save (Add) time... but at it seams, there is no way adding Lines or manipulating the rows of DBDatasource Lines up to this moment when the MasterRecord get saved to DB. After Saving to the DB everything works as expected... But not as Long the AddMode is present.

Then I try to Update my Matrix... thats the Code to my first Post... I check the Values of DBDatasources... both shows one Record...

But I'm not able to display this to the Matrix...

I hope my problem becomes more clear?

Best Regards

Oliver

pedro_magueija
Active Contributor
0 Kudos

Hi Oliver,

Do you mean you want to add several rows to the matrix (and to the underlying dbdatasource) but that you can't see them in the matrix?

If that is the case you can add a row to the matrix calling the matrix.AddRow. After filling it up you can call matrix.FlushToDataSource (this puts the data in the datasource).

You can also (or alternatively) use the matrix.GetLineData to do the same for one row:


Retrieves the data from a specified row and puts it into the bounded data source of the row.

Use this method to retrieve row data into the bounded data sources of the column. This allows you to work non-editable columns using data sources.

Syntax

Visual Basic

Public Sub GetLineData( _

  ByVal RowNum As Long _

)


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn

Former Member
0 Kudos

Hi Pedro,

yes or show only the first added Record into the Matrix.

GetLineData will end in an exemption.... (bad Row Index)

oMatrix.AddRow will work but it wont't be displayed in the Matrix.

as Well datasource:Insert Record works but it won't be shown as well...

it Looks like, that there is no connection between Matrix and Datasource at this time...

If the sentence is added finally,,, and load this again the Record will be displayed and  Addrow/Insertrecord work as expected... but not in AddMode....

oMatrix.GetLineData(0); or getlinedata(1); Exeption bad Row Index

oMatrix.FlushToDataSource();

oMatrix.LoadFromDataSource();

// oMatrix.AddRow(1, oMatrix.RowCount); -> this should be dispelled directly...

//or AddRow(1,0);

or...

Con1.InsertRecord(Con1.Size);

oMatrix.FlushToDataSource();

oMatrix.LoadFromDataSource();

That is my problem....

Regards

Oliver

pedro_magueija
Active Contributor
0 Kudos

Hi Oliver,

It's a bit difficult to say what might be the issue without more details.

How are you binding the columns of the matrix to the datasource?


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn

Former Member
0 Kudos

Hi Pedro,

it works fine for all other Modes... but not in Case of Form-Add Mode (automatic).

here you find a short one...

I


Column oIcolumn;

IColumns oIColumns;

IItem oIItem = this.SapObject.Items.Add("MTCount", SAPbouiCOM.BoFormItemTypes.it_MATRIX);

IMatrix oMatrix = ((IMatrix)(oIItem.Specific));

oMatrix.Layout = SAPbouiCOM.BoMatrixLayoutType.mlt_Normal;

oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Single;

oIColumns = oMatrix.Columns;

oIcolumn = oIColumns.Add("DSEntry", SAPbouiCOM.BoFormItemTypes.it_EDIT);

oIcolumn.TitleObject.Caption = "Entry";

oIcolumn.Width = 80;

oIcolumn.Editable = false;

oIcolumn.DataBind.SetBound(true, "@GFC_CON1", "Code");

etc.....

Regards

Oliver

Former Member
0 Kudos

Hi Pedro,

do you have some ideas to this? Or any ideas what I could do?

Best regards

Oliver

Former Member
0 Kudos

OK... know I get the Solution for it.

I try to understand the System Order Form. After Checking something in Sudio and have some test in the origin behavior I thought it could have something initializing the Lines... As I saw the Original Form... The Matrix will be initialized after inserting the Customer.

So in this case I build a temporary Docentry and pass this into the DBDatasource Lines. and make a reload to the Matrix... and this solve this issue...


IMatrix oMatrix = (Matrix)((IMatrixExt)this.Components["MTCount"]).Specific;

                IDBDataSource Con1 = (IDBDataSource)((IDbDataSourceExt)this.Components["DBCON1"]).Specific;

                IDBDataSource ZCON = (IDBDataSource)((IDbDataSourceExt)this.Components["DBZCON"]).Specific;

                int count1 = Con1.Size;

                int count2 = ZCON.Size;

                Con1.SetValue("Code", 0, RecNum);

                Con1.SetValue("LineId", 0, "1");

                oMatrix.LoadFromDataSource();

         


Thats it

Best regards

Oliver

Answers (0)