cancel
Showing results for 
Search instead for 
Did you mean: 

accessing fields on system matrix

Former Member
0 Kudos

Hello everyone. I want to acess a individual field on the products matrix in the sales order form, so i can compare it with another value, but the system wont let me.

My code is

oItem = oForm.Items.Item("38")

'SBO_Application.MessageBox("2") '- funca

oMatrix = oItem.Specific

ItemCode = oMatrix.Columns.Item(1).Cells.Item(1)

MsgBox(ItemCode)

Anyone knows what am I doing wrong? Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Try this instead, see if it works ...

ItemCode = oMatrix.Columns.Item(1).Cells.Item(1).Specific.Value

Former Member
0 Kudos

I tried

ItemCode = oMatrix.Columns.Item(1).Cells.Item(1).Specific.ValueIt

but it didn't worked. Any other ideia? I really need to access the data on that field

Former Member
0 Kudos

what is the error message that it gives you ?

Probably you missed typed but, you are not trying to run

Specific.ValueIt

? It is

.Value

just in case!

Former Member
0 Kudos

It was a missspell. I don't get any error message, however i get two first chance exceptions on vb's output window:

'system.MissingMemberException' in Microsoft.VisualBasic.dll and System.Runtime.InteropServices.COMException' in Sysform.exe. This is my first time using visual basic, i only had training in c++, c#, and java, so i have no ideia what those exceptions mean

Former Member
0 Kudos

Don't worry ... probably i would be feel the same with C++

Well, try putting that particular code function or procedure inside a try catch ex

for example

Try
   '....
    oItem = oForm.Items.Item("38")
    'SBO_Application.MessageBox("2") '- funca
    oMatrix = oItem.Specific
    ItemCode = oMatrix.Columns.Item(1).Cells.Item(1).Specific.Value
    MsgBox(ItemCode)
   ' ....
Catch ex As Exception
     SBO_Application.MessageBox("Error! " & vbCrLf & ex.Message & "-" & Err.Number, , "")
End Try

this should give you a message error more specific to the problem you are having.

Former Member
0 Kudos

Ok, i have done as you sayd, and the message the program returned was:

"Error! Public member 'Value' on type 'IComboBox' not found.-438"

Former Member
0 Kudos

Ok, so the cell you are trying to access its value from is that of type Combobox.

So, you need to change the instruction ...

itemCode = oMatrix.Columns.Item(1).Cells.Item(1).Specific.Value

to this ...

itemCode = oMatrix.Columns.Item(1).Cells.Item(1).Specific.Selected.Value

but if nothing has been selected yet it will throw you and error so you got to furthermore do this ...

If  oMatrix.Columns.Item(1).Cells.Item(1).Specific.Selected is nothing then
    itemCode = nothing
Else
    itemCode = oMatrix.Columns.Item(1).Cells.Item(1).Specific.Selected.Value
End If

Former Member
0 Kudos

Hi again. I've done has you said and i don't have an error anymore... but the variable stays empty. After the code you gave i puted "SBO_Application.MessageBox("" & ItemCode)" and it shows me an empty messege. I'm very frustrated with this, how hard can it be? What i want to do is to access the first item number when the "add" button is pressed on the "Sales order" form. Here is the complete code:

   If ((pVal.FormType = 139 And pVal.EventType <> SAPbouiCOM.BoEventTypes.et_FORM_UNLOAD) And (pVal.Before_Action = True)) Then
            If ((pVal.ItemUID = "1") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK)) Then

                Try
                    oItem = oForm.Items.Item("38")
                    oMatrix = oItem.Specific

                    If oMatrix.Columns.Item(1).Cells.Item(1).Specific.Selected Is Nothing Then
                        ItemCode = Nothing
                    Else
                        ItemCode = oMatrix.Columns.Item(1).Cells.Item(1).Specific.Selected.Value
                    End If

                    SBO_Application.MessageBox("" & ItemCode)

                Catch ex As Exception
                    SBO_Application.MessageBox("Error!" & vbCrLf & ex.Message & "-" & Err.Number, , "")
                End Try
     end if
end if 

do you see anything wrong with this? Thanks for all your help.

Former Member
0 Kudos

It depends how do you fill the combo with values. Try to change the

Selected.Value

to Selected.Description

The next way is change the code as

instead of

ItemCode = oMatrix.Columns.Item(1).Cells.Item(1).Specific.Selected.Value

give

dim cmb As SAPbouiCOM.ComboBox

cmb = oMatrix.Columns.Item(1).Cells.Item(1).Specific

ItemCode = cmb.Selected.Description

and to line with cmb = add breakpoint and watch and look, how is the combo filled.

Former Member
0 Kudos

I've tried both the ways you said, and both show a blank message instead of the item id

Nussi
Active Contributor
0 Kudos

Hi Joao,

so many people answered here and iam not sure if you're still interested in my answer.

when someone else here suggested this already - sorry

let's say you're really using vb6.

you know what i usually do - i access the Column over the ItemUID as string - with ""

because without them it's accessing them with index.

ItemCode = oMatrix.Columns.Item("1").Cells.Item(1).Specific.Value

thats what i whould do ...

lg David

Former Member
0 Kudos

Hello, and thank you for your answer. Unfortunately, it doesn't work. It gives me this error: "unable to cast object of type 'system.string' to type 'SAPbouiCOM.EditText'.-13". Any clue?

Nussi
Active Contributor
0 Kudos

Hallo Joao,

which language do you use: c#, vb.net or vb6 ?

try CStr( variable) in vb6 when you want to set the edittextbox.

because it sounds like you want to set the edittext value and passing a wrong type.

oMatrix.Columns.Item("1").Cells.Item(1).Specific.Value = cstr(value)

lg David

Former Member
0 Kudos

hi

Instead of assigning the value to string or edittext or anything,why not try this


SBO_Application.MessageBox(oMatrix.Columns.Item("1").Cells.Item(1).Specific.Value)

If this returns a value then,then declaration/initialization for Itemcode may be wrong.But all you need is values out of Itemcode,doesnt matter if u assign it to something or not.

HTH

Raghu

Former Member
0 Kudos

The reason is, that you must use Davids example as

oEdit =  oMatrix.Columns.Item("1").Cells.Item(1).Specific
ItemCode = oEdit.Value (or oEdit.String)

oedit is edittext

Answers (1)

Answers (1)

Former Member
0 Kudos

Joao,

the column you are looking for is column 3 and not 1. may be the unique id for column you see in status bar is misleading.

change it to:


  If ((pVal.FormType = 139 And pVal.EventType  <> SAPbouiCOM.BoEventTypes.et_FORM_UNLOAD) And (pVal.Before_Action = True)) Then
            If ((pVal.ItemUID = "1") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK)) Then
 
                Try
                    oItem = oForm.Items.Item("38")
                    oMatrix = oItem.Specific
                 
                        ItemCode = oMatrix.Columns.Item(1).Cells.Item(1).Specific.Value
                  
 
                    SBO_Application.MessageBox("" & ItemCode)
 
                Catch ex As Exception
                    SBO_Application.MessageBox("Error!" & vbCrLf & ex.Message & "-" & Err.Number, , "")
                End Try
     end if
end if 

hope that helps.

Binita

Former Member
0 Kudos

I've changed the code to 1 and it gave me a nasty error. Are you shure that the item code is stored in collumn 1?