Skip to Content
0
May 21, 2012 at 07:07 AM

DBDatasource in a user form not filtering

163 Views

Hi,

I need help in figuring out how to filter the display of the user form to certain records depending on their assigned access. I have created a user form through the use of the screen painter. The user form is divided into two sections. One header and one detail, much like the way marketing documents are displayed. Each of the header edit fields has been binded to a UDO field. The detail is a matrix and likewise binded to UDT columns.

Once the form is triggered from the menu event, the script below kicks in:

oDS0 = oForm.DataSources.DBDataSources.Item("@OB_PRQ")

If oMyUserInfo.SecurityLevel = 1 Or oMyUserInfo.SecurityLevel = 2 Then

If oMyUserInfo.SecurityLevel = 1 Then

'oConditions = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_Conditions)

oConditions = New SAPbouiCOM.Conditions

oCondition = oConditions.Add

oCondition.BracketOpenNum = 1

oCondition.Alias = "U_REQBY"

oCondition.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL

oCondition.CondVal = oMyUserInfo.username

oCondition.BracketCloseNum = 1

oDS0.Query(oConditions)

Else

'oConditions = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_Conditions)

oConditions = New SAPbouiCOM.Conditions

oCondition = oConditions.Add

oCondition.Alias = "U_DEPTID"

oCondition.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL

oCondition.CondVal = oMyUserInfo.deptid

oDS0.Query(oConditions)

End If

End If

oDS1 = oForm.DataSources.DBDataSources.Item("@OB_PRQ1")

If oMyUserInfo.SecurityLevel = 1 Or oMyUserInfo.SecurityLevel = 2 Then

If oMyUserInfo.SecurityLevel = 1 Then

'oConditions2 = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_Conditions)

oConditions2 = New SAPbouiCOM.Conditions

oCondition2 = oConditions2.Add

oCondition2.Alias = "U_UserSign"

oCondition2.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL

oCondition2.CondVal = oMyUserInfo.userid

oDS1.Query(oConditions2)

Else

'oConditions2 = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_Conditions)

oConditions2 = New SAPbouiCOM.Conditions

oCondition2 = oConditions2.Add

oCondition2.Alias = "U_DEPTID"

oCondition2.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL

oCondition2.CondVal = oMyUserInfo.deptid

oDS1.Query(oConditions2)

End If

End If

Then the form opens in "find mode". When I clicked the next record button, the user form still shows all the records of UDO/UDT despite the condition was successfully executed above with no error. Any ideas what is wrong with my code?