cancel
Showing results for 
Search instead for 
Did you mean: 

commit matrix changes

Former Member
0 Kudos

Hi, I have to panes: Pane1, Pane2 with it a matrix each one.

When Pane1 is active I add rows to the matrix from pane2 (matrix2). But for the changes be made persisten to the database I need to change to the Pane2 and click the Update button. How can I commit these changes without having to click the Pane2 and clicking the update button?

I called the method FlushToDataSource from the matrix object with no results.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

former_member201110
Active Contributor
0 Kudos

Hi Rassiel,

Welcome to the forums.

We'll need to know some more information on what data you are trying to update before your question can be answered. Are you linking your form to a UDO, UDT or system data via the DBDataSource?

The FlushToDataSource method has no affect on the database, it just updates the values shown in the matrix on the client. If you are wanting to update a UDO then there is currently no way to directly update the UDO tables unless you click on the Update button on the form (or course, you could use the UI API to automatically click the button to force an update after you have changed values in the matrix). If you are wanting to update system data then you must use the relevant DI API object. If you are using data from a UDT, you can use the UserTables object to update the table (or send an update statement using the Recordset object, although this method is frowned upon by SAP).

Kind Regards,

Owen

Former Member
0 Kudos

Thanks, I solved it using the DBDataSources object.

Former Member
0 Kudos

I thought I solved it using dbdatasources but it didn't.

My form is linked to an UDO.

I tried insertrecord using the dbdatasources object but it doesn't commit the changes to the DB.

After I insertrecords I call matrix1.LoadFromDataSource() and it works ok except it doesn't save the changes to the db.

I have a list with the items I want to add. Try to figure out the missing code:

First approach:

For Each items1 As Matrix1Items In lst
                Dim value As String = _
                        DirectCast(matrix1.Columns.Item(MatrixColumns.mtx1NoReq).Cells.Item(matrix1.RowCount).Specific, EditText).Value.Trim()
                If Not (String.IsNullOrEmpty(value)) Then
                    matrix1.AddRow()
                End If
                SetRowColumnValue(matrix1, matrix1.RowCount, MatrixColumns.mtx1NoLinea, items1.NoLinea.ToString())
                SetRowColumnValue(matrix1, matrix1.RowCount, MatrixColumns.mtx1CantTransferida, items1.cantTransferida.ToString())
                SetRowColumnValue(matrix1, matrix1.RowCount, MatrixColumns.mtx1ItemCode, items1.itemCode.ToString())
                SetRowColumnValue(matrix1, matrix1.RowCount, MatrixColumns.mtx1CodTransfStock, codTransStock)
                SetRowColumnValue(matrix1, matrix1.RowCount, MatrixColumns.mtx1LineId, matrix1.RowCount.ToString())
                matrix1.FlushToDataSource()
Next

this approach works ok except I have active Pane1, click on a button, for example, the I add the rows to the other matrix on Pane2, and if I doesn't make the other Pane active, it doesn't save the changes, I guess becasu the matrix is not visible so the form is still in OK mode.

2nd approach:

Dim db As DBDataSource = form.DataSources.DBDataSources.Item("@SCGPR_REQ_TRANSF")
            For Each items1 As Matrix1Items In lst
                Dim value As String = db.GetValue("U_LineNum", db.Size - 1).Trim()
                If Not (String.IsNullOrEmpty(value)) Then db.InsertRecord(db.Size)
                db.SetValue("U_LineNum", db.Size - 1, items1.NoLinea.ToString())
                db.SetValue("U_Cantidad", db.Size - 1, items1.cantTransferida.ToString())
                db.SetValue("U_ItemCode", db.Size - 1, items1.itemCode)
                db.SetValue("U_CdTransf", db.Size - 1, codTransStock)
                db.SetValue("LineId", db.Size - 1, db.Size.ToString())
                db.SetValue("DocEntry", db.Size - 1, docEntry.ToString())
    Next

after this I call matrix2.LoadFromDataSource()

this works ok. I loads the matrix with the new values, but I can't find a way to commit these changes into de DB.

I hope I made myself more clear. Thanks.

Answers (0)