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

Not displaying anything

Hi

IN the belwo code it is displaying message till GetDataFromDataSource0 omatrix.clear statement. AFter that nothing is displayed

Case "MyMenu"

Try

CreateFormWithMatrix0()

Try

AddDataSourceToForm0()

BindDataToForm0()

GetDataFromDataSource0()

oForm.Visible = True

Catch

End Try

Catch Exc As Exception

SBO_Application.MessageBox(Exc.ToString)

End Try

Private Sub CreateFormWithMatrix0()

Dim oItem As SAPbouiCOM.Item

Dim oButton As SAPbouiCOM.Button

Try

oForm = SBO_Application.Forms.Item("UidFrmMatrix0")

oForm.Close()

Catch

End Try

Dim creationPackage

creationPackage = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)

creationPackage.FormType = "TypeFrmMatrix0"

creationPackage.UniqueID = "UidFrmMatrix0"

oForm = SBO_Application.Forms.AddEx(creationPackage)

oForm.Title = "Maintain Trans"

oForm.Left = 335

oForm.ClientWidth = 750

oForm.Top = 40

oForm.ClientHeight = 400

AddMatrixToForm0()

End Sub

Private Sub AddMatrixToForm0()

Dim oItem As SAPbouiCOM.Item

oItem = oForm.Items.Add("Matrix1", SAPbouiCOM.BoFormItemTypes.it_MATRIX)

oItem.Left = 5

oItem.Width = 740

oItem.Top = 45

oItem.Height = 300

oMatrix = oItem.Specific

oColumns = oMatrix.Columns

oColumn = oColumns.Add("#", SAPbouiCOM.BoFormItemTypes.it_EDIT)

oColumn.TitleObject.Caption = "#"

oColumn.Width = 25

oColumn.Editable = False

oForm.DataSources.UserDataSources.Add("#", SAPbouiCOM.BoDataType.dt_SHORT_NUMBER)

oColumn = oColumns.Add("ID", SAPbouiCOM.BoFormItemTypes.it_EDIT)

oColumn.TitleObject.Caption = "ID"

oColumn.Editable = False

oColumn = oColumns.Add("Code", SAPbouiCOM.BoFormItemTypes.it_EDIT)

oColumn.TitleObject.Caption = "Code"

oColumn.Editable = False

oColumn = oColumns.Add("Name", SAPbouiCOM.BoFormItemTypes.it_EDIT)

oColumn.TitleObject.Caption = "Name"

oColumn.Editable = False

End Sub

Public Sub AddDataSourceToForm0()

Dim res As Long

Try

Dim oUserTable As SAPbobsCOM.UserTable

oUserTable = oCompany.UserTables.Item("M_Trans")

Dim RecSet As SAPbobsCOM.Recordset = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

Dim RecSet0 As SAPbobsCOM.Recordset = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

RecSet.DoQuery("SELECT empID, U_ecode,firstname +' ' + lastname as name,status FROM OHEM")

While RecSet.EoF = False

Dim key As String = RecSet.Fields.Item("U_ecode").Value.ToString().Trim()

If (oUserTable.GetByKey(key)) Then

Else

If RecSet.Fields.Item("status").Value = 1 Then

oUserTable.UserFields.Fields.Item("U_ID").Value = RecSet.Fields.Item(0).Value

oUserTable.Code = RecSet.Fields.Item(1).Value.ToString.Trim()

oUserTable.Name = RecSet.Fields.Item(2).Value.ToString.Trim()

res = oUserTable.Add()

End If

End If

RecSet.MoveNext()

End While

Catch oEx As Exception

MessageBox.Show(oEx.Message)

End Try

oDBDataSource = oForm.DataSources.DBDataSources.Add("@M_Trans")

End Sub

Public Sub BindDataToForm0()

Try

oColumn = oColumns.Item("#")

oColumn.DataBind.SetBound(True, "", "#")

oColumn.Width = 20

oColumn = oColumns.Item("ID")

oColumn.DataBind.SetBound(True, "@M_Trans", "U_ID")

oColumn.Width = 0

oColumn = oColumns.Item("Code")

oColumn.DataBind.SetBound(True, "@ M_Trans ", "Code")

oColumn.Width = 50

oColumn = oColumns.Item("Name")

oColumn.DataBind.SetBound(True, "@ M_Trans ", "Name")

oColumn.Width = 150

Catch oEx As Exception

MessageBox.Show(oEx.Message)

End Try

End Sub

Public Sub GetDataFromDataSource0()

oMatrix.Clear()

oDBDataSource.Query()

oMatrix.LoadFromDataSource()

SBO_Application.MessageBox(oMatrix.RowCount)

For i As Integer = 1 To oMatrix.RowCount

Dim oEdit As SAPbouiCOM.EditText = oMatrix.Columns.Item("#").Cells.Item(i).Specific

oEdit.String = i

Next i

End Sub

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on May 05, 2015 at 04:16 PM

    Hi,

    you could go a few steps back and verify each step:

    1. Check the result of your query by using a debugger or using a messagebox: MessageBox.Show("Count=" + RecSet.RecordCount).
    2. Validate, that your code iterates over the recordset correctly by using a debugger or writing it to a string and display the string. Isolate this step from writing your data to the user table, test the latter in its own step.
    3. Try to write one well known data set to your user table and verify the written data. Make sure, that the identifiers used are properly set.

    Good luck,

    Dominic

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 14, 2015 at 06:18 AM

    Hi

    It is giving me error DataSource - Invalid TableName [66000-7] . It is displaying form but showing no records. Records are there in the table. Error comes on this line

    oDBDataSource.Query()

    Thanks

    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.