Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

choose from list problem

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.

Former Member
Former Member replied

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

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question