AIF Archives - INT4 Your soft landing in SAP API testing Wed, 03 Mar 2021 13:33:10 +0000 en-GB hourly 1 https://wordpress.org/?v=6.0.8 SAP AIF – Using Init Function Before Mapping and Init Function Before Processing https://test11988.futurehost.pl/sap-aif-using-init-function-before-mapping-and-init-function-before-processing Thu, 04 Feb 2021 12:16:33 +0000 https://int4.com/?p=9446 Introduction During implementation of an AIF Interface it can happen that some additional logic needs to be added before or after mapping is being done, but still before action processing. Then Init Function Before Mapping and  Init Function Before Processing comes to help us. To define any of those functions go to: /AIF/CUST and then: […]

The post SAP AIF – Using Init Function Before Mapping and Init Function Before Processing appeared first on INT4.

]]>

In this article you will learn:

  • When you can use Init Function Before Mapping
  • When you can use Init Function Before Processing

Reading time: 8 minutes

Introduction

During implementation of an AIF Interface it can happen that some additional logic needs to be added before or after mapping is being done, but still before action processing. Then Init Function Before Mapping and  Init Function Before Processing comes to help us.

Init Function Before Mapping - Mapping - Init Function Before Processing - Action


To define any of those functions go to: /AIF/CUST and then: Interface Development->Define Interfaces

Define Interfeces in SAP AIF


After choosing the interface you can provide Init Function Before Mapping and / or Init Function Before Processing, depending on your needs.

Providing Init Function Before Mapping/Init Function Before Processing


Init Function Before Mapping

You can use this function module to modify or manipulate the data in the source and destination structures before the mapping defined in the AIF is executed.

The function module you use here must have the same signature as the template function module /AIF/FILE_TEMPL_INIT_MAPPING.

The best way to create a correct object is to copy provided template function module /AIF/FILE_TEMPL_INIT_MAPPING into the new one:

Copy Function Module


This way you assure that the function is having the correct signature.

By default your module will be created with a BREAK-POINT inside, which you can use for testing purposes and remove afterwards.

You can manipulate both – destination (“DATA”) and source (“RAW_STRUCT”) structures. Because the template provided by SAP is general-purpose and can be used with all interfaces, those parameters won’t have the predefined structure. Depending on what data you want to manipulate, it is required that you specify the correct data type of the source and destination structures in the newly created function module.

Function-Module-ZINITT_Mapping


After the logic is implemented and the new function module is active we need to add it to the Interface.

To configure this functionality go to:

/AIF/CUST and then: Interface Development->Define Interfaces , choose your interface and provide the name of your custom FM in the field below.

Define Interfaces Move Corresponding Structures Init Function Before Mapping


And that’s it. You have just configured Init Function Before Mapping.

Init Function Before Processing

You can use this function module to modify or manipulate the data in the destination structure after mapping defined in the AIF is executed, but before the processing of the actions starts in the SAP. The init function is processed at the beginning of an action call.

The function module you use here must have the same signature as the template function module /AIF/FILE_TEMPL_INIT_PROCESS.

To create a correct object copy provided template function module /AIF/FILE_TEMPL_INIT_PROCESS into your own one:

Copy Function Module ZINIT_PROCESSING


This way you assure that the function is having the correct signature.

The same, like for Init Function Before Mapping,  by default your module will be created with a BREAK-POINT inside, which you can use for testing purposes and remove afterwards.

For Init Function Before Processing you can only manipulate destination (“DATA”) structure. It will not have a predefined structure as well, so it is required that you specify the correct data type in the newly created function module.

Function module ZINIT_PROCESSING


After the logic is implemented and the new function module is active we need to add it to the Interface.

To configure this functionality go to:

/AIF/CUST and then: Interface Development->Define Interfaces, choose your interface and provide the name of your custom FM in the field below.

Define Interfaces Move Corresponding Structures Init Function Before Processing


And that’s it. You have just configured Init Function Before Processing.

Use cases and summary

