Technology Blog Posts by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
AlexPfeil
Product and Topic Expert
Product and Topic Expert
0 Likes
1,679

Introduction

In SAP Advanced Event Mesh, there is the possibility to apply filters from consumer side based on the Topic. For example:

Topic: sap/aif/businesspartner/change/<BusinessPartnerGroup>

One Consumer could be only interested in one Group and would subscribe to

sap/aif/businesspartner/change/0001

Other consumers might want to consume everything and subscribe to 

sap/aif/businesspartner/change/>

In some cases, the SAP Event Source might want to filter on Sender Side in order to only send a Subset of the Data in the System. This is possible in AIFAEM and I will show you one way to do it.

Target Message Structure

In my first blog on this topic I have created a simple Business Partner Data Event. Now let´s assume we want to filter based on the Business Partner Group. Since I didn´t have this field in my structure, I simply added it into my Structure:

 

 

@EndUserText.label : 'ABUSINESSPARTNER but with less fields'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
define structure zaifaem_abusinesspartner {

  businesspartner         : abap.string(0);
  businesspartnergrouping : abap.string(0);
  firstname               : abap.string(0);
  lastname                : abap.string(0);

}

 

 

I also added it into my Structure Mapping Function Module

AlexPfeil_1-1736518096118.png

Also, I want to add another Field to the Target Structure. This filed will control, if an event is sent out or not.

AlexPfeil_2-1736518404033.png

if IGNORE = "X", we want to ignore this Event and not send it to AEM.

 

Value Mapping Definition

AlexPfeil_3-1736518564815.png

This Value Mapping is intended with a Whitelisting Approach. Unless I maintain something else in the Value Mapping Table, It will map the Default Value "X". For Group 0001 I have maintained an entry with "" (empty), so IGNORE will be empty.

TCode: /N/AIF/VMAP

AlexPfeil_4-1736518693037.png

 

If you want to do a Blacklisting Appraoch, you just need to remove the Default Value. Then the Value Mapping will map "" as default. Then you can Add Entries with "X" in the right Column and will set IGNORE = "X" for those.

The Value Mapping of Course has to be implemented in the Structure Mapping. Since I want to use a Field from the Target Structure, which will be available after the Structure Mapping 20 (DATA), I added a Structure Mapping 30 to ZAIF_AEM_BUPA_EVENT_MESSAGE

AlexPfeil_6-1736518852396.png

Then I add the Field Mapping for "IGNORE"

AlexPfeil_7-1736518898555.png

 

Check Definition

In the Action I want the AIF to check if the Field "IGNORE" is empty. If yes, it should send the Event to AEM. If not, it should not send it. Therefore I defined a Check in /N/AIF/CUST -> Define Check

AlexPfeil_8-1736519214161.png

AlexPfeil_9-1736519229415.png

For the Warning message just define a message in any message class in SE91

AlexPfeil_10-1736519308742.png

 

Action 

In /N/AIF/CUST -> Define Actions you will need to add the Target Message Type as Main Component Type

AlexPfeil_11-1736519380376.png

For the Standard Action /AIF/AIF_ACTION_CALL_AEM we add this Check

AlexPfeil_13-1736519465762.png

 

Test

Now let´s Test. 

AlexPfeil_14-1736519660890.png

 

1) Business Partner which should be sent --> 104

AlexPfeil_15-1736519722678.png

AlexPfeil_16-1736519769805.png

2) Business Partner which shouldn´t be sent --> 103

AlexPfeil_17-1736519813270.png

AlexPfeil_19-1736519852585.png

The Info Message we only see with Trace Level 2. You can enable it here:

AlexPfeil_20-1736519902280.png

--> Mass Maintain

AlexPfeil_23-1736520000530.png

AlexPfeil_21-1736519932498.png

3) Other Interfaces

Since we are using the Action for all Interfaces, we have to make sure that other Interfaces without Filter still work. For instance I have another Event for SalesOrders without the "IGNORE" Field:

AlexPfeil_24-1736520139454.png

Expecation is, that AIF will not find the Field and therefore the Check is skipped and the Event is sent out. Let´s try: Changing Sales Order in VA02

AlexPfeil_25-1736520228713.png

AIF:

AlexPfeil_26-1736520268400.png

 

 

 

 

 

2 Comments