on 12-22-2005 9:05 AM
Hi everyone,
i am trying to align scanned ean-codes with values in two system matrix columns by triggering a keydown-event on an UDF. Depending on which of the two system forms(140 or 180) are previously loaded, the event should address and search the matrix column of that specific form.
It already works when triggering the event for only one system form in code(vb.net) but when i add the routine for the second form(180) accordingly and try to trigger the event for that form, the column of the matrix on the system form(140) is being addressed and the triggered keydown-event fails.
Any suggestions would be greatly appreciated.
regards
Daniel
Hi Barend,
thanks for your suggestion.
But how would you do this in item_event.
Could you provide a code sample ?
regards
Daniel
Message was edited by: Daniel Lobotzki
Message was edited by: Daniel Lobotzki
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ok, this is my item_event code:
Private Sub SBO_Application_ItemEvent(ByVal FormUID As
String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef
BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
If pVal.FormType = 25 And pVal.EventType =
SAPbouiCOM.BoEventTypes.et_FORM_LOAD Then
displayScannerForm()
End If
If pVal.FormUID = "ScannerForm1" And pVal.EventType =
SAPbouiCOM.BoEventTypes.et_KEY_DOWN And
pVal.Before_Action = False Then
If pVal.CharPressed = 13 Then
Dim EANCodeEditText, EditCellVal_EANCode1,
EditCellVal_EANCode2, As SAPbouiCOM.EditText
Dim SNCellValue_EANCode1, SNCellValue_EANCode2 As String
Dim oFrm, oFrm1 as SAPbouiCOM.Form
Dim oMtrx, oMtrx1 as SAPbouiCOM.Matrix
Dim oCol, oCol1 as SAPbouiCOM.Column
Dim ScannedEanCode As String
EANCodeEditText = SBO_Application.Forms.Item
("ScannerForm1").Items.Item
("results1").Specific
ScannedEanCode = EANCodeEditText.String
oFrm = SBO_Application.Forms.GetFormByTypeAndCount
(140, 1)
oMtrx = oFrm.Items.Item("38").Specific
oCol = oMtrx.Columns.Item("4")
Dim i As Integer
Dim test1, test2 As String
Dim tmpbool As Boolean = False
Dim RowAnz As Integer = oMtrx.RowCount
For i = 1 To RowAnz
EditCellVal_EANCode1 = oCol.Cells.Item(i).Specific
SNCellValue_EANCode1 = EditCellVal_EANCode1.Value
test1 = SNCellValue_EANCode1.Replace("-", "")
If ScannedEanCode = test1 Then
Try
tmpbool = True
'procedure is called
ExtractingItemCode(pVal.Row, pVal.FormUID)
Catch ex As Exception
SBO_Application.MessageBox("Fehler: " & Err.Number &
vbNewLine & Err.Description)
End Try
End If
Next
'and now i want to do the same using the other form(180)
oFrm1 = SBO_Application.Forms.GetFormByTypeAndCount
(180, 1)
oMtrx1 = oFrm1.Items.Item("38").Specific
oCol1 = oMtrx1.Columns.Item("4")
Dim RowAnz1 As Integer = oMtrx1.RowCount
For i = 1 To RowAnz1
EditCellVal_EANCode2 = oCol1.Cells.Item(i).Specific
SNCellValue_EANCode2 = EditCellVal_EANCode2.Value
test2 = SNCellValue_EANCode2.Replace("-", "")
If ScannedEanCode = test2 Then
Try
tmpbool = True
'procedure is called
ExtractingItemCode(pVal.Row, pVal.FormUID)
Catch ex As Exception
SBO_Application.MessageBox("Fehler: " & Err.Number &
vbNewLine & Err.Description)
End Try
End If
Next
End If
End If
End Sub
Message was edited by: Daniel Lobotzki
Message was edited by: Daniel Lobotzki
Daniel your problem lies here:
'and now i want to do the same using the other form(180)
oFrm1 = SBO_Application.Forms.GetFormByTypeAndCount
(180, 1)
oMtrx1 = oFrm1.Items.Item("38").Specific
oCol1 = oMtrx1.Columns.Item("4")
Dim RowAnz1 As Integer = oMtrx1.RowCount
For i = 1 To RowAnz1
EditCellVal_EANCode2 = oCol1.Cells.Item(i).Specific
SNCellValue_EANCode2 = EditCellVal_EANCode2.Value
test2 = SNCellValue_EANCode2.Replace("-", "")
If ScannedEanCode = test2 Then
Try
tmpbool = True
'procedure is called
<b><u>ExtractingItemCode(pVal.Row, pVal.FormUID)</b></u>
Catch ex As Exception
SBO_Application.MessageBox("Fehler: " & Err.Number &
vbNewLine & Err.Description)
End Try
End If
Next
-> you are trying to use pVal for from 180 but the pval is appilcable only to form 140 for this event.
Thus what you are trying to accomplish here is impossible - I guess it's back to the drawing board!
(Always remember 1 item event is always ONLY applicable to 1 form - the one on which the action was made)
Hi Barend,
thank you for your help and effort.
But i still have some difficulty understanding this since
i'm not trying to use pVal for both forms (140+180) at the same time, but only for one form at a time depending on which form (either 140 or 180) was loaded before.
You also stated:
"1 item event is always ONLY applicable
to 1 form - the one on which the action was made."
In my case the form on which the action (keydown-event)
is made is neither form 140 nor form 180 but the User
Defined Form (ScannerForm1).
The matrix column to be addressed and searched by this
event is located on Form 140 or Form 180 (so to say at the
receiving end of the triggered keydown-event from the UDF
'ScannerForm1').
So what i'm trying to accomplish after the keydown-event is triggered, is to 'check' somehow if either form 140 or form 180 has been opened previous to the 'ScannerForm1' in
order to search the matrix column of that one specific
form.
I hope you can reproduce my explanation, since it is
quite difficult to explain.
regards
Daniel
Message was edited by: Daniel Lobotzki
Message was edited by: Daniel Lobotzki
Hi Barend,
thanks for your answer.
Although i'm not sure it can be solved like this.
Because i'm already working within an Item_Event sub.
This is my code:
Private Sub SBO_Application_ItemEvent(ByVal FormUID As
String, ByRef pVal As SAPbouiCOM.ItemEvent,
ByRef BubbleEvent As Boolean) Handles
SBO_Application.ItemEvent
If pVal.FormType = 25 And pVal.EventType =
SAPbouiCOM.BoEventTypes.et_FORM_LOAD Then
displayScannerForm()
End If
...
If pVal.FormUID = "ScannerForm" And pVal.EventType =
SAPbouiCOM.BoEventTypes.et_KEY_DOWN And
pVal.Before_Action = False Then
If pVal.CharPressed = 13 Then
...
oFrm = SBO_Application.Forms.GetFormByTypeAndCount(140, 1)
oMtx = oFrm.Items.Item("38").Specific
oCol = oMtx.Column.Item("4")
...
So when this keydown-event is triggered in order to
search through the column of the matrix, pVal is
already occupied with the FormUID of the ScannerForm.
Can it be solved within this Item_Event sub
or is there any other way to implement this ?
regards
Daniel
Message was edited by: Daniel Lobotzki
Message was edited by: Daniel Lobotzki
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Daniel,
You must do it in item_event: each form will fire the event to this sub and here you must manage what you want to do with the event.
There is an error in your logic, Never use:
oFrm = SBO_Application.Forms.GetFormByTypeAndCount(140, 1)
because you won't know what form will be returned - instead use
oFrm = SBO_Application.Forms.Item(FormUID)
this way you'll get the form that sent the item event.
Hi Daniel,
You should cast a handle to your form using the unique form ID (in the Item_Event sub)
Private Sub SBO_App_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_App.ItemEvent
dim oForm as SAPbouiCOM.Form
if If pVal.FormTypeEx = "180"
oform = SBO_App.Forms.Item(FormUID)
run your matrix code here with oform
end if
if If pVal.FormTypeEx = "140"
oform = SBO_App.Forms.Item(FormUID)
run your matrix code here with oform
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.
User | Count |
---|---|
91 | |
10 | |
10 | |
6 | |
5 | |
5 | |
5 | |
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.