on ‎2005 Jan 05 4:57 AM
Hi All,
I'm Using SBO Version 2004 and Form designed by screen painter.
DBDataSource query sourcecode:
Set oCondition = oConditions.Add
oCondition.BracketOpenNum = 1
oCondition.Alias = "U_ECRNO"
oCondition.Operation = co_EQUAL
oCondition.CondVal = sEcrNo
oCondition.BracketCloseNum = 1
Set oDBDataSource = oForm.DataSources.DBDataSources.Item("@ECRD")
Set oMatrix = oForm.Items("13").Specific
oMatrix.Clear
oDBDataSource.Query oConditions
For i = 0 To oDBDataSource.Size - 1
If oDBDataSource.Size > i Then
oDBDataSource.Offset = i
oMatrix.AddRow
End If
Next i
End If
Problem : To update the data which is inquired in the MATRIX how?
Sorry for my bad english.
I need your help.
Thanks.
Request clarification before answering.
I've ever tried using DBDataSource to query data to Matrix but I think using DBDataSource isn't more flexible tha we're using UserDataSource that value generated from Recordset . I think it's more flexible to generate many output based on our requirement that we use condition since there're so many limitation using DBDataSource.But using UserDataSource + Recordset we'll spend more code line that we use DBDatasource.But using UserDataSource we can use "update" to user table object.I dont even try SDK 2004 but in 6.5 DBDataSource Limited to Add Mode Only.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
First of all:
As I replied in some other post before: DBDataSources are much more powerful in SDK 2004!
In SDK 2004 you don't have to loop over all records in the DBDataSource to get them into a matrix anymore.
Simply call the matrix object's LoadFromDataSource. That's all.
To get the data from the matrix back into the DBDataSource call FlushToDataSource.
When you want to update the data in the database, use either the user-defined object feature (there you get it "for free", but you have to define your table to be used with a UDO... - please check-out the UDO helpfile for more details) - or use Hamdi's approach.
I.e. either use UserDataSources + DI API's RecordSet or UserTable object or use DBDataSources + DI API's RecordSet or UserTable object. Please note that the UserTable object represents a record in a user-defined table (though its name says something different ).
HTH,
Frank
Hi,
This is nothing else, but some (adapted) code taken from SDK 2004 samples (06.MatrixAndDatasources + UIDIBasicApp/ VIDS)... + added the call to FlushToDataSource
Please check-out the SDK samples!!!
Regards,
Frank
*******************************************************
Public Sub FillMatrixFromDS(ByVal f As SAPbouiCOM.Form)
Dim oMatrix As SAPbouiCOM.Matrix
Dim oItem As SAPbouiCOM.Item
Dim oDBDataSource As SAPbouiCOM.DBDataSource
oItem = f.Items.Item("Matrix1")
oMatrix = oItem.Specific
'Get data source
oDBDataSource= f.DataSources.DBDataSources.Item("OCRD")
'// Prepare matrix to populate with data
oMatrix.Clear()
oMatrix.AutoResizeColumns()
'// Read the data from DB into DBDataSource
oDBDataSource.Query()
'// Populate matrix...
'//(only one call in 2004 (for DBDataSources)!)
oMatrix.LoadFromDataSource()
End Sub
*******************************************************
Private Sub FillDSFromMatrix(ByVal f As SAPbouiCOM.Form)
Dim oMatrix As SAPbouiCOM.Matrix
Dim oItem As SAPbouiCOM.Item
Dim oDBDataSource As SAPbouiCOM.DBDataSource
Dim i As Integer
Dim sValue As String
oItem = f.Items.Item("Matrix1")
oMatrix = oItem.Specific
'Get data source
oDBDataSource = f.DataSources.DBDataSources.Item("OCRD")
'// Flush user input into datasources
oMatrix.FlushToDataSource()
For i = 0 To oDBDataSource.Size - 1
sValue = oDBDataSource.GetValue("Phone1", i)
' do sth. with sValue (e.g. save it to the DB through
' the UserTable object) or set some other value...
'oDBDataSource.SetValue("Phone1", i, "???" & sValue)
Next i
' e.g. update matrix; freeze it, if necessary;
' if you do so, make sure that it is ALWAYS
' "unfreezed" to avoid confusing the user...
' Therefore => exception handling
'Try
' oForm.Freeze(True)
' here's the update of the matrix - in case we
' changed the datasource above...
' oMatrix.LoadFromDataSource()
'Catch ex As Exception
'Finally
' oForm.Freeze(False)
'End Try
End Sub
Message was edited by: Frank Moebius
| User | Count |
|---|---|
| 15 | |
| 15 | |
| 14 | |
| 9 | |
| 5 | |
| 4 | |
| 4 | |
| 2 | |
| 2 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.