Now, when you know how to configure this functionality,  you would probably like to know some examples of the use-cases for both types of functions.

Init Function Before Mapping can be used when:

  • We are processing an IDOC and we need to add additional segments and / or lines. For instance, you need to append an additional line with an information about a default business partner
  • We need to modify some information in the source structure  because this data is being used during mapping to select additional information. For instance, you need to modify business partner ID, because then this value is used in mapping for gathering information about the address
  • You need to validate if the message doesn’t contain duplicates

Init Function Before Processing can be used when:

  • You need to validate if the destination structure contains master data which is already present in the system
  • You need to perform calculations based on the values in the destination structures like for instance total weight of the materials
  • You need to add the discount code based on the total purchase of the customer in the current year

The use-cases I gave are just an example and they will vary depending on the project and requirements. But they can be a good point in better understanding of the capabilities of those functionalities.

Summary

Now, you are ready to use the  Init Function Before Mapping and  Init Function Before Processing in your AIF projects.

Want to learn more about SAP AIF? Check other articles about SAP AIF on Int4 blog.

Read also:

1. SAP AIF – How to create Interface Variants

2. Set up interface in SAP AIF Interface Monitor (/aif/ifmon)

 

 

The post SAP AIF – Using Init Function Before Mapping and Init Function Before Processing appeared first on INT4.

]]>
AIF Index Tables: IDOC qualifiers https://test11988.futurehost.pl/aif-index-tables-idoc-qualifiers https://test11988.futurehost.pl/aif-index-tables-idoc-qualifiers#comments Fri, 28 Feb 2020 13:17:54 +0000 https://www.int4.com/?p=3440 Things get a bit more complicated when it comes to an IDOC scenario. Some IDOC segments contain qualifiers, which hold value that determines other fields within the segment. I.e. in the IDOC basic type INVOICE02 segment E1EDK02 has a BELNR field, that for qualifier = ‘001’ is the Customer Purchase Order number and for qualifier […]

The post AIF Index Tables: IDOC qualifiers appeared first on INT4.

]]>

AIF Index Tables: IDOC qualifiers

AIF allows for indexing field values in order to facilitate filtering out messages in its message monitoring – /AIF/ERR. For this purpose, Index Tables are used. They keep all the data that comes through the particular interface in selected fields.

From this step-by-step manual you will learn:

  • how to deal with IDOC qualifiers when implementing index tables in AIF IDOC scenarios.

Things get a bit more complicated when it comes to an IDOC scenario. Some IDOC segments contain qualifiers, which hold value that determines other fields within the segment. I.e. in the IDOC basic type INVOICE02 segment E1EDK02 has a BELNR field, that for qualifier = ‘001’ is the Customer Purchase Order number and for qualifier = ?009? is the invoice number. This way the same field of a structure can be used to maintain different types of data.

Now let?s say the requirement is to index only BELNR values with these two qualifiers, and to keep them under two separate fields.

While we define our fields of EDI_BELNR data type in Error Handling -> Define Interface- Specific Features-> Define Key Fields for Multi Search we must remember to mark checkbox Key Field Rule. Then, in the Function Module field we pass reference to a FM that contains our logic for processing the BELNR values depending on the qualifier value. 

Define Key Fields for Multi Search

Field Sequence

 

In this sample function module we store BELNR values only if the 3 initial characters of sdata structure (it?s where the qualifier value resides) are equal to ‘009’.

FUNCTION AIF_KEYFIELD_BELNR_001 .
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(IS_RAW_STRUCTURE) TYPE  ANY OPTIONAL
*"     REFERENCE(IS_SAP_STRUCTURE) TYPE  ANY OPTIONAL
*"     REFERENCE(IS_KFLDS) TYPE  /AIF/T_INF_KFLDS
*"  CHANGING
*"     REFERENCE(CS_SIDX_ENTRY) TYPE  ANY
*"----------------------------------------------------------------------
FIELD-SYMBOLS: <lt_idoc_data>   TYPE edidd_tt.

