cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

DBDataSource Update?

Former Member
0 Likes
1,220

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

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.

Former Member
0 Likes

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

Former Member
0 Likes

Thank For Your Info Frank, I should have tried SDK2004, i guess.But I can try it until SBO 2004/6.7 is really released to Public.

Former Member
0 Likes

Hi Hamdi,

Version 2004 A / 6.7 has been released on Dec 17th 2004.

SAP B1 can be downloaded from Service Marketplace (please read the setup guide...); SDK 2004 documentation has to be ordered as a CD.

Regards,

Frank

S0003325515
Newcomer
0 Likes

Hello Frank

I tried it at the last 20 day's and i can say it doesn't work in my version of SDK(B12004A00P_7-10002632). Please give use a little example. I will tried it, i am far from believing it.

bye Michi

Former Member
0 Likes

Hi Frank, you have an example the

LoadFromDataSource

and

FlushToDataSource.

something as which wrote "Choi" in the first post

thanks.

Jorge Benitez

Axis Group

Former Member
0 Likes

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

Former Member
0 Likes

Regarding Michael's post:

Please note that there are restrictions for "system forms" (see SDK 2004 UI helpfile: "How to..." section)!

I suppose that's why you think it wouldn't work...

HTH,

Frank

Answers (0)