Managing Services in The Enterprise Services Repository: Warning
Managing Services in The Enterprise Services Repository: Warning
PUBLIC
Warning
This document has been generated from the SAP Help Portal and is an incomplete version of the official SAP product
documentation. The information included in custom documentation may not re ect the arrangement of topics in the SAP Help
Portal, and may be missing important aspects and/or correlations to other topics. For this reason, it is not for productive use.
This is custom documentation. For more information, please visit the SAP Help Portal 1
2/21/2022
JAVA Mapping
Use
You can implement mapping programs in Java. Note that the Java mapping API only provides the framework for this, and does
not presuppose a speci c kind of implementation. To process XML documents, use Java API for XML Processing (JAXP) , for
example. The JAXP supports the Document Object Model (DOM) and the Simple API for XML (SAX) . This gives you great
exibility for mapping-programming with Java.
Implementation Considerations
Java mapping programs are not permitted to be stateful. Do not write data to a database table during a Java mapping, for
instance. The Process Integration runtimecannot track such side effects. Therefore, if an attempt is made to resend a message
that has not been received by the receiver, the data may inadvertently be written to the database twice in a Java mapping.
If you use JRE classes in your Java mapping programs then the same program restrictions apply as for Enterprise Java Beans
(EJBs). For a detailed description of these restrictions, see the relevant EJB speci cation. Also make sure you read the
information in section Features in Runtime Environment (Java Mappings) .
Features
Classes in Java Mapping API (Package com.sap.aii.mapping.api)
Class(n) Use
You access the various different parts of the message by using the
relevant methods of these classes. An object of a type from the
following classes is then returned in each case.
InputPayload OutputPayload Object for reading from ( InputPayload ) and writing to the
payload ( OutputPayload ). You access the payload by using a
Stream ; this means that you are free to choose the actual method
of access yourself.
InputParameters OutputParameters To access the parameters of the Java mapping program, use the
methods of these classes.
InputHeader OutputHeader To read from the header elds of the source message (
This is custom documentation. For more information, please visit the SAP Help Portal 2
2/21/2022
InputHeader ) or to set the content type of the target message (
OutputHeader ), work with these classes.
The following gure gives you an overview of how to access the various parts of a message by using the parameters
TransformationInput and TransformationOutput :
You must connect the Java mapping API to your application environment (see: Runtime Environment (Java-Mappings) ). The
runtime environment also comprises additional classes that developers can include in their implementation at required.
This is custom documentation. For more information, please visit the SAP Help Portal 3
2/21/2022
Programming lookups in mapping programs See: Mapping-Programme um Lookups erweitern
For more information about the Java mapping API, see SAP Developer Network at
https://www.sdn.sap.com/irj/sdn/javadocs (SDN user required).
Note
You can still use the previous Java mapping API (see: Java Mapping API (SAP NetWeaver 2004 und 7.0) ).
Restrictions
Note the following points when using static variables in Java mappings:
Mappings can be executed in parallel. Therefore, several instances of a mapping may access a static eld for read or write
purposes at the same time.
If mapping programs are executed more than once, the content of the static eld may be lost. The reasons for this are as
follows:
The content of a static eld is lost if the Java class in question is reloaded. This happens after a cache refresh, for
example.
If the mapping runtime consists of a cluster, the mapping classes on each node of the cluster are loaded
separately. Each node has its own static elds.
Static elds can be used for constants and as a buffer, taking the above-mentioned points into consideration.
Use
The Process Integration runtime uses the runtime environment for Java mappings to execute Java mapping programs. In
addition to the mapping API you can use other standard libraries of the SAP JEE server in loaded Java mapping programs.
Prerequisites
You are using the SAP NetWeaver Developer Studio.
To be able to write a mapping program in your Java development environment, the Java runtime environment (JRE) of the SAP
JEE server must be consistent with the JRE version of your Java development environment.
Features
The mapping runtime environment consists of the following runtime components:
sapxmltoolkit The
http://help.sap.com/saphelp_nw70/helpdata/en/36/ef353e39011a38e10000000a114084/frameset.htm contains a
JAXP implementation.
The SAP XML Toolkit will be replaced by version 5 of the Java Development Kit (JDK). More information: XSLT Mapping .
This is custom documentation. For more information, please visit the SAP Help Portal 4
2/21/2022
com.sap.mw.jco The SAP Java Connector enables ABAP-APIs to be called from the Java mapping. See the
corresponding Javadoc documentation in the SAP Developer Network at
https://www.sdn.sap.com/irj/sdn/javadocs (SDN user required).
com.sap.tc.Logging The SAP Logging Service enables integration with the Application Server Management tools.
See the corresponding Javadoc documentation in the SAP Developer Network at
https://www.sdn.sap.com/irj/sdn/javadocs (SDN user required).
Java programs that are loaded in an imported archive can use classes from the JRE, the mapping API, and these three standard
libraries.
If you use JRE classes in your Java mapping programs then the same program restrictions apply as for Enterprise Java Beans
(EJBs). This includes the following, for example (for a detailed description, see the relevant EJB speci cation):
Do not load a JDBC driver to use them directly. Instead, use the mapping lookup API (see: Mapping Lookups ), or the JDBC
Connector Service in the SAP JEE Engine.
Do not use the package java.io to write directly to les, or use it to read directly from les.
Also ensure that you read the implementation considerations and restrictions in Java Mapping .
The mapping runtime environment is determined by the software component version and the namespace of the Java mapping to
be executed. The environment also has a speci c search sequence when loading the classes. If the mapping runtime environment
nds a class in a path, the search is terminated and the subsequent paths are ignored. The paths are searched in the following
sequence:
2. The path in which the mapping API is saved and the path of the standard libraries (SAP XML Toolkit, SAP Java Connector,
SAP Logging Service), see above
3. Imported archives in the same namespace and the same software component version as the Java mapping to be
executed
4. Imported archives in the same namespace and a subordinate software component version
7. Note that you can only load a class from the other namespaces if it is unique there.
Activities
Accessing the Runtime Environment in the SAP NetWeaver Developer Studio
Mapping API
To access the mapping API in a Java project in SAP NetWeaver Developer Studio, proceed as follows:
This is custom documentation. For more information, please visit the SAP Help Portal 5
2/21/2022
1. Choose Properties in the context menu for the Java project in which you want to apply the mapping API.
2. In the navigation tree choose Java Build Path and then choose the Libraries tab page.
4. From the list of classpath variables, select SAP_SYSTEM_ADD_LIBS and choose Extend .
5. Enhance the variable with the following path: comp SAP_XIAF DCs sap.com com.sap.aii.mapping.lib.facade _comp
gen default public api lib java com.sap.aii.mapping.api. lter.jar
For more information about the mapping API (and the lookup API it contains) refer to SAP Developer Network at
https://www.sdn.sap.com/irj/sdn/javadocs (SDN user required) and SAP NetWeaver Developer Studio:
Help Help Content SAP NetWeaver Developer Studio Documentation API Reference SAP NetWeaver 7.10 for Process
Integration comp.sap.aii.mapping.api .
To include the three J2EE standard libraries in the class path of SAP NetWeaver Developer Studio, proceed as follows:
1. Call the context menu for your Eclipse project and choose Properties .
sapxmltoolkit
comp/ENGINEAPI/DCs/sap.com/sapxmltoolkit/_comp/gen/default/public/default/lib/java/
com.sap.mw.jco
comp/ENGINEAPI/DCs/sap.com/com.sap.mw.jco/_comp/gen/default/public/default/lib/java/
com.sap.tc.Logging
comp/ENGINEAPI/DCs/com.sap.tc.Logging/_comp/gen/default/public/default/lib/java/
Use
At con guration time you complete a value mapping table in the Integration Directory. In this table, values that are identical
semantically are summarized in a group.
The mapping runtime provides an API to determine a target value for a source value during a Java mapping.
Features
Source and Target Representation
This is custom documentation. For more information, please visit the SAP Help Portal 6
2/21/2022
It is possible for an object (for example, a material number) to be identi ed differently at the receiver than at the sender; in this
case, an object is said to have different representations . An object representation consists of:
The identi cation scheme used (for example, the scheme "customer number")
The value of the object, which is dependent on the identi cation scheme, the issuing agency, and the value mapping
context
The package com.sap.aii.mapping.value.api contains the interfaces IFIdentifier , IFRequest , and IFResponse .
You request objects for these interfaces to describe such representations. You use IFIdentifier to construct IFRequest ,
and when you execute the value mapping an object of type IFResponse is returned.
To make a value mapping request, use an object of type IFRequest . You construct the request by using a source label, a target
label (both are objects of type IFIdentifier ), and the source value. The result of the value mapping is an object of type
IFResponse , which you can use to query one or more target values in addition to the information in the request.
Note
Alternatively, you can execute a value mapping by transferring all required values to the method executeMapping() in a
call (see below).
To make a request and execute a value mapping, you use a factory class and a service class. The methods of these classes are
described below. The interface methods consist merely of access methods for the respective values:
This is custom documentation. For more information, please visit the SAP Help Portal 7
2/21/2022
Methods of the Interface IFRequest
public java.lang.String getSingleTargetValue () Individual target value. If no valid target value is found, the method
returns the null value. If more than one target value is found, the
method returns the rst value (determined randomly).
To make sure that there is only one target value, use the method
countTargetValues() . To query null values, you can also use
the method hasTargetValues() .
public java.lang.String[] getTargetValues () All possible result values for the request
public boolean hasTargetValues () true , if there is at least one result value; false if not.
Mapping Request
Method Use
public static IFIdentifier newIdentifier Returns a label for the transferred values
( java.lang.String context, java.lang.String
agency, java.lang.String scheme)
public static IFRequest newRequest Returns a value mapping request for a source label, target label, and
( IFIdentifier sourceIdentifier, IFIdentifier source value
targetIdentifier, java.lang.String sourceValue)
Method Use
This is custom documentation. For more information, please visit the SAP Help Portal 8
2/21/2022
public XIVMService () Constructor
ValueMappingException
public static IFResponse executeMapping Returns a value mapping result for a value mapping request
(IFRequest request)
throws ValueMappingException
public static IFResponse[] executeMapping Returns the value mapping results for several value mapping
(IFRequest[] requests) requests
throws ValueMappingException
The exception ValueMappingException of the method executeMapping() is only thrown if an error occurs during the
execution of the value mapping or if the value cannot be mapped for other reasons.
Use
There is a header for adapter-speci c message attributes in the message header of an XI message where sender adapters can
write additional information in the message header. In this way sender adapters can write information that only becomes known
at runtime into the message.
Developers can also get read and write access to adapter-speci c attributes in a Java mapping program.
Integration
There are mapping rutime contants for XSLT programs (J2EE) and message mappings that developers can use to access to the
same Java classes for mappings of adapter-speci c attributes as in Java mapping programs. Mapping programs that are
executed on the Integration Server supports this access.
There is a special interfaces for accessing ABAP Mappings (see interface documentation for interface
IF_MAPPING_DYNAMIC_CONF).
Features
The key for accessing the value of an adapter-speci c attribute is made up of a namespace and an attribute name that belongs
to the adapter. There are, for example, the following attributes for the le adapter:
The adapter namespace comprises the namespace in the Enterprise Services Repository in which the Adapter Metadata for the
adapter is saved and the name of the adapter metadata object. The adapter namespaces for the adapters shipped by SAP
therefore have the following format:
The adapter metadata objects are in namespace http://sap.com/xi/XI/System of software component SAP BASIS .
Mapping API
The classes for accessing the adapter-speci c attributes are part of the mapping API (package com.sap.aii.mapping.api ):
com.sap.aii.mapping.api.DynamicConfiguration Key
com.sap.aii.mapping.api.DynamicConfiguration
Class to read, change, or delete the value of an adapter-speci c attribute. You access the attributes in the methods using
objects of DynamicConfigurationKey .
For more information on the Mapping API, see SAP Developer Network as of SAP NetWeaver '04 SPS14 under
https://www.sdn.sap.com/irj/sdn/javadocs (SDN user required).
The question remains for a Multi-Mapping about how to deal with a variety of message headers with adapter-speci c attributes.
Basically, the Mapping API can only access one message header. This has the following consequences, depending on whether
there are multiple source or target messages:
1:n transformation
If there are multiple target messages, the header for the adapter-speci c attributes is copied for each message. You
cannot create individual headers for the adapter-speci c attributes for each message, but one header for all.
n:1 transformation
This variant is only possible for multi-mappings in integration processes. If there is more than one source message, then it
is not possible to have read-only access to the adapter-speci c attributes of the different message headers at runtime.
m:n transformation
The restrictions mentioned above apply here. Here, developers can write the same adapter-speci c attributes for all
target messages to the header without having to have read-only access the source message. m:n transformations are
only supported in integrations processes.
Use
Although the JAVA mapping API has been revised (see: Java Mapping ) and SAP recommends that you use this new API for new
Java mapping programs, the JAVA mapping API for SAP NetWeaver 2004 and SAP NetWeaver 2004 and 7.0 remains a feature of
SAP NetWeaver. Consequently, all JAVA mapping programs that you implemented using the Java mapping API for SAP
NetWeaver 2004 or SAP NetWeaver 7.0 are still valid and do not need to be modi ed.
This is custom documentation. For more information, please visit the SAP Help Portal 10
2/21/2022
Caution
The JAVA mapping API (SAP NetWeaver 2004 and 7.0) does not support parameterized Java mappings.
Furthermore, in user-de ned functions of message mapping programs, you continue to access the constants of the mapping
runtime by using the JAVA mapping API for SAP NetWeaver 2004/SAP SAP NetWeaver 7.0.
Prerequisites
Ensure that you read the implementation considerations and restrictions in Java Mapping . These also apply for the Java
mapping API for SAP NetWeaver 2004 / SAP NetWeaver 7.0.
Features
To program a Java mapping with the Java mapping API for SAP NetWeaver 2004/SAP SAP NetWeaver 7.0, you must de ne a
Java class that implements the Java interface com.sap.aii.mapping.api.StreamTransformation . This interface has two methods:
The Process Integration runtime calls this method to execute a mapping. This method receives an input stream for the
source document and an output stream for the target document as parameters. These streams are usually XML
documents. You can parse the substructures to be converted from the input stream and output the converted target
document in the output stream.
The Process Integration runtime transfers parameters to the mapping program with this method. It evaluates these
parameters at runtime in the method execute() . This enables you to control the process ow of the mapping.
The transferred object that implements the Java interface java.util.Map contains seven key/value pairs as parameters.
These correspond to corresponding elds in the message header. Apart from the MAPPING_TRACE constant, the value objects
are of type java.lang.String . The key objects are de ned in the class
com.sap.aii.mapping.api.StreamTransformationConstants :
Constant Meaning
VERSION_MINOR
This is custom documentation. For more information, please visit the SAP Help Portal 11
2/21/2022
Response messages get a new message ID.
TIME_SENT Time stamp specifying when the message was sent by the sender.
The format of the time stamp is as follows:
YYYY-MM-DDTHH:MM:SSZ
The letter 'T' separates the date from the time, which is generally
speci ed in UTC. If it is a local time, the closing 'Z' is omitted.
INTERFACE Sender interface name. As of SAP XI 3.0, use this constant instead
of the constant SENDER_NAME used previously.
MAPPING_TRACE Returns an AbstractTrace object that you can use to write messages
in the monitoring.
Activities
1. Implement your Java mapping, for example in SAP NetWeaver Developer Studio (more information: Runtime Environment
(Java Mappings) ).
This is custom documentation. For more information, please visit the SAP Help Portal 12
2/21/2022
2. Import your Java libraries to the Enterprise Services Repository as an archive (see Imported Archives (XSLT/Java) ).
Example
The following example shows how the MAPPING_TRACE and RECEIVER_NAME parameters are set and evaluated in a Java
mapping program:
public void setParameter (Map param) { this.param = param; if (param == null) { this.param = new HashMap(); } }
try {
// ...
StreamTransformationConstants.RECEIVER_NAME);
// ...
Use
In some mapping programs it may be necessary to access elds in the message header. For this purpose, the mapping runtime
saves the eld values as key-value pairs.
Key Value
MessageClass ApplicationMessage
ProcessingMode synchronous
ReceiverNamespace http://com.sap/xi/example
This is custom documentation. For more information, please visit the SAP Help Portal 13
2/21/2022
The keys are derived from the eld names of the elds in the message header.
To be able to read the elds of the message header at runtime, you must access the map for the runtime constants. However, if
you were to access the map by using the keys speci ed above and one of the keys were to change, the program code would be
rendered invalid. For this reason, the mapping API provides string constants that can be used to access the map in place of the
keys.
MESSAGE_CLASS MessageClass
VERSION_MAJOR VersionMajor
VERSION_MINOR "VersionMinor"
PROCESSING_MODE "ProcessingMode"
MESSAGE_ID "MessageId"
REF_TO_MESSAGE_ID "RefToMessageId"
CONVERSATION_ID "ConversionId"
TIME_SENT "TimeSent"
INTERFACE "Interface"
INTERFACE_NAMESPACE "InterfaceNamespace"
SENDER_PARTY "SenderParty"
SENDER_PARTY_AGENCY "SenderPartyAgency"
SENDER_PARTY_SCHEME "SenderPartyScheme"
SENDER_SERVICE "SenderService"
RECEIVER_NAME "ReceiverName"
RECEIVER_NAMESPACE "ReceiverNamespace"
RECEIVER_PARTY "ReceiverParty"
RECEIVER_PARTY_AGENCY "ReceiverPartyAgency"
RECEIVER_PARTY_SCHEME "ReceiverPartyScheme"
RECEIVER_SERVICE "ReceiverService"
MAPPING_TRACE "MappingTrace"
How the access works varies according to where you want to query the runtime constants:
In Java mappings you work with the get -methods of the mapping API.
Within a user-de ned function of a message mapping, you can access the map either by using the method
getTransformationParameters() of the container object or by using the method getParameters() of the
GlobalContainer object. See: Container Object .
If you are still working with the SAP NetWeaver 2004/SAP SAP NetWeaver 7.0 JAVA mapping API, you must code the
method setParameter within a JAVA mapping to be able to access the map. More information: Java-Mapping-API (SAP
This is custom documentation. For more information, please visit the SAP Help Portal 14
2/21/2022
NetWeaver 2004 and 7.0) .
In certain exceptional and unavoidable cases, it may be necessary to use the keys to access the elds in the message header.
This is always the case when you want to access the contents of the map by means of a variable. In the example below, a variable
key key , which is to be used to read a eld in the message header, is transferred to a user-de ned function of a message
mapping. You can only use a variable to access the map if the variable has the name of the key as its value and not the name of
the string constant.
map = container.getTransformationParameters();
For example, to read the message ID from the message header, the variable key must have the value MessageId and not
MESSAGE_ID.
Note
Since the new mapping API works with get-methods, you can only access the message header in this way when you are using
the SAP NetWeaver 2004 and 7.0 JAVA mapping API.
This is custom documentation. For more information, please visit the SAP Help Portal 15