ASSIGN COMPONENT 'ZZBNRINV' OF STRUCTURE cs_sidx_entry TO FIELD-SYMBOL(<fs_ZZBNRINV>).
CHECK <fs_ZZBNRINV> IS ASSIGNED.

ASSIGN COMPONENT 'IDOC_DATA' OF STRUCTURE is_sap_structure TO <lt_idoc_data>.
CHECK <lt_idoc_data> IS ASSIGNED.

IF LINE_EXISTS( <lt_idoc_data>[ segnam = 'E1EDK02' sdata(3) = '009'] ) .
<fs_ZZBNRINV> = <lt_idoc_data>[ segnam = 'E1EDK02' sdata(3) = '009' ]-sdata+3(38).
ELSE.
CLEAR <fs_ZZBNRINV>.
ENDIF .

ENDFUNCTION.

 

However we must keep in mind that this will work only for Single selection type index tables.

Conclusion

If you would like to learn more about AIF Index tables please read these blogs by Mateusz Nowak:

The post AIF Index Tables: IDOC qualifiers appeared first on INT4.

]]>
https://test11988.futurehost.pl/aif-index-tables-idoc-qualifiers/feed 1
/AIF/ERR – AIF Monitoring and Error handling https://test11988.futurehost.pl/aif-err-aif-monitoring-and-error-handling Thu, 20 Feb 2020 14:30:57 +0000 https://www.int4.com/?p=3341 Keep in mind that in order to trace any interface traffic the monitoring functionality has to be set up for a particular interface. If you don’t know how to perform the initial steps please check this blog by Mateusz Nowak:  https://www.int4.com/enable-monitoring-of-idoc-interfaces-in-sap-aif-in-less-than-3-minutes/.  When we initially access /aif/err the first thing that catches the eye is a […]

The post /AIF/ERR – AIF Monitoring and Error handling appeared first on INT4.

]]>

SAP AIF

(Application Interface Framework) is a powerful tool which not only makes it possible to separate business logic from technical mappings but also allows for interface monitoring. In this blog, I would like to shed some light on the AIF error handling solution that can be accessed through /aif/err t-code. 

This blog explains:

  • how to use /AIF/ERR – AIF Monitoring and Error handling tool – from the selection screen up to the results.

Keep in mind that in order to trace any interface traffic the monitoring functionality has to be set up for a particular interface. If you don’t know how to perform the initial steps please check this blog by Mateusz Nowak: 

https://www.int4.com/enable-monitoring-of-idoc-interfaces-in-sap-aif-in-less-than-3-minutes/. 

When we initially access /aif/err the first thing that catches the eye is a complex selection screen divided into different sections. Selection details are required to filter out interfaces and messages we are interested in: 

  • Application Selection: 

In the application selection, we must provide an error handling application?s unique ID. This is the application to be used for Monitoring and Error Handling. By default, it’s always AIF.

AIF Application selection

 

  • Application-Specific Selection

The Next step is to provide the Namespace (2), Interface Name (3) and version (4) of the interfaces we want to monitor. We can provide more than one interface name, but the results will be limited to interfaces within a single namespace. If we would like to view traffic across all interfaces that go through AIF we must leave these selection screen fields empty. 

AIF Application Specific Selection

The easiest way to select a single interface is to use the Select Interface button (7), which reveals a tree-structure view of all available interfaces and their versions. 

AIF select interface

What is worth mentioning we can narrow our search results, even more, limiting them to selected message classes (5) and numbers (6)

 

  • More Specific Selection 

In order to facilitate filtering out the relevant messages, custom selection fields can be set up. This, however, requires creating index tables and additional module pool report for the selection screen. If you would like to get more familiar with this concept please read https://www.int4.com/how-to-create-a-single-index-table-in-sap-aif/

AIF More specific selection

  • Generic Selection

Generic Selection AIF

In Generic Selection we can restrict results to time periods or even specific messages by providing Message GUIDs (8). 

 

  • Status selection

