The post SAP AIF – Using Init Function Before Mapping and Init Function Before Processing appeared first on INT4.
]]>Reading time: 8 minutes
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: Interface Development->Define Interfaces
After choosing the interface you can provide Init Function Before Mapping and / or Init Function Before Processing, depending on your needs.
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:
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.
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.
And that’s it. You have just configured Init Function Before Mapping.
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:
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.
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.
And that’s it. You have just configured Init Function Before Processing.
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:
Init Function Before Processing can be used when:
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.
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.
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.
]]>The post AIF Index Tables: IDOC qualifiers appeared first on INT4.
]]>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:
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.
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.
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.
]]>The post /AIF/ERR – AIF Monitoring and Error handling appeared first on INT4.
]]>(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:
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:
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.
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.
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.
What is worth mentioning we can narrow our search results, even more, limiting them to selected message classes (5) and numbers (6).
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/.
In Generic Selection we can restrict results to time periods or even specific messages by providing Message GUIDs (8).
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.
Now let’s take a quick look at the Results overview. Initially, it consists of 4 quarters:
If we have executed the transaction in the Technical Mode (9) in the results, we will be able to benefit
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:
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:
The post /AIF/ERR – AIF Monitoring and Error handling appeared first on INT4.
]]>The post 8th SAP Press book author in the Int4 team! appeared first on INT4.
]]>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!
– 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.
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.
]]>