Blog > How to create Custom Functions in SAP AIF?

How to create Custom Functions in SAP AIF?

SAP_AIF_How_to_create_custom_functions_Nowak
Mateusz Nowak SAP Integration Consultant, SAP Press Author
icon__calendar 2018-04-25

SAP AIF – Custom Functions creation

Custom functions in SAP AIF (SAP Application Interface Framework) can enhance and speed up your process of monitoring messages and business documents related to the messages.

In this post, I will show you how to quickly create a custom function for inbound sales order interface, that redirects you to Display Sales Order transaction and allows preview of the created Sales Document.

 

It is possible to create a custom function in two ways: in /AIF/CUST_FUNC transaction and directly in the Monitor and Error Handling.

 

How to Create Custom functions in SAP AIF in transaction /AIF/CUST_FUNC?

The first method – the creation of custom function by transaction code gives us the opportunity to adjust it in a more complex way.

In order to create a custom function for your interface go to transaction /n/AIF/CUST_FUNC and provide your namespace, interface name and interface version.

In new Window select New Entries.

Then provide Function Text, Function Tooltip, Function Icon, Message ID, Message Number.
I will use Message ID V1 with message number 311, that informs about type and number of the document, that has been created.

Then choose Skip First Screen and Start in New Session checkboxes. As Custom function type choose Transaction and VA03 as URL. We want to make this custom function visible for all users and only for selected messages in the interface that we provided in the beginning. The final result should look exactly like it’s visible on the below screen:

 

 

Creation of the custom function in AIF in transaction /AIF/CUST_FUNC

Creation of the custom function in AIF in transaction /AIF/CUST_FUNC

 

Save the entry and go to Define Parameter IDs and Values Node and choose New Entries.

In parameter ID you have to provide parameter ID from the VA03 transaction: AUN, that represents Sales Order number. In the message number 311 from V1 ID, the sales order number is stored in variable &2 and that is why you have to choose MSGVAR2 as message variable.

Save the entry and assign it to transport request.

How to create custom function in SAP AIF directly in AIF Monitor and Error Handling?

The second options for doing the same can be done directly in the /AIF/ERR transaction.

The only thing you have to do is to open Error Handling window for the specific interface. Then highlight the specific message in Log Messages and from the menu choose Customize – Custom Functions.

Then provide the information as it is shown on the screenshot below:

Custom Functions in SAP AIF creation directly in Error Handling View

Custom Functions in SAP AIF creation directly in Error Handling View

 

Now in AIF Monitoring and Error Handling in Log Messages for this specific message you will see a function with the icon you provided.

Once you click on it, you will be redirected to the VA03 transaction and Sales Order 38450 will be displayed.

Displaying Sales Order by using Custom Function in SAP AIF

Displaying Sales Order by using Custom Function in SAP AIF

 

This is a very simple trick, that can make working with AIF more pleasant!

Have you ever used custom functions? Do you prefer to maintain it from the transaction code or directly from Monitor and Error Handling window?

Mateusz Nowak SAP Integration Consultant, SAP Press Author
SAP Integration consultant since 2016. Mateusz is the author of SAP Press Book: Interface Monitoring and Error Handling with SAP AIF. He's also a trainer in the openSAP course Virtualize and Automate Your SAP Testing Using Int4 IFTT. Matt has been involved in multiple integrational projects as ABAP Developer, AIF lead and consultant. Skilled at a variety of tools and development techniques including ABAP, AIF, PO, BRFplus, IDocs, Adobe Forms, Smartforms, IDocs, ALE, SCPI.