cancel
Showing results for 
Search instead for 
Did you mean: 

Matix with query

Former Member
0 Kudos

Hi experts,

I want to fill my matrix with the result of my query. Here is my code, I do not know where the error but I get the following message: Collection - Out of boundaries.

If (pVal.ItemUID = "RechNav") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) Then

Dim f As SAPbouiCOM.Form

f = SBO_Application.Forms.Item("Liste_escale")

Dim oMatrix As SAPbouiCOM.Matrix = f.Items.Item("3").Specific

Dim req As SAPbobsCOM.Recordset

req = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

req.DoQuery("SELECT U_CdNav, U_NLloyd, U_NDclrNav, U_PavDN, U_Cng, U_AgCng, U_Arm, U_AgSh, U_DatArE, U_DateDep, U_TpOcPos, U_TImpt, U_TEmb FROM [@DESC] WHERE U_CdNav='" & TxtCodN.Value & "'")

Dim i As Integer = 0

oMatrix.FlushToDataSource()

With f.DataSources.DBDataSources.Item("DESC")

While (req.EoF = False)

oMatrix.SetValue("V_0", i, req.Fileds.Item("U_CdNav").Value.ToString)

oMatrix.SetValue("V_13", i, req.Fileds.Item("U_NLloyd").Value.ToString)

oMatrix.SetValue("V_12", i, req.Fileds.Item("U_NDclrNav").Value.ToString)

oMatrix.SetValue("V_11", i, req.Fileds.Item("U_PavDN").Value.ToString)

oMatrix.SetValue("V_10", i, req.Fileds.Item("U_Cng").Value.ToString)

oMatrix.SetValue("V_9", i, req.Fileds.Item("U_AgCng").Value.ToString)

oMatrix.SetValue("V_8", i, req.Fileds.Item("U_Arm").Value.ToString)

oMatrix.SetValue("V_7", i, req.Fileds.Item("U_AgSh").Value.ToString)

oMatrix.SetValue("V_6", i, req.Fileds.Item("U_DatArE").Value.ToString)

oMatrix.SetValue("V_5", i, req.Fileds.Item("U_DateDep").Value.ToString)

oMatrix.SetValue("V_4", i, req.Fileds.Item("U_TpOcPos").Value.ToString)

oMatrix.SetValue("V_3", i, req.Fileds.Item("U_TImpt").Value.ToString)

oMatrix.SetValue("V_2", i, req.Fileds.Item("U_TEmb").Value.ToString)

oMatrix.InsertRecord(i)

i = i + 1

req.MoveNext()

End While

End With

oMatrix.LoadFromDataSource()

End If

Edited by: Olivier KPOLO on Jun 8, 2010 1:16 PM

Edited by: Olivier KPOLO on Jun 8, 2010 1:23 PM

Edited by: Olivier KPOLO on Jun 8, 2010 1:24 PM

Edited by: Olivier KPOLO on Jun 8, 2010 1:27 PM

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Olivier,

You may check these threads for the error message:

Thanks,

Gordon

Former Member
0 Kudos

Hi,

Thanks for yur reply, but i get another error message: Row - Invalid index.

I don't know where is the error.

Regards

Olivier.

Former Member
0 Kudos

Hi...

Try tis code..

Dim str As String = ""

Dim oMatrix As SAPbouiCOM.Matrix

Dim req As SAPbobsCOM.Recordset

oMatrix = objForm.Items.Item("3").Specific

req = objMain.objUtilities.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

strQuery = "SELECT U_CdNav, U_NLloyd, U_NDclrNav, U_PavDN, U_Cng, U_AgCng, U_Arm, U_AgSh, U_DatArE, U_DateDep, U_TpOcPos, U_TImpt, U_TEmb FROM [@DESC] WHERE U_CdNav='" & TxtCodN.Value & "'"

req.DoQuery(strQuery)

If req.RecordCount > 0 Then

For i As Integer = 1 To req.RecordCount

oMatrix.Columns.Item("V_0").Cells.Item(i).Specific.String = req.Fields.Item("U_CdNav").Value

oMatrix.Columns.Item("V_13").Cells.Item(i).Specific.String = req.Fields.Item("U_NLloyd").Value

oMatrix.Columns.Item("V_3").Cells.Item(i).Specific.String = req.Fields.Item("").Value

oMatrix.Columns.Item("V_4").Cells.Item(i).Specific.String = req.Fields.Item("").Value

oMatrix.Columns.Item("V_5").Cells.Item(i).Specific.String = req.Fields.Item("").Value

oMatrix.Columns.Item("V_6").Cells.Item(i).Specific.String = req.Fields.Item("").Value

oMatrix.Columns.Item("V_8").Cells.Item(i).Specific.String = req.Fields.Item("U_EnvDocNo").Value

oMatrix.AddRow()

oMatrix.MoveNext()

Next

Else

oMatrix.Clear()

oMatrix.FlushToDataSource()

End If