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 modified.
The JAVA mapping API (SAP NetWeaver 2004 and 7.0) does not support parameterized Java mappings.
Furthermore, in user-defined 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.
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.
To program a Java mapping with the Java mapping API for SAP NetWeaver 2004/SAP SAP NetWeaver 7.0, you must define a Java class that implements the Java interface com.sap.aii.mapping.api.StreamTransformation . This interface has two methods:
public void execute(java.io.InputStream in, java.io.OutputStream out)
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.
public void setParameter(java.util.Map param)
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 flow 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 fields in the message header. Apart from the MAPPING_TRACE constant, the value objects are of type java.lang.String . The key objects are defined in the class com.sap.aii.mapping.api.StreamTransformationConstants :
String Mapping Runtime Constants
Constant |
Meaning |
Relevant for PCK |
MESSAGE_CLASS |
Classification of message. Possible values:
|
Yes |
VERSION_MAJOR |
XI message protocol version. Example: For the XI 3.0 message protocol VERSION_MAJOR = 3 and VERSION_MINOR = 0. |
No The PCK only supports message protocol XI 3.0. |
VERSION_MINOR |
No |
|
PROCESSING_MODE |
The mode of a message can be synchronous or asynchronous. Correspondingly, these constants can have the value synchronous or asynchronous . |
Yes |
MESSAGE_ID |
The message ID. It can change during communication: Response messages get a new message ID. If new messages result from a message (the message is copied at multiple receivers), the new messages get new message IDs. |
Yes |
REF_TO_MESSAGE_ID |
The ID of a referenced message that belongs semantically to this message. For example, a response message uses this field to note which request message it belongs to. |
Yes |
CONVERSATION_ID |
This field is not mandatory in the message. It enables an ID to be used to group messages that belong together. This field is not intended to be used for message serialization and has nothing to do with the serialization context ( ABAP proxy runtime, Java proxy runtime). |
Yes |
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 specified in UTC. If it is a local time, the closing 'Z' is omitted. |
Yes |
INTERFACE |
Sender interface name. As of SAP XI 3.0, use this constant instead of the constant SENDER_NAME used previously. |
Yes |
INTERFACE_NAMESPACE |
Sender interface namespace. As of SAP XI 3.0, use this constant instead of the constant SENDER_NAMESPACE used previously. |
Yes |
SENDER_PARTY |
Communication party that sent the message. |
Yes |
SENDER_PARTY_AGENCY |
Issuing agency for the message sender. |
Yes |
SENDER_PARTY_SCHEME |
Identification scheme used by the sender. |
Yes |
SENDER_SERVICE |
Communication component on the sender side that sent the message. For example, the name of a business system. As of SAP XI 3.0, use this constant instead of the constant SENDER_SYSTEM used previously. |
Yes |
RECEIVER_NAME |
Receiver interface name. |
Yes |
RECEIVER_NAMESPACE |
Receiver interface namespace. |
Yes |
RECEIVER_PARTY |
Communication party to receive the message. |
Yes |
RECEIVER_PARTY_AGENCY |
Issuing agency for the message receiver. |
Yes |
RECEIVER_PARTY_SCHEME |
Identification scheme used by the receiver. |
Yes |
RECEIVER_SERVICE |
Communication component on the receiver side that receives the message. For example, the name of a business system. As of SAP XI 3.0, use this constant instead of the constant RECEIVER_SYSTEM used previously. |
Yes |
MAPPING_TRACE |
Returns an AbstractTrace object that you can use to write messages in the monitoring. |
No |
Implement your Java mapping, for example in SAP NetWeaver Developer Studio (more information: Runtime Environment (Java Mappings) ).
Import your Java libraries to the Enterprise Services Repository as an archive (see Imported Archives (XSLT/Java) ).
The following example shows how the MAPPING_TRACE and RECEIVER_NAME parameters are set and evaluated in a Java mapping program:
import java.io.InputStream; import java.io.OutputStream; import java.util.Map; import java.util.HashMap; import com.sap.aii.mapping.api. AbstractTrace; import com.sap.aii.mapping.api.StreamTransformation; import com.sap.aii.mapping.api.StreamTransformationConstants;
public class JavaMapping implements StreamTransformation {
private Map param = null; private AbstractTrace trace = null;
public void setParameter (Map param) { this.param = param; if (param == null) { this.param = new HashMap(); } }
public void execute(InputStream in, OutputStream out) {
try {
trace = (AbstractTrace)param.get( StreamTransformationConstants.MAPPING_TRACE ); trace.addInfo('...');
// ...
String receiverName = (String)param.get(
StreamTransformationConstants.RECEIVER_NAME);
// ...
}
}
}
More information: Special Access to Mapping Runtime Constants