on 10-08-2007 5:54 AM
Hi all,
I ' ve used choose from list in User defined form to fill GRPo No.
The choose from list working fine but when I press "Cancel" button in choose from list the following error message is displays.
"Object reference not set to an instance of an object".
Let me know please, what is the problem and it would be appreciated.
I ' ve used the following code.
Private Sub AddChooseFromList()
Try
Dim oCFL As SAPbouiCOM.ChooseFromList
Dim oCons As SAPbouiCOM.Conditions
Dim oCon As SAPbouiCOM.Condition
Dim emptyCon As New SAPbouiCOM.Conditions
Dim rs As SAPbobsCOM.Recordset = Ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
rs.DoQuery("SELECT t0.docnum, t0.docdate,t0.cardcode FROM OPDN T0 WHERE T0.DOCNUM not in(SELECT U_grnno FROM [dbo].[@PSSIT_CONSHDR])")
oCFL = Oform.ChooseFromLists.Item("GRN1")
oCFL.SetConditions(emptyCon)
oCons = oCFL.GetConditions()
For i As Integer = 0 To rs.RecordCount - 1
If i = (rs.RecordCount - 1) Then
oCon = oCons.Add()
oCon.Alias = "docnum"
oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL
oCon.CondVal = Trim(rs.Fields.Item(0).Value)
Else
oCon = oCons.Add()
oCon.Alias = "docnum"
oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL
oCon.CondVal = Trim(rs.Fields.Item(0).Value)
oCon.Relationship = SAPbouiCOM.BoConditionRelationship.cr_OR
End If
rs.MoveNext()
Next
oCFL.SetConditions(oCons)
Catch
MsgBox(Err.Description)
End Try
End Sub
Thanks & Regards,
Venkatesan G.
Hi VG,
in the CFL-Event NOT BeforeAction you get a DataTable from ItemEvent (or IChooseFromListEvent).SelectedObjects.
If this returns Nothing (Is Nothing) instead of a DataTable then you should exit your EventHandler immediatly.
I've also missed that in CFL-SAP-examples...
Message was edited by:
Roland Toschek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Venkatesh,
Try this code,,
Dim oCFL As SAPbouiCOM.ChooseFromList
Dim CFLEvent As SAPbouiCOM.IChooseFromListEvent = pVal
Dim CFL_Id As String
CFL_Id = CFLEvent.ChooseFromListUID
oCFL = PE_Form.ChooseFromLists.Item(CFL_Id)
Dim oDT As SAPbouiCOM.DataTable
oDT = CFLEvent.SelectedObjects
Try
<b> If Not (oDT Is Nothing) And pVal.BeforeAction = False Then
If oCFL.UniqueID = "CFL1" Then
' Write your code here.
End if
End if
</b>
Catch ex as Exception
app.MessageBox (ex.Message)
End Try
If Your problem sloved!! . Give me reward points
Regards,
G.Suresh
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.