SAP®
Release: 4.0
Authors: Thomas
Elsässer,
Verena
Wörner, Enrico
Mraß, Yaping
Gao, Eric
Hong, Gabriele
Moll
© 2012 SAP AG
Dietmar-Hopp-
Allee. 16
D-69190 Walldorf
HORIZON
COOKBOOK
SAP Application Interface
Framework
Cookbook
History
Version
4.0
Status
Released
Date
10.10.2012
SAP Application Interface Framework
Page 1 of 49
Title:
Version: 4.0
Date:
10.10.2012
SAP®
Content
COOKBOOK
1
1.1
1.2
2
3
Organization ......................................................................................... 3
Project Team / Development Team ................................................................. 3
Document References..................................................................................... 3
Target of this Document ..................................................................... 3
Architecture Overview ......................................................................... 4
4
Implementation with the SAP Application
Interface
Interface
Framework ........................................................................................... 6
4.1
Prerequisites and Preparation ......................................................................... 6
4.2
Customizing of Interfaces with the SAP Application Interface Framework ....... 8
4.2.1 Namespaces ................................................................................................... 9
Interfaces ...................................................................................................... 10
4.2.2
4.2.3
Interface Engines .......................................................................................... 12
Value Mapping .............................................................................................. 14
4.2.4
4.2.5
Fix Values ..................................................................................................... 19
4.2.6 Checks .......................................................................................................... 21
Actions .......................................................................................................... 24
4.2.7
Structure Mapping ......................................................................................... 26
4.2.8
4.2.9
Interface Determination ................................................................................. 33
4.2.10 Error Handling ............................................................................................... 34
Interface Variants .......................................................................................... 37
4.2.11
4.3
Implementation of Subscreen with Key Fields ............................................... 42
4.3.1 Creating a Single Index Table ....................................................................... 42
Implementation of Subselection Screen with Key Fields ................................ 43
4.3.2
4.3.3
Assign Subselection Screen and Single Index Table ..................................... 43
4.3.4 Define Key Fields .......................................................................................... 44
BAdIs for the Error Handling Application Toolbars ......................................... 45
4.4
5
Enable Users to Monitor Interfaces .................................................. 49
SAP Application Interface Framework
Title:
Version: 4.0
Date:
10.10.2012
Page 2 of 49
© 2012 SAP AG
Dietmar-Hopp-
Allee 16
D-69190 Walldorf
SAP®
COOKBOOK
1 Organization
1.1 Project Team / Development Team
Name
Company
Project Role(s) / Comments
Thomas Elsässer
SAP AG
Solution Architect
Yaping Gao
Enrico Mraß
Verena Wörner
Gabriele Moll
Eric Hong
Lianyue Li
SAP AG
SAP AG
SAP AG
SAP AG
SAP AG
SAP AG
1.2 Document References
Solution Architect
Solution Developer
Solution Developer
Solution Developer
Solution Developer
Solution Developer
[OnlineDocu]: Online Documentation including information for business users and system ad-
ministrators (http://help.sap.com/ SAP ERP Add.Ons SAP Application Interface Frame-
work)
2 Target of this Document
This document describes how to develop interfaces with the SAP Application Interface Frame-
work. It can be used as a step-by-step manual.
The following chapters provide an overview of the structured approach to the implementation of
the interfaces using the SAP Application Interface Framework. The features and functionality
outlined in the following chapters refer to the functionality of the SAP Application Interface
Framework 2.0.
The interface implementation consists of two parts. The first part is dependent on the interface
technology you want to use and will not be part of this cookbook. For example, if you want to
use an ABAP proxy interface the first step is to a design service interface in the SAP NetWeaver
PI. The cookbook focuses on the second step, which is the implementation and Customizing of
the interface in the SAP Application Interface Framework.
Chapter 3 gives an overview of the system architecture needed for the SAP Application Inter-
face Framework.
Chapter 4 describes the implementation of the interface with the SAP Application Interface
Framework. This chapter explains the different Customizing activities that are available.
Chapter 5 gives you a task oriented view on how to create an interface. This chapter contains a
short overview of how to enable users to monitor interfaces in the Interface Monitor.
SAP Application Interface Framework
Title:
Version: 4.0
Date:
10.10.2012
Page 3 of 49
© 2012 SAP AG
Dietmar-Hopp-
Allee 16
D-69190 Walldorf
SAP®
COOKBOOK
3 Architecture Overview
The SAP Application Interface Framework is located on an SAP application system (for example
an ERP or CRM system). Figure 1 gives an overview of the system architecture containing the
SAP Application Interface Framework. The figure displays a system architecture, where data is
received from the SAP NetWeaver PI. However, the SAP Application Interface Framework sup-
ports also several IDoc scenarios as well as an own runtime and persistence layer.
Figure 1: SAP Application Interface Framework – Architecture Overview with SAP
NetWeaver PI
Data is send to the SAP system where the SAP Application Interface Framework is located. The
SAP application system receives the data and calls the SAP Application Interface Framework.
In the SAP Application Interface Framework, received data is processed. The data is trans-
formed from the raw data structure (source) to the SAP data structure (destination). During this
transformation, checks can be executed. If a check does not succeed, further processing of the
message in the SAP Application Interface Framework stops. Value mappings are executed to fill
the SAP data structure. After all the data is mapped from the raw data structure to the SAP data
structure, actions are called. Actions are used to execute the business logic of the interface in
the SAP Application Interface Framework. Within an action, you can call an SAP standard func-
tion, your own customer-specific function, or a BAPI. The mapping of data, the executed
checks, value mappings, and actions depend on the Customizing of the interface (see chap-
ter 4), which is done by the interface developer.
Errors that occur while processing a message in the SAP Application Interface Framework, for
example, if a check does not succeed or if a value mapping fails, are written to the application
log. Application log messages are loaded into the Monitoring and Error Handling transaction
SAP Application Interface Framework
Title:
Version: 4.0
Date:
10.10.2012
Page 4 of 49
© 2012 SAP AG
Dietmar-Hopp-
Allee 16
D-69190 Walldorf
SAP®
COOKBOOK
and support the business user in solving errors. Additionally, you can configure the system to
send alerts to users, if certain errors occur during message processing.
The process described above is concerned with how data is received by the SAP Application
Interface Framework. It is also possible to send data using the SAP Application Interface
Framework. Therefore, an outbound interface is needed. To start the processing, a report, func-
tion module, or batch job is necessary to call the SAP Application Interface Framework. In the
SAP Application Interface Framework, data is mapped from the SAP data structure (source) to
the raw data structure (destination). Customized checks and mappings are executed and errors
that occur are written to the application log. If the processing in the SAP Application Interface
Framework is successful, the data will be send to the receiver.
© 2012 SAP AG
Dietmar-Hopp-
Allee 16
D-69190 Walldorf
SAP Application Interface Framework
Title:
Version: 4.0
Date:
10.10.2012
Page 5 of 49
SAP®
COOKBOOK
4 Interface Implementation with the SAP Application
Interface Framework
4.1 Prerequisites and Preparation
Depending on the interface technology you use different prerequisites apply and different steps
have to be executed in preparation to developing an interface with the SAP Application Interface
Framework. This chapter will give a general overview of the steps required before an interface
can be developed with the SAP Application Interface Framework.
Some of the steps required as preparation are similar for different technologies
Find or create BAPI(s) and function module(s): Usually, the business logic in the
backend is executed by methods (for example, of business objects), BAPIs, or function
modules. These could be predefined by SAP or implemented specifically for your com-
pany. In order to call these objects in an action of the SAP Application Interface Frame-
work later on (see chapter 4.2.7), you need your data to be in the format or structure
they expect. To achieve this, you have to build your SAP data structure to accommo-
date the required data and their expected format.
Create SAP (target / source) data structure: This data structure is required for pass-
ing values during the processing of the function modules. The structure can consist of a
hierarchy of substructures and tables.
For an outbound interface, the SAP data structure constitutes the source structure. Its
components are usually defined by the format of the data stored in the system. When
defining the SAP data structure, you collect all the data and corresponding data types
you want to send to an external system and include them in the SAP data structure.
During the runtime of the SAP Application Interface Framework, the data of the SAP da-
ta structure is mapped to the destination structure. Furthermore, the SAP data structure
is available in several function modules as the source structure.
For an inbound interface, the SAP data structure constitutes the destination structure.
Its components are usually defined by the class methods or function modules you want
to execute in the system. When defining the SAP data structure, you collect all the nec-
essary input data and corresponding data types and include them in the SAP data struc-
ture. During the runtime of the SAP Application Interface Framework, the data of the
source structure is mapped to the SAP data structure. Furthermore, the SAP data struc-
ture is available in several function modules as the destination structure.
Example of a source structure:
ZGTP_AIF
o ZAIF_HEADER_AND_ITEM1_T
ZAIF_HEADER
ZAIF_ITEM_T
o ZAIF_HEADER_AND_ITEM2_T
ZAIF_HEADER2
ZAIF_ITEM_T2
o ZAIF_ADD_DATA_T
Structure
Table Type
Structure
Table Type
Table Type
Structure
Table Type
Table Type
SAP Application Interface Framework
Title:
Version: 4.0
Date:
10.10.2012
Page 6 of 49
© 2012 SAP AG
Dietmar-Hopp-
Allee 16
D-69190 Walldorf
SAP®
COOKBOOK
o ZAIF_GLOBAL_DATA
Structure
4.1.1.1 Proxy Interfaces
Interface Framework. Within
A service interface has been created in the Enterprise Service Repository and a proxy class and
structure has been generated for the service interface in your backend system. After generating
the proxy class and structure, you need to implement the proxy method to call the SAP Applica-
tion
this method, static method PROCESS of class
/AIF/ENABLER_PROXY needs to be called. The method passes the data to the SAP Applica-
tion Interface Framework and starts processing data. To implement the method, double click on
the generated proxy class. Select the proxy method and implement it like in the following cod-
ing:
METHOD ~.
/aif/cl_enabler_proxy=>process_message(
is_input = input
iv_exception_classname = 'ZCX_FAULT'
).
ENDMETHOD.
Note: You have to exchange the exception class name one that belongs to your service inter-
face. To get the name, access the proxy class you generated and choose Exceptions. Further-
more, the name of the method differs.
4.1.1.2
IDoc Interfaces
Decided on scenario: To monitor IDocs with the SAP Application Interface Frame-
work four scenarios exist. Decide which scenario you want to use, this will depend
on your requirements and business needs. Following Scenarios exist:
o Monitoring of existing IDocs in Monitoring and Error Handling
o Process IDoc Using AIF; Call IDoc Function Module in Action
o Process IDoc Using AIF; Call BAPI in Action
o Process IDoc Using ALE; Wirthe Index Tables with AIF Enabler
Depending on the scenario you select you might have to create a new IDoc basic
type and message type.
4.1.1.3 XML Interfaces
If you want to use the XML persistence and runtime delivered with the SAP Application Interface
Framework, you have to create, for example a report or function module where you trigger pro-
cessing in the runtime. Depending on the data you want to process you have to define a struc-
ture for your interface in the SAP Application Interface Framework.
4.1.1.4
Interfaces for the Error and Conflict Handler
For an ECH interface you need to define an interface in the Enterprise Service Repository and
generate a proxy class in your backend system. How the implementation of the proxy method
will look like depends on the integration scenario you select. Two scenarios exist for the integra-
tion for the Error and Conflict Handler and the SAP Application Interface Framework:
SAP Application Interface Framework
Title:
Version: 4.0
Date:
10.10.2012
Page 7 of 49
© 2012 SAP AG
Dietmar-Hopp-
Allee 16
D-69190 Walldorf
SAP®
COOKBOOK
Display messages of ECH in Monitoring and Error Handling
Display Messages Processed with SAP Application Interface Framework in ECH
4.2 Customizing of Interfaces with the SAP Application Inter-
face Framework
Customizing for the SAP Application Interface Framework can be reached via transaction code
/AIF/CUST or via the SAP Easy Access menu by choosing Cross-Application Components
SAP Application Interface Framework Interface Development Customizing. The Customiz-
ing tree of the SAP Application Interface Framework is displayed in Figure 2. Note: Some of the
activities displayed in the customizing tree are only available if component AIFX is installed.
SAP Application Interface Framework
Title:
Version: 4.0
Date:
10.10.2012
Page 8 of 49
© 2012 SAP AG
Dietmar-Hopp-
Allee 16
D-69190 Walldorf