Finally, status selection allows us to view only messages with certain status i.e. which are currently In Process or that stopped processing due to Technical Errors. 

Status selection AIF

Now let’s take a quick look at the Results overview. Initially, it consists of 4 quarters: 

Results overview AIF

  • Data messages (11) containing a list of messages matching our selection criteria. From here we can i.e. restart selected messages, view selected message in WE02 IDOC monitoring (IDOC interfaces), or with a single click check RFC connection (PROXY interfaces)

 

  • Log Messages (12) containing status messages

 

  • Data Structure (13) displaying a message in a tree-like structure. Double-clicking on any of the nodes results in the row data to appear in the last quarter (14) 

 

If we have executed the transaction in the Technical Mode (9) in the results, we will be able to benefit

Additional parameters AIF

from an additional view containing a structure of Interface Processing. It will allow us to determine at which stage of interface processing an error occurred i.e. In this case, we have an error that came up during mapping->checks stage:

Structure of interface aif

The technical view can be switched on while the results are already displayed but be aware that special authorization might be required. Another Additional Parameter that can be useful is an emergency correction (10). If the checkbox is marked all fields of the message can be edited – no matter whether they were defined as editable in AIF customizing or not.

If you want to learn more about AIF’s advanced features, please check these books by our SAP Press authors:

SAP Press books int4

The post /AIF/ERR – AIF Monitoring and Error handling appeared first on INT4.

]]>
8th SAP Press book author in the Int4 team!  https://test11988.futurehost.pl/8th-sap-press-book-author-in-the-int4-team Wed, 15 Jan 2020 16:06:44 +0000 https://www.int4.com/?p=3308 “Mapping with BRFplus Decision Tables and SAP AIF” – a hands-on guide The publication is full of practical tips, examples, and exercises. With this hands-on guide you will : – learn how to maximize BRFplus potential in your business scenarios – check how to enhance your BRFplus projects and build complex BRFplus solutions  – go […]

The post 8th SAP Press book author in the Int4 team!  appeared first on INT4.

]]>

8 SAP Press authors on board

We’re proud to announce that the group of SAP Press book authors in the Int4 team is growing!

In just one week from today, the first SAP Press book by Michał Rohnka – SAP ABAP and integration consultant, will be published. He will be the 8th (what’s interesting, 4 of them are Michałs) SAP Press author in our team and we can ensure you that it’s not the end! 

Congratulations, Michał – great job!

“Mapping with BRFplus Decision Tables and SAP AIF” – a hands-on guide

The publication is full of practical tips, examples, and exercises. With this hands-on guide you will :

– learn how to maximize BRFplus potential in your business scenarios

– check how to enhance your BRFplus projects and build complex BRFplus solutions 

– go into details with all capabilities and configuration offered by BRFplus Decision Tables

– learn how to use BRFplus as an efficient and flexible mapping engine 

– leverage BRFplus and AIF compatibility in your interface projects.

We’re presenting a short book excerpt below:

“In this E-Bite you”ll learn how to create nested decision table calls, using the ability of BRFplus expressions to call each other. You will see how you can call another expression directly from a decision table cell. You will also be introduced with reusability of decision tables with function call expressions, which are BRFplus context mapping tools, allowing you to call other BRFplus functions as though they were expressions. Thanks to that, you can build a generic function with a decision table in it that will be an interface to your decision table and call this interface with different function calls depending on the context available.”

Seems interesting to you? Let us know in the comment below! We’re always ready to discuss.

 

Stay tuned!

Next week we will give more details about the “Mapping with BRFplus Decision Tables and SAP AIF” book. We recommend you to visit the SAP Press website so you can find other interesting publications by our teammates.

We also encourage you to stay up to date with news that we share on the Int4 blog and Int4 LinkedIn page. This way you won’t miss any information about our publications, activities, and projects we get involved in. 

 

The post 8th SAP Press book author in the Int4 team!  appeared first on INT4.

]]>