Skip to Content
avatar image
Former Member

Fillin a Matrix

Hi:

I am filling a matrix with a Query, I get the results well, but it fill's me at the end aditional lines with ceros.

Has any one the same problem, what I am doing wrong

The code is:

Public Sub SetMatrix()

Dim oHoras As SAPbouiCOM.EditText

Dim oNumTicket As SAPbouiCOM.EditText

Dim ototFactura As SAPbouiCOM.EditText

Dim i As Long

i = 1

oRecordSet.DoQuery ("SELECT U_Hora AS hora, SUM(U_Brufacre) AS Total_facturado, COUNT(U_nticketr) AS Num_Facturas From [@LIS1] GROUP BY U_tienda, U_Hora Having (U_tienda = '" & lproy & "')")

While oRecordSet.EOF = False

oMatrix.AddRow i, i + 1

' filling the matrix

Set oHoras = oMatrix.Columns("Horas").Cells.Item(i).Specific

oHoras.String = oRecordSet.Fields.Item(0).Value

Set ototFactura = oMatrix.Columns("totFactura").Cells.Item(i).Specific

ototFactura.String = oRecordSet.Fields.Item(1).Value

Set oNumTicket = oMatrix.Columns("NumTicket").Cells.Item(i).Specific

oNumTicket.String = oRecordSet.Fields.Item(2).Value

oRecordSet.MoveNext

i = i + 1

Wend

End Sub

/***********************

Thanks to all

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • Jun 29, 2004 at 01:40 PM

    I think the problem has to do with the addrow method.

    You use this:

    oMatrix.AddRow i, i + 1

    try using default values

    oMatrix.AddRow ()

    or something like

    oMatrix.AddRow (1,-1)

    I think you are confused with the first parameter. It specifies how many rows to add. The UI help file is not clear enough about this parameter too:

    NumOfRows:

    Specifies the number of rows in the matrix.

    Not much sense for me.

    Regards,

    Ibai Peña

    Message was edited by: Ibai Peña

    Message was edited by: Ibai Peña

    Message was edited by: Ibai Peña

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 29, 2004 at 02:17 PM

    Hello,

    I've got the same problem ...

    I am working on it ...

    I'll contact you later ...

    thanks.

    Romeo.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 30, 2004 at 08:26 AM

    Hi

    I found Natalia's example very interesting and i'm trying to reuse it, but if the recordset field is a date type, the EditText object receives an empty string, and if the recordset field is a numeric type the EditText object receives 0.

    I've tried to use both EditText string and value property but it doesn't work

    Some ideas?

    Regards

    Giovanni Lopez

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 30, 2004 at 08:37 AM

    Hi Giovanni:

    In my case the recordset fields are numeric so i get a zero's at the end, from where did u get the examples??.I can't find examples of hoy to fill a matrix with query's.

    If u want u can write to this direccion:

    natalia.bakkalian@lis-consulting.com

    If I find a solution I will post it ok?.

    Thanks

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi all

      Thiis is a real code that works OK

      Dim rs As SAPbobsCOM.Recordset

      rs = diComp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

      oMatrix = oForm.Items.Item("mtxAttr").Specific

      oMatrix.Clear()

      rs.DoQuery("SELECT * FROM [@ATR] ORDER BY Code")

      With oForm.DataSources.UserDataSources

      If rs.RecordCount <> 0 Then

      rs.MoveFirst()

      Do Until rs.EoF

      .Item("AttrCode").Value = rs.Fields.Item("Code").Value

      .Item("AttrName").Value = rs.Fields.Item("Name").Value

      .Item("InUse1").Value = IIf(InStr(strAttrib, rs.Fields.Item("Name").Value) = 0, "N", "Y")

      oMatrix.AddRow()

      rs.MoveNext()

      Loop

      End If

      End With

      All columns in the matrix are bounded to the user datasources. I think it's the best practice to use bounded columns. It helps to format data, fill matrix and work with it by using GetLineData and SetLineData methods.

      Best regards

      Mark

  • avatar image
    Former Member
    Jun 30, 2004 at 09:48 AM

    Hi Mark:

    I am trying your code, but a get a general failer when a reach this line, any sugestion??.

    .Item("Horas").Value = oRecordSet.Fields.Item("U_Hora").Value

    Thanks for your help

    Add comment
    10|10000 characters needed characters exceeded