cancel
Showing results for 
Search instead for 
Did you mean: 

Adding condition when using DBDataSource

Former Member
0 Kudos

hi

i want to add our custom form controls directly to the database table using DBDataSource, It fetches all the data that exist in the particular table. <b>But if i want some filter condition on the data, how we can add it????</b>

If any sample then plz send...

Thx.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You can find this very good example in the UI API reference/help file :

Set oConditions = New SAPbouiCOM.Conditions

'// Let's assume we wish our query to select

'// Bussines Partners of type "C" (Customers)

'// or "S" (Suppliers)

'// WHERE ((CardType = 'C') Or (CardType = 'S'))

'// the conditions collection encapsulates the WHERE clause

'// of a select statement

Set oCondition = oConditions.Add

'// ((CardType = 'C') Or

oCondition.BracketOpenNum = 2

oCondition.Alias = "CardType"

oCondition.Operation = co_EQUAL

oCondition.CondVal = "C"

oCondition.BracketCloseNum = 1

oCondition.Relationship = cr_OR

Set oCondition = oConditions.Add

'// (CardType = 'S'))

oCondition.BracketOpenNum = 1

oCondition.Alias = "CardType"

oCondition.Operation = co_EQUAL

oCondition.CondVal = "S"

oCondition.BracketCloseNum = 2

'// Execute the query with the conditions collection

oDBDataSource.Query oConditions

Former Member
0 Kudos

hi

thx to reply. This is fine but i <b>want to use join on different table</b>. Is this possible that a form having different DBDataSource so that we can add condition on different tables of Database. If yes then how ????

Thx

Former Member
0 Kudos

DBDataSource object is very limited.

In the conditions you only can set the 'WHERE' statement. Maybe the is a 'trick' but i don't think that it is possible to make a join in DBDataSources.

The Problem is that you can have more than one Datasource in a form but you can only link one to a matrix.

DBDataSource was made for browsing only.

Answers (1)

Answers (1)

AlexGrebennikov
Active Contributor
0 Kudos

Hi Pankaj!

I had the same issue in the beginning of the year. You can learn more about my issue and find a solution at