cancel
Showing results for 
Search instead for 
Did you mean: 

addressing column in matrix on two system forms with keydown-event on udf

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

barend_morkel2
Active Contributor
0 Kudos

post your full Item-event code here then we can see what we can work out...

Former Member
0 Kudos

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

barend_morkel2
Active Contributor
0 Kudos

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)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Barend,

i found a different way to solve my problem.

However your suggestions were very helpful, sorry for the late points reward.

regards

Daniel

Answers (2)

Answers (2)

Former Member
0 Kudos

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

barend_morkel2
Active Contributor
0 Kudos

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.

barend_morkel2
Active Contributor
0 Kudos

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