on 10-09-2008 10:29 AM
Hi,
I created UDO with master table and child table and when I tried to execute on it a dbdatasource query I got this error Data source - Invalid table name [66000-7]. When I tried this query on system table it works perfectly, so I don't know where is the problem (it looks like DBDataSources.Query doesn't work on user tables).
My code:
oDBDataSources = oForm.DataSources.DBDataSources.Add("@MyTable");
oConditions = (SAPbouiCOM.Conditions)(SBO_Application.CreateObject(BoCreatableObjectType.cot_Conditions));
oMatrix = (SAPbouiCOM.Matrix)(oForm.Items.Item("mtx_dzial").Specific);
oCondition = oConditions.Add();
oCondition.BracketOpenNum = 1;
oCondition.Alias = "U_MyDate";
oCondition.Operation = BoConditionOperation.co_BETWEEN;
oCondition.CondVal = "2008/10/01";
oCondition.CondVal = "2008/10/06";
oCondition.BracketCloseNum = 1;
oDBDataSources.Query(oConditions);
Regards
Ela
Hi
Check in your VB Code these lines:
-
WRONG
oCondition.CondVal = "2008/10/01";
oCondition.CondVal = "2008/10/06";
RIGTH
oCondition.CondVal = "2008/10/01";
oCondition.CondEndVal = "2008/10/06";
Try to verify your code.
Regards
Sierdna S.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
BEFORE ALL POINTS BELOW ...try to use this line ...
oForm.DataSources.DBDataSources.Item("@MyTable").Query(oConditions)
1) You need to verify Date Format... It's may be probable point of the first check.
2) Try to use SQL Server Tool: SQL Profiler to see (trace) the query what are you making.
See comments in your code below.
oDBDataSources = oForm.DataSources.DBDataSources.Add("@MyTable");
oConditions = (SAPbouiCOM.Conditions)(SBO_Application.CreateObject(BoCreatableObjectType.cot_Conditions));
oMatrix = (SAPbouiCOM.Matrix)(oForm.Items.Item("mtx_dzial").Specific);
oCondition = oConditions.Add();
oCondition.BracketOpenNum = 1;
oCondition.Alias = "U_MyDate";
oCondition.Operation = BoConditionOperation.co_BETWEEN;
oCondition.CondVal = "2008/10/01";
oCondition.CondVal = "2008/10/06";
oCondition.BracketCloseNum = 1;
' POST 1" BREACKPOINT HERE: Switch "ON" tracing...after press F5 in Visual Studio...
oDBDataSources.Query(oConditions);
' POST 2" BREACKPOINT HERE: Switch "OF" tracing.
Dim s = ""
Regards
Sierdna S.
Edited by: Sierdna S on Oct 9, 2008 2:38 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Look here the working example...
Hope it can help you.
Public Sub SBO_CreateForm()
Dim oForm As SAPbouiCOM.Form
Try
Dim sUniqueID As String = "O99_" & Microsoft.VisualBasic.Format(Now.Millisecond, "0000")
Dim sFormXmlFile As String = "MY_FORM_FILE.xml"
' Search for this function on this forum...
Call ReplaceUIDandLoadToB1(sFormXmlFile, sUniqueID)
oForm = SBO_Application.Forms.Item(sUniqueID)
Call Matrix_SetConditions(oForm)
oForm.Visible = True
Catch ex As Exception
If Not oForm Is Nothing Then
oForm.Close()
oForm = Nothing
End If
Finally
System.GC.Collect() 'Release the handle to the table
End Try
End Sub
Private Sub Matrix_SetConditions(ByRef oForm As SAPbouiCOM.Form)
Dim oMatrix As SAPbouiCOM.Matrix
Dim oConditions As SAPbouiCOM.Conditions
Dim oCondition As SAPbouiCOM.Condition
Try
oMatrix = oForm.Items.Item("mtx00").Specific
If oMatrix Is Nothing Then Throw New Exception("ERROR!...")
oConditions = SBO_Application.CreateObject(BoCreatableObjectType.cot_Conditions)
' ++++++++++++++++++++++++++++++++++++++++++++
If Not sItem1.Equals("") And Not sItem2.Equals("") Then
'// AND (P.U_CodItem BETWEEN '" & s1.Trim & "' AND '" & s2.Trim & "')"
oCondition = oConditions.Add
oCondition.BracketOpenNum = 1
oCondition.Alias = "U_CodItem"
oCondition.Operation = co_BETWEEN
oCondition.CondVal = sItem1
oCondition.CondEndVal = sItem2
oCondition.BracketCloseNum = 1
Else
If Not sItem1.Equals("") Then
'// AND P.U_CodItem = '" & s1.Trim & "'"
oCondition = oConditions.Add
oCondition.Alias = "U_CodItem"
oCondition.Operation = co_EQUAL
oCondition.CondVal = sItem1.Trim
End If
If Not sItem2.Equals("") Then
'// AND P.U_CodItem = '" & s1.Trim & "'"
oCondition = oConditions.Add
oCondition.Alias = "U_CodItem"
oCondition.Operation = co_EQUAL
oCondition.CondVal = sItem2.Trim
End If
End If
' other conditions ....
'// Execute the query with the conditions collection
oForm.DataSources.DBDataSources.Item("@O99_MY_TABLE_NAME_HERE").Query(oConditions)
oMatrix.LoadFromDataSource()
oMatrix.SelectionMode = BoMatrixSelect.ms_Single
Catch ex As Exception
' log exception here
Finally
If Not oConditions Is Nothing Then If oConditions.Count > 0 Then glo_Conditions = oConditions
System.GC.Collect()
End Try
End Sub
In the xml file of my form I have added dbdatasource:
<datasources>
<dbdatasources>
<action type="add">
<datasource tablename="@O99_MY_TABLE_NAME_HERE"/>
</action>
</dbdatasources>
I has also tryed to change for your case UseMatrix project in "06.MatrixAndDataSources" example of SDK Samples.
The query doen't give the problem.
I added a table MyTable (Master_Data) and has defined as an UDO.
I have also added to the attribute table MyData type Date-Tiem / Date.
Try to verify matrix columns to table attributes binding.
Especialy look this line: oColumn.DataBind.SetBound(True, "@MyTable", "Code") where Table Name shoud be with @.
Public Sub BindDataToForm()
'// getting the matrix column by the UID
''//************************************************
''// to Data Bind an item with a user Data source
''// the table name value should be an empty string
''//************************************************
'oColumn = oColumns.Item("DSPhoneInt")
'oColumn.DataBind.SetBound(True, "", "IntPhone")
oColumn = oColumns.Item("Code")
'oColumn.DataBind.SetBound(True, "", "DSCardCode")
oColumn.DataBind.SetBound(True, "@MyTable", "Code")
oColumn = oColumns.Item("Name")
'oColumn.DataBind.SetBound(True, "", "DSCardCode")
oColumn.DataBind.SetBound(True, "@MyTable", "Name")
oColumn = oColumns.Item("MyData")
'oColumn.DataBind.SetBound(True, "", "DSCardCode")
oColumn.DataBind.SetBound(True, "@MyTable", "U_MyData")
End Sub
Also when you get data from database:
Public Sub GetDataFromDataSource()
'// Ready Matrix to populate data
oMatrix.Clear()
oMatrix.AutoResizeColumns()
Dim oConditions As SAPbouiCOM.Conditions = _
SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_Conditions)
Dim oCondition As SAPbouiCOM.Condition
oCondition = oConditions.Add()
oCondition.BracketOpenNum = 1
oCondition.Alias = "U_MyData"
oCondition.Operation = SAPbouiCOM.BoConditionOperation.co_BETWEEN
oCondition.CondVal = "01-01-2008"
oCondition.CondEndVal = "31-12-2008"
oCondition.BracketCloseNum = 1
'// Querying the DB Data source
oDBDataSource.Query(oConditions)
''// setting the user data source data
oMatrix.LoadFromDataSource()
End Sub
Regards
Sierdna S.
User | Count |
---|---|
85 | |
7 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.