on 10-30-2017 7:52 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
Hi Megha Mangalekar,
It was glad to know that the issue has been resolved for you!
Kind regards,
ANKIT CHAUHAN
SAP SME Support
User | Count |
---|---|
110 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.