on 06-12-2008 6:51 PM
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.
Hi
Try this instead, see if it works ...
ItemCode = oMatrix.Columns.Item(1).Cells.Item(1).Specific.Value
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
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
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.
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.
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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
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.