cancel
Showing results for 
Search instead for 
Did you mean: 

Matrix problem (again)

Former Member
0 Kudos

I try to fill-in a matrix using a recordset and userdatasource.

here is a part of codes:

For i As Integer = 1 To rs.RecordCount

oMatrix.AddRow(i)

oUDSCardCode.ValueEx = rs.Fields.Item("CardCode").Value

oUDSCardName.ValueEx = rs.Fields.Item("CardName").Value

oUDSItemCode.ValueEx = rs.Fields.Item("ItemCode").Value

oUDSItemName.ValueEx = rs.Fields.Item("ItemName").Value

oMatrix.SetLineData(i)

oMatrix.FlushToDataSource()

rs.MoveNext()

Next i

my problem is, there is only 3 records in the recordset:

i.e.

AAACode AAAName AAAItem AAADesc

BBBCode BBBName BBBItem BBBDesc

CCCCode CCCName CCCItem CCCDesc

but the Matrix shows:

AAACode AAAName AAAItem AAADesc

BBBCode BBBName BBBItem BBBDesc

BBBCode BBBName BBBItem BBBDesc

CCCCode CCCName CCCItem CCCDesc

CCCCode CCCName CCCItem CCCDesc

CCCCode CCCName CCCItem CCCDesc

Any ideas?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Nussi
Active Contributor
0 Kudos

Hi,

the mistake is that you use

oMatrix.AddRow(i)

that means you add 3 lines when i = 3

better add the row with

oMatrix.AddRow(1, -1)

lg David

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi

This is code used to add rows to matrix from RS.

Hope its help you.

Regards

Sierdna S.


Dim sSql As String = ""
sSql = "SELECT DocNum,.. FROM ... WHERE ..."
oRS = SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
oRS.DoQuery(sSql)
If oRS.RecordCount > 0 Then
  Dim i As Integer = 0
  oRS.MoveFirst()
  While oRS.EoF = False
    i = i + 1
    oForm.DataSources.UserDataSources.Item("uNr").Value = i     ' 1" matrix column for row number
    oForm.DataSources.UserDataSources.Item("uChoise").Value = "1" ' For user choise checkbox column
    oForm.DataSources.UserDataSources.Item("uDocNum").Value = oRS.Fields.Item("DocNum").Value
    oForm.DataSources.UserDataSources.Item("uLineNum").Value = oRS.Fields.Item("LineNum").Value
    oForm.DataSources.UserDataSources.Item("uItemCode").Value = oRS.Fields.Item("ItemCode").Value
    oForm.DataSources.UserDataSources.Item("uItemName").Value = oRS.Fields.Item("ItemName").Value
    oForm.DataSources.UserDataSources.Item("uQuantity").Value = oRS.Fields.Item("Quantity").Value
    oForm.DataSources.UserDataSources.Item("uNotes").Value = oRS.Fields.Item("Notes").Value
    ' ++++++++++++++++++++
    oMatrix.AddRow()
    ' ++++++++++++++++++++
    oRS.MoveNext()

  End While

End If

Former Member
0 Kudos

Hi

Thanks For ur reply i did as u directed..

here is the code how i implement .

what i need to do is.. i have designed a form purchase indent from that using copy to functionality i have to store all the data from that form to purchase order form.

i am able to open the purchase order and load some values while load the matrix i faced a problem.

can u reffer the code and advise me where i committed mistake plz..

SBO_Application.ActivateMenuItem("2305")

Dim f As SAPbouiCOM.Form

f = SBO_Application.Forms.ActiveForm

'Dim f As SAPbouiCOM.Form

'f = SBO_Application.Forms.Item("142")

'f.Select()

' ' f.Execute() Dim f As SAPbouiCOM.Form

Dim oField As SAPbouiCOM.EditText

oItem = f.Items.Item("16")

oField = oItem.Specific

oField.String = "Based On PurchaseIndent:" + oForm.Items.Item("3").Specific.Value

Dim sSql As String = ""

Dim oRS As SAPbobsCOM.Recordset

oItem = f.Items.Item("38")

oMatrix = oItem.Specific

oColumns = oMatrix.Columns

sSql = "select a.U_ITEM as Code, a.U_DESC as Descp,a.U_QTY as Quantity,a.U_RATE as price from [@TBL_INDENTROWS1] a,[@TBL_INDENT1] b where a.DocEntry=b.DocEntry and b.U_INDNO='" & oForm.Items.Item("3").Specific.Value & " '"

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

oRS.DoQuery(sSql)

If oRS.RecordCount > 0 Then

Dim i As Integer = 0

oRS.MoveFirst()

While oRS.EoF = False

i = i + 1

oMatrix.Columns.Item("Column1").Cells.Item(i).Specific.Value = oRS.Fields.Item("Code").Value

                                                                                                              • oMatrix.Columns.Item("Column3").Cells.Item(i).Specific.Value = oRS.Fields.Item("Descp").Value

oMatrix.Columns.Item("Column11").Cells.Item(i).Specific.Value = oRS.Fields.Item("Quantity").Value

oMatrix.Columns.Item("Column13").Cells.Item(i).Specific.Value = oRS.Fields.Item("price").Value

oMatrix.AddRow()

oRS.MoveNext()

End While

End If

when the control reaches to column 1 it terminates and exception is followed .. plz reply m soon..

Former Member
0 Kudos

got it.

thank you very much.

Former Member
0 Kudos

thanks for your reply.

i mean rs.Recordcount = 3

so i would expect it shows 3 rows in the Matrix,

but now i get totally 6 rows.

I've already added oMatrix.AddRow(i, -1), but problem stills.

Pls. adv.

Thanks

Nussi
Active Contributor
0 Kudos

Hi,

first sigh

did you read what i wrote ?

use oMatrix.AddRow(-> 1 <-, -1)

not i in AddRow

lg David