Manage Learn to apply best practices and optimize your operations.

Getting started with NetWeaver RFC to PI data transfers

Data integration in SAP NetWeaver PI can be a complex process. In this book chapter excerpt, you'll find out how to use ABAP programs to transfer master data via the RFC adapter to the PI system. You'll learn the basic principles of this process and read data design best practices.

Data integration in SAP NetWeaver PI can be a complex process. In this book chapter excerpt, you'll find out how...

to use SAP ABAP programs to transfer master data via the NetWeaver RFC adapter to the NetWeaver PI system. You'll learn the basic principles of the RFC-to-PI data transfer process and read data design best practices.

Getting started with NetWeaver RFC to PI data transfers

Configuring and monitoring NetWeaver PI RFC-to-file transfers

Technical Exercises

Using the available concepts and adapters of SAP NetWeaver PI is the
basis for implementing complex integration scenarios. This chapter
shows you how to configure adapters, create mappings, and monitor
scenarios. The individual exercises build on each other and get more
complex to help you gain the knowledge necessary to implement the
case study presented in Chapter 5, SARDIS Case Study in Sales and


Although the individual exercises depend on each other, you can use the
lists of every exercise to track which objects are reused so you can start
with a more advanced lesson. Predefined objects aren’t used in the exercises,
so you can reproduce all of the steps for completing the integration
scenario at any time.

All of the exercises are designed in such a way that they can be performed
by members of a class at the same time. Still, some steps can only
be carried out once. Any steps that must be performed by the instructor
either prior to or during the course will be noted.


Although the exercises are appropriate for workgroups, you can also complete
them on your own. If you do, you should also perform the steps that
would be implemented by the instructor.

Even if you are going to complete the exercises alone, we recommend using
a user number, as this simplifies comparisons between your work and the
described procedure. In this case, you should use the instructor’s number —

