Skip to Content
author's profile photo Former Member
Former Member

Matrix To User Defined Table

Hello. I'm attempting to take data from a matrix and place it into a User Defined Table. To do this, I'm assigning User Data Sources to each of the columns and attempting to read the values out. I COULD update the table if I could get the data, however, my problem is that each data source for the 3 matrix columns is returning empty (null) values. One of the columns is a checkbox column. My code is below, any help would be greatly appreciated. At this point, I'd be happy just to 'see' the data, which is the purpose of the MessageBox at the bottom.

Dim sboCol1 As SAPbouiCOM.Column

Dim sboCol2 As SAPbouiCOM.Column

Dim sboCol3 As SAPbouiCOM.Column

Dim sboDS1 As SAPbouiCOM.UserDataSource

Dim sboDS2 As SAPbouiCOM.UserDataSource

Dim sboDS3 As SAPbouiCOM.UserDataSource

Set oForm = SBO_Application.Forms.Item(FormUID)

Set oItem = oForm.Items.Item("Matrix1")

Set oMatrix = oItem.Specific

Set sboDS1 = oForm.DataSources.UserDataSources.Add("DS1", dt_SHORT_NUMBER, 10)

Set sboDS2 = oForm.DataSources.UserDataSources.Add("DS2", dt_SHORT_TEXT, 10)

Set sboDS3 = oForm.DataSources.UserDataSources.Add("DS3", dt_SHORT_TEXT, 10)

Set sboCol1 = oMatrix.Columns.Item("Col0")

Set sboCol2 = oMatrix.Columns.Item("Col3")

Set sboCol3 = oMatrix.Columns.Item("Col1")

Call sboCol1.DataBind.SetBound(True, , "DS1")

Call sboCol2.DataBind.SetBound(True, , "DS2")

Call sboCol3.DataBind.SetBound(True, , "DS3")

For i = 1 To oMatrix.RowCount

oMatrix.GetLineData ℹ️

SBO_Application.MessageBox "Line:" & sboDS1.Value & ":" & sboDS2.Value & ":" & sboDS3.Value

Next i

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 13, 2004 at 04:21 PM

    Here are some thoughts I've had from looking at your code.

    First, it looks like you are creating and binding the user data sources to the columns upon attempting to retrieve the data, not at the time of column creation. Usually, data sources are bound to columns at the time of column creation.

    This is probably where your problem lies, as I expect the user data sources won't initialize themselves automatically with any value already in the columns.

    I'd try 2 things.

    The first would be to create and bind the user data sources to the columns at the time of column creation.

    This way, the data sources exist at the time of adding data to your matrix.

    The second would be to force a 'Click' event on each column prior to retrieving the data.

    I've found this to be a successful way of forcing data sources to accept the data that is visually shown in their associated controls.

    You could do this by adding an inner for loop inside your for loop, for each column.

    At it's simplest it would be like this:

    For Index = 0 To Matrix.Columns.Count - 1

    Matrix.Columns.Item(RowIndex).Cells(0).Click

    Next Index

    You will likely need to check the enabled/visible state as well, prior to forcing the clicking or it may crash.

    I hope this helps.

    Demetree

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 10, 2004 at 05:02 PM

    Hi Greg,

    I'm having same problem now.

    I have a column that have null value and the program stops with error.

    Have you solved the problem?

    Any other suggestion appreciated.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.