cancel
Showing results for 
Search instead for 
Did you mean: 

Events Filters method

Former Member
0 Kudos

Hi,

in the SDK documentation, i see 2 differents ways to applied events filter, could you please explain me what's the difference between both and if both works fine.

In first method below the Forms are assigned after all events filer (that's correct?)

1st method :

Private Sub SetFilters()
    '// Create a new EventFilters object
    oFilters = New SAPbouiCOM.EventFil

    '// add an event type to the container
    '// this method returns an EventFilter object

    oFilter = oFilters.Add(SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED)
    oFilter = oFilters.Add(SAPbouiCOM.BoEventTypes.et_COMBO_SELECT)
    oFilter = oFilters.Add(SAPbouiCOM.BoEventTypes.et_VALIDATE)
    oFilter = oFilters.Add(SAPbouiCOM.BoEventTypes.et_LOST_FOCUS)
    oFilter = oFilters.Add(SAPbouiCOM.BoEventTypes.et_KEY_DOWN)
    oFilter = oFilters.Add(SAPbouiCOM.BoEventTypes.et_MENU_CLICK)
    oFilter = oFilters.Add(SAPbouiCOM.BoEventTypes.et_CLICK)

    '// assign the form type on which the event would be processed
    oFilter.AddEx("149") 'Quotation Form
    oFilter.AddEx("139") 'Orders Form
    oFilter.AddEx("133") 'Invoice Form
    oFilter.AddEx("169") 'Main Menu

    SBO_Application.SetFilter(oFilters)

End Sub

2nd method (most commonly used i think) :

oFilters As SAPbouiCOM.EventFilters
oFilter As SAPbouiCOM.EventFilter

Private Sub SetFilters()

    '// Create a new EventFilters object
    Set oFilters = New SAPbouiCOM.EventFilters

    '// Add an event type to the container
    '// This method returns an EventFilter object
    Set oFilter = oFilters.Add(et_CLICK)
        '// The form types to which the event will apply
        oFilter.Add 139 'Orders Form
        oFilter.Add 142 'Purchase Form

    Set oFilter = oFilters.Add(et_KEY_DOWN)
        '// Again the form type to which the event will apply
        oFilter.Add 139 'Orders Form
    SBO_Application.SetFilter oFilters

End Sub

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Alan,

You can also do it using XML.

Turning Off Filters to a specific form


<?xml version="1.0" encoding="UTF-16"?>
<filter>
	<events>
		<event type="1">
			<forms>
				<form form_id="NMSP_MYFORM"></form>
			</forms>
		</event>
	</events>
</filter>

Turning On Filters


<?xml version="1.0" encoding="UTF-16"?>
<filter>
	<events>
		<event type="7">
			<forms>
				<form form_id="NMSP_MYFORM"></form>
			</forms>
		</event>
		<event type="21">
			<forms>
				<form form_id="140"></form>
			</forms>
		</event>
		<event type="16">
			<forms>
				<form form_id="139"></form>
			</forms>
		</event>
		<event type="34">
			<forms>
				<form form_id="139"></form>
			</forms>
		</event>
		<event type="36">
			<forms>
				<form form_id="139"></form>
			</forms>
		</event>
		<event type="5">
			<forms>
				<form form_id="139"></form>
			</forms>
		</event>
		<event type="1">
			<forms>
				<form form_id="139"></form>
				<form form_id="140"></form>
				<form form_id="NMSP_MYFORM"></form>
			</forms>
		</event>
		<event type="27">
			<forms>
				<form form_id="139"></form>
			</forms>
		</event>
		<event type="10">
			<forms>
				<form form_id="139"></form>
				<form form_id="140"></form>
			</forms>
		</event>
		<event type="6">
			<forms>
				<form form_id="140"></form>
			</forms>
		</event>
	</events>
</filter>

Regards,

Vítor Vieira

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Alan,

.........

oFilter = oFilters.Add(SAPbouiCOM.BoEventTypes.et_MENU_CLICK)

oFilter = oFilters.Add(SAPbouiCOM.BoEventTypes.et_CLICK)

'// assign the form type on which the event would be processed

oFilter.AddEx("149") 'Quotation Form

oFilter.AddEx("139") 'Orders Form

oFilter.AddEx("133") 'Invoice Form

oFilter.AddEx("169") 'Main Menu

What will happen here is that only et_CLICK is fine-tuned to only trigger on formtypes 149, 139, 133 and 169. All other events defined here will trigger on all forms.

Unless you want to build a key-logger you want method 1 for et_KEY_DOWN.