Skip to Content
0

How to insert Table's records in matrix row by row using RecordSet

Oct 30, 2017 at 07:52 AM

50

avatar image

Hi I am trying to add records from my no object table to matrix but i am getting exception "Bad value " where i am trying to add Name at Ename field of matrix.can any one give me the solution.

thanks and regards

Megha

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Megha Mangalekar Oct 30, 2017 at 07:56 AM
0

here is my code

Dim i As Integer recset = ocmp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

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

ocp.UniqueID = "MForm" ocp.FormType = "MForm"

ocp.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Fixed

oform = SBO_Application.Forms.AddEx(ocp)

oform.Height = 250

oform.Width = 300

oitem = oform.Items.Add("Matrix", SAPbouiCOM.BoFormItemTypes.it_MATRIX)

oitem.Top = 5

oitem.Left = 5

oitem.Width = 250

oitem.Height = 200

omatrix = oitem.Specific

ocolumns = omatrix.Columns

ocolumn = ocolumns.Add("Ecode", SAPbouiCOM.BoFormItemTypes.it_EDIT)

ocolumn.Width = 50

ocolumn.Editable = True

ocolumn.TitleObject.Caption = "Code"

ocolumn = ocolumns.Add("EName", SAPbouiCOM.BoFormItemTypes.it_EDIT)

ocolumn.TitleObject.Caption = "Name"

ocolumn.Width = 50

ocolumn.Editable = True

ocolumn = ocolumns.Add("ECurrkey", SAPbouiCOM.BoFormItemTypes.it_EDIT)

ocolumn.TitleObject.Caption = "CurrKey"

ocolumn.Width = 50

ocolumn.Editable = True

recset.DoQuery("select Code,Name,U_CurrKey from [@SERVER] ")

'Dim CODE As String = recset.Fields.Item(0).Value

'Dim NAME As String = recset.Fields.Item(1).Value

'Dim CURRKEY As String = recset.Fields.Item(2).Value

If recset.RecordCount > 0 Then

For i = 0 To 2

omatrix.AddRow()

'While recset.EoF = False

omatrix.Columns.Item("Ecode").Cells.Item(omatrix.VisualRowCount).Specific.value = recset.Fields.Item(0).Value 'CODE omatrix.Columns.Item("EName").Cells.Item(omatrix.VisualRowCount).Specific.value = recset.Fields.Item(1).Value 'CODE 'NAME omatrix.Columns.Item("ECurrkey").Cells.Item(omatrix.VisualRowCount).Specific.value = recset.Fields.Item(2).Value 'CURRKEY omatrix.AddRow(2)

If recset.EoF = False

Then recset.MoveNext()

ElseIf recset.BoF = False Then

recset.MovePrevious()

End If

' End While

Next i

End If

End Sub

Show 6 Share
10 |10000 characters needed characters left characters exceeded

Hi Megha,

What is the issue that you are having?

Kind regards,

ANKIT CHAUHAN

SAP SME Support

0

I am getting "invalid index"exception at line

"omatrix.Columns.Item("Ecode").Cells.Item(omatrix.VisualRowCount).Specific.value = recset.Fields.Item(0).Value " of above program

I have created no object table"SERVER" i just want to display records from this table to matrix using record set

0

Hi Megha,

Clearly, your program is not able to get the Row on which you want to copy the data. I would ask you to debug it line by line and check whether it is referring to the correct row.

Also omatrix.AddRow(2) . Could you mention why you are adding 2 row in one go?

Kind regards,

ANKIT CHAUHAN

SAP SME Support

0

After debugging also i am getting same exception at the same line.

omatrix.Columns.Item("Ecode").Cells.Item(omatrix.VisualRowCount).Specific.value = recset.Fields.Item(0).Value

won't this line add value to matrix cell using recordset?

What should be passesd instead of "omatrix.VisualRowCount". Please sir give me solution? If this line of code is not correct then i just want single line of code which will assign a value to matrix using recordset.

Thank you and regards,

Megha

0

Hello Ankit sir,

My Issue has solved .I didnt bind the matrix column with data source that's why it wasn't worked correctly.

Thank you and Regards

Megha

0

Hi Megha Mangalekar,

It was glad to know that the issue has been resolved for you!

Kind regards,

ANKIT CHAUHAN

SAP SME Support

0