Most exercises are completed as a development consultant, and, particularly
in the beginning of the exercise block, you will assume the role
of the system administrator or lead developer. In some places, you will
have the opportunity to develop your own small applications in ABAP
or Java. You hardly need any prerequisites for this, because the sample
listings can be found in Appendix A, Exercise Materials, and in digital
form on the website for this book (

The exercises deal with selected adapters and aspects of the PI environment.
Various elements played a role in selecting the integration scenarios.
On one hand, we present adapters that enable the presentation of
reproducible exercises. On the other, we identify aspects that are necessary
to implement the case study.

Even though the individual exercises do not have to be completed in
the given order, we did choose their order for a reason. In this chapter,
you will implement integration scenarios that will prepare you for the
case study in Chapter 5. Using PI messages, you will create material in
another system and verify its success. In the final step, the creation of
material master data is reported to the person responsible for all materials.
A business process ensures that these reports are delivered in bundles
per agent.

To begin, you will use an ABAP program in system A, which records the
data of a material to be created and transfers this data to the PI system
using the remote function call (RFC) adapter (see Section 4.1, Exercise
1: RFC-to-File). There, the material master record is converted to a file
in PI format via the file adapter. In the next exercise, this file is read by
the file adapter and converted into an intermediate document (IDoc),
which is transferred to and directly processed on system B (see Section
4.2, Exercise 2: File-to-IDoc).

In the third example, you will check to ensure that the material has been
created successfully. Based on an ABAP proxy, you will send a call to
the PI system. This request is converted to a Web service call provided
by system B. The response of this control is synchronously returned to
calling system A (see Section 4.3, Exercise 3: ABAP-Proxy-to-SOAP). The
agent uses an ABAP program to report the successful creation of the
material master records using a business process (see Section 4.4, Exercise 4: Business Process Management). As an alternative to the design of
the second exercise, the example from the second scenario will be readdressed
in a fifth scenario, replacing the receiving IDoc adapter through
a Java database connectivity (JDBC) database (see Section 4.5, Exercise
5: File-to-JDBC).

Even though the contents of the individual exercises are based on one
another, you can start with any of the exercises by using the appropriate

4.1 Exercise 1: RFC-to-File

In the first exercise, you will use your own ABAP program to call a
remote-enabled function module that transfers material master data via
the RFC adapter to the PI system. Once there, the data is converted to PI
XML format and stored as a file. To keep things simple, the file is created
directly on the PI server’s file system.

Although the file technically remains on the PI system, from a logical
viewpoint you will configure the receiving file adapter for system B. The
communication in this integration scenario is asynchronous, because no
business response is returned after sending the material data. The roles
of systems A and B, and the adapters used in this exercise, are illustrated
in Figure 4.1.

Exercise 1: RFC-to-File

Figure 4.1 Scheme of Exercise 1: RFC-to-File

4.1.1 Basic Principles

Because this book does not focus on the development of ABAP programs
and remote-enabled function modules, we will only give you a basic
explanation of the program and function module used. You can get an appropriate transport with the function module and the program for
20 participants and 1 instructor from the book’s web page (http://www.
) and implement it in your system A. For implementing the
transport, consult your landscape administrator, if necessary.

If you want to create the program and the function module yourself, you
will find the corresponding sample source code in Appendix A.
First, log on to the client of system A as the user SYS_A-##. There, you can
view the remote-enabled function module using the Function Builder in
Transaction SE37. Select the function module Z_RFM_MATERIALINPUT_##,
where ## is your participant number.

You will see that from the function module’s point of view the parameters
are only imported and no value is returned. This is one of the
two prerequisites for asynchronous communication from a sending RFC

Except for the interface definition, the function module does not contain
any ABAP code. This means that the function module is used as a kind
of dummy that forwards the transferred data to SAP NetWeaver PI and
serves as an interface. The information about where to forward the data
transferred to the function module is contained in the calling program.

The program Z_PROG_MATERIALINPUT_##, which you can find with the
function module in the same transport request, and that you can view in
Transaction SE38, has two functions: First, it accepts the basic material
master data that will be used to create a new material in system B. Second,
it calls the function module (described earlier) with the parameters
listed in Table 4.1. The naming of these parameters is explained in the
second exercise, in Section 4.2.

In this call, two things need to be mentioned: The remote-enabled function
module is called to a specific destination (i.e., in the system behind
this RFC connection). In the case of destination SystemA_Sender-##, this
is the PI system, so the values transferred to the function module are forwarded
to the PI system. The second aspect is the call in the background
that makes the communication asynchronous.

Transferred Data Description
MATNR Material number
MAKTX Material description
ERSDA Creation Date (will be added automatically)
ERNAM User name of creator (will be added automatically)
MTART Material type
MBRSH Industry sector
MATKL Material group
MEINS Quantity unit
BRGEW Gross weight
GEWEI Weight unit
MTPOS_MARA General item category group

Table 4.1 Data Transferred to the Function Module Z_RFM_MATERIALINPUT_##

4.1.2 Design

At first, you need to create the various data and message types, and the
service interfaces, with the required mappings in the Enterprise Services
Repository. In a later phase of the configuration, these elements will be
linked to the connected business systems (system A and system B).
First, call Transaction SXMB_IFR from one of the connected systems or
from the PI system itself. This opens the PI tools menu in your web
browser, which should look familiar to you if you prepared for the exercises
(see Chapter 3, Basic System Configuration). At the top-left, select
the entry to the Enterprise Services Repository.

After the Java Web Start application has been updated and you have
logged into the PI system as the appropriate user, the user interface of
the Enterprise Services Repository is displayed. Make sure that you do
not log on using the initial password; instead, change it during the logon
to the SAP GUI.

On the left side, you will fi nd the software components that have
already been declared. This includes the software component
SC_Training PI_## with the namespace
training/##, which is where you will store your elements in the Enterprise
Services Repository.

For a better overview, restrict the view to your software component. In
the tree structure, click on your software component, and, above the
tree, click the Only display selected subtree icon. The Enterprise Services
Repository should then look like Figure 4.2.

 Entry to the Enterprise Services Repository

Figure 4.2 Entry to the Enterprise Services Repository

Folders have been introduced with SAP NetWeaver PI 7.1. Their use
is optional, and serves the organizational division of design and configuration elements. Folders can be used in both the Enterprise Services
Repository and the Integration Builder; the Enterprise Services Repository
folder is created via the context menu of a namespace. It is possible
to assign design elements directly to a folder when they are created.
Folders are logically associated with a namespace. Figure 4.3 shows the
namespace in the selection
window and the folder testfolder directly underneath. This folder is in turn associated with the sub subfolder. In the selection window, you
can choose either the superordinate or the subordinate folder.

Creation of Folders in the Enterprise Services Repository

Figure 4.3 Creation of Folders in the Enterprise Services Repository

If you decide to detail the development structure beyond the presented
structure, you can assign already-existing elements to a folder via drag
and drop. For each of the folders, you can create a substructure in the
form of subfolders. These are not limited by their number.

Another advantage of this concept is the authorization administration.
You can assign authorizations to the folders on the group, role, and user
levels. However, because authorization management is not the focus of
this book, we won’t discuss it here in detail.

An overview of the elements required for this exercise is given in Table
4.2. The roles of individual elements and their connections have already
been explained in Chapter 2, SAP NetWeaver PI.


Object Type Sender Side Receiver Side
Service interface Z_RFM_
Message type   MT_Material
Data type   DT_Material
Operation mapping   OM_Z_RFM_MATERIALINPUT_##_to_SI_Material_
Message mapping MM_Z_RFM_MATERIALINPUT_##_to_MT_Material

Table 4.2 Elements in the Enterprise Services Repository for the First Exercise


If the connection to the Enterprise Services Repository is interrupted while
an object is being edited, you can click on the Administration option in the
Process Infrastructure (PI) tools and release the locked object for editing in
the Lock Overview area.

Creating Elements for the Sending System

By using an RFC adapter, this scenario has a particular aspect: all elements
on the sender side are replaced with the interface definition of
the RFC module. The interface is imported from system A and not created
in the Enterprise Services Repository to accelerate work and reduce
the error rate.

To import the RFC interface, expand the bottom directory, Imported
Objects, right-click to open the context menu, and find the Import of
SAP Objects function. In the following window, select the According
to Software Component Version option in the Connection Data area,
because the system data has already been stored (see Figure 4.4). If this
option is not available, enter the host name and the system number (system
A). Next, enter your user SYS_A-## and the appropriate password
before continuing.

The next step lets you choose between RFC and IDoc interfaces. Expand
the RFC option, and all remote-enabled function modules in system A
are determined and displayed. Because this data collection can take a while, when you perform these steps in a group you can import all of
the interfaces before starting the exercise. From the list, select function
module Z_RFM_MATERIALINPUT_## (see Figure 4.5) and continue with the
import .

Import of RFC Interfaces — Login

Figure 4.4 Import of RFC Interfaces — Login

Import of RFC Interfaces — Selection

Figure 4.5 Import of RFC Interfaces — Selection

In the final step of the import process, check your selection and finish
the import. After the import has completed, you can see your newly
imported interface for your software component version in the Imported
Objects • RFC directory. It is marked with a separate icon that indicates
that this element has not been activated yet.

Creating Elements for the Receiving System

While all of the elements are created on the side of the sending system
by importing the RFC interface, you will create a data type, a message
type, and a service interface for the receiving system. We recommend
beginning with the independent elements (i.e., with those on the lowest
hierarchy level), which, in this case, is the data type.

Within your namespace , expand the Data Type directory and open the
creation dialog via the New entry of the context menu. In this window,
you can enter the name of the new object, along with a description (see
Figure 4.6).

The namespace and the software component version are automatically
completed because you called the dialog in the appropriate context. Also,
it is important to note the left area of this screen, which lists the elements
that can be created within the Enterprise Services Repository. You
can change what kind of element you want to create at any time. You will
see a similar structure later when working in the Integration Directory.

Dialog for Creating an Object in the Enterprise Services Repository

Figure 4.6 Dialog for Creating an Object in the Enterprise Services Repository

Name the new data type DT_Material and click on Create. The details
window of a new data type is displayed on the right side. Because the
structure of this window is typical of all detail views in the Integration
Builder, it is used to explain some functions.

Next to the menu line of the Enterprise Services Repository is a separate
details menu; the most important functions of which are also displayed
as icons to its right. In addition to the icons for switching between the
display and changing mode, and for creating a copy, you will also fi nd
an icon for the where-used list of this element (for example) . The icon
group to the right allows you to control the view; for example, you
can hide header data or detach the details window as an independent

In the case of your data type, the lower area of the details window contains
a list of all data type elements. Using the relevant icons, you can
add new rows to the top of the table and enter the elements from Figure
4.7. Please note that this is the type xsd:string. Only the BRGEW element
has the type xsd:decimal; you will perform a calculation using
this value later. In addition, add the missing element NTGEW of the type
xsd:decimal. You will use this element to calculate the net weight of the
material (based on the gross weight) in the message mapping. Save the
data type after all of the elements have been inserted.

Editing a Data Type

Figure 4.7 Editing a Data Type

Because data types in the PI environment are used exclusively for modularizing
data formats, and cannot appear in a mapping or interface themselves,
they are embedded in message types. While data types can only
be assigned to message types in a 1:1 ratio, data types can be combined
in any ratio.

To create a message type, open the appropriate context menu by rightclicking
on the Message Types directory. Select the New option. The
familiar creation dialog box is displayed, this time for a message type.
Name the new object MT_Material and enter a description. Continue
with the detail view by clicking Create. Pay attention to the Data Type
Used area in the middle; this is where you should insert the data type
you just created. You have three ways of doing so:

  • The most obvious method is typing the name and the namespace;
    however, this involves the risk of typos.
  • The second option is to select the object in an ABAP-based SAP system,
    such as in the input help. To do this, click on the hand and question
    mark icon to the right of the namespace field. A window opens,
    containing all of the data types created in your software component
    version for selection. The Name and Namespace fields are then populated.
  • The third option is to drag and drop the selection. This is particularly
    suitable if your software component version contains a lot of data
    types, but there are only a few in your namespace. You can also pick
    the data type from the directory structure to the left and drop it on
    the hand next to the namespace field. Only by dropping it over the
    hand can you ensure a correct data transfer.

As you can see, all three ways work, even without activating the data

After selecting the appropriate data type, the lower area of the details
window shows the structure of the used data type (see Figure 4.8). Check
the structure and save the message type.

Editing a Message Type

Figure 4.8 Editing a Message Type

The last object on the receiver side is the service interface, which determines
if a message can be received or sent, and whether the message is
sent synchronously or asynchronously.

To create this service interface, open the context menu of the corresponding
directory. Enter the name SI_Material_Async_In and an appropriate
description, and then click Create to get to the details window. You can
choose from the Inbound, Outbound, and Abstract options for the interface
category; the individual categories were discussed in Chapter 2.

Because we are dealing with the interface on the receiver side, select
Inbound . The communication mode determines whether a response
regarding the contents is expected or not. Because this is a one-way scenario,
select the Asynchronous mode.

You probably noticed that the input options for message types change
every time the attributes are modified. You should now see the fields for
the Request Message Type and the Fault Message Type . However, you
will only use the former (see Figure 4.9). Using one of the three methods
discussed earlier, select the message type MT_Material as the input message,
and then save your service interface.

Editing a Service Interface

Figure 4.9 Editing a Service Interface

Creating the Mapping Objects

The connection between the elements of the sending and the receiving
side is established via mapping. The contents conversion of the data
formats in the form of message mapping is embedded in the operation
mapping that connects a pair of inbound and outbound interfaces.

To begin, create the message mapping . In your namespace, open the
context menu of the Message Mappings directory. In the creation dialog,
enter the name MM_Z_RFM_MATERIALINPUT_##_to_MT_Material, where ##
represents your participant number. Choose a description and create the

The center area of the details window is divided into two parts, allowing
you to select the sending message type on the left side and the receiving
message type on the right side. First, start with the message type on the
sending side: You can either use the input help, or drag the appropriate
message type to the Enter a source message label. In this exercise,
there is no explicit message type on the sender side, so use the RFC
interface .

Regardless of the selection method, you must choose which RFC message
you would like to use. This is because synchronous communication
is expected for an RFC interface. Therefore, you can choose between Z_RFM_MATERIALINPUT_## and Z_RFM_MATERIALINPUT_##.Response. Select
the former because no response is expected.

The left part of the center area now lists the elements of the RFC interface.
For the receiving part, select your MT_Material message type.

If you look at the elements on the right side, you’ll find a red mark next
to every entry. This indicates an incomplete mapping for the respective
target element. Because we didn’t change anything in the Occurrence
column when creating a data type, the default value of 1..1 is applied.
This means that this element is mandatory. If one of the target fields does
not receive a value from the mapping, an error occurs. The connection
between the elements of the two message types can also be established
via three different methods:

  • The most obvious method is connecting via drag and drop, where it
    isn’t important which side is dragged to the other. The two elements
    are displayed in the lower screen area and connected automatically.
  • The second option is to double-click on the source and target element
    to move them to the lower screen area, where they are displayed as
    rectangles. There you can connect the two rectangles by dragging the
    white area of the sending element to the corresponding area of the
    receiving element. This method should be used if the mapping is
    extended by predefined functions.
  • The third method is suitable for connecting a large number of elements
    of the same name. To do this, parent elements must be selected
    on both sides. In this mapping, these are Z_RFM_MATERIALINPUT_## on
    the sender side, and MT_Material on the receiver side. Then, above
    the sending message type, select the Map selected Fields and Substructures
    if Names are Identical icon. An alert dialog box appears,
    asking you to confirm the action. After dismissing the dialog, all of
    the elements on the sender side are connected to those on the receiver
    side. It’s important to note that mapping of element names is case

Perform a mapping using the third method, and have the result displayed
in the overview by clicking on the Dependencies icon. The two message
types then move apart and give way to the display of connection lines.

You will also notice that the marks next to the receiver elements have
now turned green. Only the NTGEW element is still red, because it was not
automatically provided with a value.

For demonstrating the integrated mapping functions, we assume that
the net weight of the material is 90% of the gross weight. To map this,
first select the NTGEW element on the receiver side, and then the BRGEW
element on the sender side, by double-clicking on these items so both
are displayed in the bottom area. To make this calculation, you first need
a multiplication function that calculates the net weight from the gross
weight with a constant of 0.9.

In the toolbar at the bottom of the screen, select the functions for Constants
and click on the Constant function to the right, which is then
displayed as a rectangle in the work area of the mapping. The cog wheel
means that you can maintain parameters within this function. Doubleclick
on the constant rectangle and change its value to 0.9 for the 90%
of the net weight.

Now change to the Arithmetic area in the toolbar to insert the multiply
function in the work area. Connect the BRGEW and Constant 0.9 elements
to the multiply function by dragging the white subareas. In fact,
these functions would be sufficient for calculating the correct net weight.
However, the three decimal places permitted for the xsd:decimal type
might be exceeded. If this message mapping were tested, it would result
in an error.

Before the result of the calculation can be mapped to the NTGEW element,
it must be formatted using the FormatNumber function from the Arithmetic
functional area. Configure the internal parameter Number Format
of the function so that the result matches the scheme 000.000. Insert the
FormatNumber function between the multiply function and the target
element NTGEW (see Figure 4.10). All rectangles and the mark next to the
NTGEW target element should now be colored green. Save the message

Message Mapping of the RFC-to-File Exercise

Figure 4.10 Message Mapping of the RFC-to-File Exercise

To ensure that the new mapping works, a test function is added to the
Enterprise Services Repository, which you can select via the Test tab in
the top area of the details window. The left side of the test area displays
the structure of the sending message type whose elements are populated
with test values. Be sure to use a decimal point as the decimal character
for the BRGEW element.

The test itself is started with the Start the Transformation icon (indicated
by a vise) at the bottom-left of the test area. If the test program
does not find any errors, the structure of the receiving message type with
its respective values is displayed on the right. In particular, you should
verify whether the NTGEW element has been populated correctly.

The operation mapping is the last object of the integration scenario you
are creating in the Enterprise Services Repository . Start the creation dialog
by opening the context menu of the Operation Mappings directory
in your namespace. Name the operation mapping OM_Z_RFM_MATERIALINPUT_##_
to_SI_Material_Async_In, and then enter a description for the
object. Create it by clicking the Create button.

This object’s detailed view is divided into an upper interface area and a
lower mapping area. In the upper interface area, select the sender interface;
this is the RFC interface Z_RFM_MATERIALINPUT_##. Note that the
RFC interface is not stored in your namespace; instead, you will find it
via the Imported Objects • RFC menu path. Perform the same steps for
the SI_Material_Async_In target interface.

By selecting the two interfaces, you have now specified which interfaces
will communicate with each other and which message types are used.
However, you still need to determine how the two data formats are converted
to each other, because there might be different message mappings
for the same message pair.

In the lower mapping area, click the Read Operations button to display
the message types of the used interfaces (see Figure 4.11). After the
Source and Target Operation fields have been filled, click on the Name
field located between the source and target message fields and select the
input help that appears . A list is displayed, which contains all message
mappings that exist between the interfaces in this sender and receiver
scenario; you should only see mappings of the scheme MM_Z_RFM_MATERIALINPUT_##_
to_MT_Material. Select the mapping with your member

Operation Mapping of the RFC-to-File Exercise

Figure 4.11 Operation Mapping of the RFC-to-File Exercise

If you take a closer look at the Mapping Program area, you will notice
that the tabular structure allows you to select several mappings. All
selected message mappings are processed sequentially according to their order in the table. When creating the message mapping, for example,
you can use the Test tab to perform a test which, in addition to the message
mapping, also checks interface compatibility. Save your operation
mapping after it has been successfully tested.

As you can see, all newly created objects were usable throughout the
entire Enterprise Services Repository, even though they were not activated.
However, you can’t access all of these objects in the Integration
Directory in this state, so the next step is to activate your change.

To do this, go to the directory structure on the left and select the Change
Lists tab. The tree structure is hidden, and your software component
version is displayed, which you should fully expand. Beneath that list,
you will find a Standard Change List containing all newly created objects.
Verify that all elements presented in Table 4.2 are included in the change

Select the Activate option from the change list’s context menu. A window
containing all of the objects of the list is displayed. You have the
option of excluding specific objects from the activation, but activate the
entire list and return to the Objects tab. Notice that the icons indicating
that the new objects are not yet activated have disappeared.


You can also activate individual items via their context menu.

Dig Deeper on SAP Cloud Platform