Skip to Content
0
Former Member
May 28, 2008 at 06:34 AM

Update Master Data Lines Table from Grid

44 Views

Hia all, I need to update user defined tables of type Master Data (@XTSD_Rem_HDR) and Master Data Lines (@XTSD_Rem_LNS) from a form with header fields databound to the Master Data Table, and a grid that is supposed to represent the lines data.

The scenario is as follows:

I have a form designed in screen painter that closely resembles the SAP Business One Payment Wizard.

The form includes the following u201Cfeaturesu201D:

Object Type = User Defined Object that has a Master Data Table as its u201CTableu201D and a Master Data Lines table as child linked to it.

Settings-GridUID = My Invoices grid that is linked to a DataTable called u201C@XTSD_Rem_LNSu201D and populated by a stored procedure.

My problem is that the only way for me to actually add records to the lines table is by manually updating the DBDataSource values from the Gridu2019s datatable.

This is done on the Item Pressed before action for ItemUID 1.

And done as follows:

oDataTable = oForm.DataSources.DataTables.Item("MyInvTable") u2018-> This is the DataTable belonging to my grid and loadedu2019populated by my Stored Procedure
         x = oForm.DataSources.DBDataSources.Item(1).Size

For i = 0 To oDataTable.Rows.Count - 1
                    oForm.DataSources.DBDataSources.Item(1).InsertRecord(x)
                    oForm.DataSources.DBDataSources.Item(1).Offset = oForm.DataSources.DBDataSources.Item(1).Size - 1

                 oForm.DataSources.DBDataSources.Item(1).SetValue(0, i, WizHDR.RunCode) 'Code
                 oForm.DataSources.DBDataSources.Item(1).SetValue(1, i, i) 'LineNum
                 oForm.DataSources.DBDataSources.Item(1).SetValue(2, i, REM_UDO) 'ObjType
                 oForm.DataSources.DBDataSources.Item(1).SetValue(3, i, 0) 'LogInstance
                 oForm.DataSources.DBDataSources.Item(1).SetValue(4, i, oDataTable.GetValue("CardCode", i))
                 oForm.DataSources.DBDataSources.Item(1).SetValue(5, i, oDataTable.GetValue("Inv#", i))
next

SBO then inserts the new records correctly.

This works fine, but I have a major problem when wanting to Update records in my lines table.

Is there any way for me to make SBO handle the Add\Update seeing as a manual procedure is quite combersome if not impossible?

Clearly what is needed is a type of DataBind to marry the loaded DataTable, the UDO, and the actual User Defined Tables.

I just want the User Defined Header and Lines tables to be updated as it would if a matrix was used instead of a grid.

Note that I have to use a grid because it needs to collapsable.

Any help would be greatly appreciated.

Thanks guys.