Technical Articles
Create a recipient using several key field values for recipient determination
Introduction
During my work in the Application Interface Framework (AIF) development I sometimes get questions from customers asking how different functionalities do work or what the best way is to solve a specific requirement with SAP Application Interface Framework. For this reason, I have setup a blog series where I describe the solutions to your requirements. Have a look at this blog to get an overview over all already published blogs.
Problem Description
AIF is using recipients to determine the users who are responsible for a message. Users will only see AIF interfaces in the interface monitor or message dashboard if they are assigned to one or more recipients. With the usage of key fields it is possible to determine recipients depending on the value of one or more specific fields in the message. This allows more specific recipients for example there could be one recipient used for messages for VKORG 1000 and another one for VKORG 2000. In this blog I will describe how to create and use a recipient that is depending on the value of two different key fields.
How does it work?
The functionality can be used for new and existing interfaces. The following steps must be executed.
1. Create Recipients
To be able to see the messages in the AIF Interface Monitor the different recipients have to be created. For every user group who has to monitor a subset of the messages one recipient is necessary.
2. Create and assign single index table
To be able to use and store the values of the key fields a single index table is necessary. The key fields have to be part of the single index table. The table can be copied from table /AIF/STD_IDX_TBL. The copied table has to be extended with the relevant key fields.
After the table was created it has to be assigned to the AIF interface.
3. Create and assign recipient assignment table
The information which key field values are assigned to which recipient is stored in a recipient assignment table. The table can be copied from table /AIF/T_ALRT_DEF. The copied table has to be extended with the relevant key fields.
After the table was created it has to be assigned to the interface.
4. Create key fields
After creating and assigning the recipient assignment table the corresponding key fields have to be defined for the AIF interface. The flag relevant for recipient determination controls if a key field is used for recipient determination or not. Field Field Name in Alert Recipient Assignement and flag Relevant for Recipient Determination have to be filled. Only single key fields can be used for recipient determination.
5. Assign key field values to recipients
To be able to handle the recipient assignment correctly the different values of the key fields have to be assigned to the corresponding recipients. The entries have to be added in the newly created recipient assignment table.
6. Test
The final step is to send some test data and check if the recipient determination is working correctly for the different recipients.
Example
This example uses the SAP flight booking example.
Preparation
In order to execute this example, you require an AIF interface. In this example I’m using the file interface build in this example.
Fields CITY and CUSTOMER_COUNTRY will be used to determine the correct recipient.
1. Create Recipient
We require three recipients for this example.
Go to the AIF customizing and navigate to SAP Application Interface Framework -> Error Handling -> Define Namespace-Specific Features. Select your namespace.
Navigate to Define Recipients and create three new entries via button New Entries.
Three recipients will be created. One recipient will receive all messages for city Berlin and customer country EN. One recipient will receive all messages for city Berlin and customer country DE. The third recipient will be used as fallback and will collect all other messages.
Create the new recipients and enter the following data:
Namespace |
Recipient for Alert |
Alert Recipient Description |
ZBM_03 |
Recipient_b_and_en |
Recipient for city Berlin and customer country EN |
ZBM_03 |
Recipient_b_and_de |
Recipient for city Berlin and customer country DE |
ZBM_03 |
Recipient_fallback |
Recipient used to collect all remaining messages |
After creating the three entries save your changes.
2. Create and assign single index table
Create single index table
To be able to use key fields a single index table is necessary. Normally (for interfaces without key fields) the standard index table can be used for an AIF interface. In this case we like to will use two key fields – CUSTTYPE and LANGU. Therefor we have to create a single index table and add our additional fields to the table.
Create the table via transaction SE11. Table /AIF/STD_IDX_TBL can be used as template. Copy this table. Enter /AIF/STD_IDX_TBL in field Database table and press copy.
Enter a name for the to be created table. ZCUST_IDX_TBL will be used in this example.
Press OK to copy the table. In the following screen enter all transport relevant information. For this example the table was created as local object.
Open the new table in edit mode and add the additional fields. Add the following two fields to the table:
Field | Data Element |
CITY | S_CITY |
CUSTOMER_COUNTRY | S_COUN_ISO |
Save and activate the table.
Assign the single index table
After creating the single index table the table has to be assigned to the AIF interface. Go to AIF customizing (transaction /AIF/CUST) and select SAP Application Interface Framework -> Error Handling -> Define Namespace-Specific Features. Enter your namespace.
Press OK.
In the following screen create a new entry in activity Define Interface-Specific Features for your interface.
Enter the interface name and version. In field Message Idx Table enter the name of the newly created single index table. In this example ZCUST_IDX_TBL was used.
Save the new entry.
3. Create and assign recipient assignment table
Create recipient assignment table
The information which key field value combination is assigned to which recipient is stored in a recipient assignment table.
Create the table via transaction SE11. AIF provides a template table /AIF/T_ALRT_DEF. Copy this table. Enter /AIF/T_ALRT_DEF in field Database table and press copy.
Enter a name for the to be created table. In this example I will use ZAIF_ALRT_DEF.
Press OK. Afterwards open the table in edit mode. The fields which are used for the recipient determination have to be added to the table. In this case we require the fields CITY and CUSTOMER_COUNTRY in the recipient assignment table.
Field |
Data Element |
CITY |
S_CITY |
CUSTOMER_COUNTRY |
S_COUN_ISO |
After adding the fields: save and activate the table.
Assign recipient assignment table
To use the recipient assignment table the table has to be assigned to the AIF interface. Go to AIF customizing (transaction /AIF/CUST) -> SAP Application Interface Framework -> Error Handling -> Define Namespace-Specific Features. Enter your namespace.
On the left hand side of the menu navigate to Configure Alerts and create a new entry.
Enter the following data:
Field Name |
Field Value |
Interface Name |
FLCUSTOMER |
Interface Version |
1 |
Recipient Assignment Table |
ZAIF_ALRT_DEF |
Save your changes. The entry should look like displayed below.
4. Create key fields
After creating and assigning the recipient assignment table the corresponding key fields have to be defined for the interface. The flag relevant for recipient determination controls if a key field is used for recipient determination or not. Field Field Name in Alert Recipient Assignement has to be filled and flag Relevant for Recipient Determination needs to be set. Only single key fields can be used for recipient determination.
Create the key fields for the interface in the AIF customizing. Go to AIF customizing (transaction /AIF/CUST) -> SAP Application Interface Framework -> Error Handling -> Define Interface-Specific Features. Select your namespace, interface name and version.
Create a new entry in activity Define Key Fields for Multi. Search.
Enter the following data:
Field Name |
Field Value |
Field Sequence No. |
10 |
Key Field Name |
CITY |
Data element |
S_CITY |
Field Name |
LINES-CUSTOMER_CITY |
Raw or SAP Structure |
Source structure |
Multi. Selection Type |
Single Selection |
Hide Tree Node in the View 1 tree |
True |
Field Name in Alert Recipient Assignment |
CITY |
Relevant for Recipient Determination |
True |
The entry looks like displayed in the screenshot:
Create a second key field and enter the following data:
Field Name |
Field Value |
Field Sequence No. |
20 |
Key Field Name |
CUSTOMER_COUNTRY |
Data element |
S_COUN_ISO |
Field Name |
LINES-CUSTOMER_COUNTRY |
Raw or SAP Structure |
Source structure |
Multi. Selection Type |
Single Selection |
Hide Tree Node in the View 1 tree |
true |
Field Name in Alert Recipient Assignment |
CUSTOMER_COUNTRY |
Relevant for Recipient Determination |
True |
The entry looks like displayed in the screenshot:
5. Assign key field values to recipients
To be able to handle the recipient assignment correctly the different values of the key fields have to be assigned to the corresponding recipients. The entries have to be added in the newly created recipient assignment table.
Go to transaction SE16 and enter the name of the recipient assignment table created in step 3. In this case it is table ZAIF_ALRT_DEF. Press the New Button.
Create three entries as displayed below:
NS |
IFNAME |
IFVERSION |
NSRECIP |
RECIPIENT |
CUSTTYPE |
LANGU |
ZBM_03 |
FLCUSTOMER |
1 |
ZBM_03 |
RECIPIENT_B_AND_EN |
Berlin |
EN |
ZBM_03 |
FLCUSTOMER |
1 |
ZBM_03 |
RECIPIENT_B_AND_DE |
Berlin |
DE |
ZBM_03 |
FLCUSTOMER |
1 |
ZBM_03 |
RECIPEINT_FALLBACK |
|
|
Save your changes.
6. Test
Send in some test data and check if the messages are assigned to the right recipients.
In order to see the different recipients in the AIF Interface Monitor you have to assign your user to those recipients. This can be done via transaction /AIF/RECIPIENTS. Start the transaction and select your user. Assign your user to the three new recipients.
Send in new test data. At least three messages with the following data is required to check if the recipient assignment is working as expected:
- Send in data where CUSTOMER_CITY = Berlin and CUSTOMER_COUNTRY = DE
- Send in data where CUSTOMER_CITY = Berlin and CUSTOMER_COUNTRY = EN
- Send in Data where CUSTOMER_CITY = London and CUSTOMER_COUNTRY = EN.
Check the result in the AIF Interface Monitor. You should see messages for each recipient. Check if the messages are assigned correct.
Summary
This blog post gave an introduction on how to combine several key fields and use them for recipient determination. This will allow you to specify which messages of an interface a specific group of users can see.
Any feedback on the blog is appreciated. Feel free to leave your feedback or any questions about the topic in the comments or drop me a message.
First of Thank you for this knowlable blog Britta Mangei.
I have Requirement Like need to display Interface monitor as company code wise or logical system wise.
Can you please guide how to achieve this..?
Thanks & regards.