Start of Content Area

Component documentation JAVA Mapping  Locate the document in its SAP Library structure

Purpose

You can implement mapping programs in Java. Note that the Java mapping API only provides the framework for this, and does not presuppose a specific 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 flexibility 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 Integration Server cannot 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 specification. 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

AbstractTransformation

To implement a Java mapping program, you must define a class that enhances this abstract class and then, within it’s class, implement the transform() method.

Furthermore, by using the getTrace() method in the AbstractTransformation class, you can get a trace object of type AbstractTrace returned (see below).

AbstractTrace

To write information from a mapping program to the runtime trace, use an object of type AbstractTrace (see: AbstractTrace Object). The getTrace() method in class AbstractTransformation returns an object of this type.

TransformationInput
TransformationOutput

Parameter of method transform() to be implemented to access the source message (by using TransformationInput) and to create the target message (output after TransformationOutput).

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.

See also: Parameterized Mapping Programs

InputHeader
OutputHeader

To read from the header fields of the source message (InputHeader) or to set the content type of the target message (OutputHeader), work with these classes.

DynamicConfiguration
DynamicConfigurationKey

Classes for read-from and write-to access to adapter-specific message attributes (see: Java Mapping of Adapter-Specific Attributes).

InputAttachments
OutputAttachments

Classes, to be able to access message attachments in the mapping program. InputAttachments allows access to attachments, that the sender attached to the outgoing message (or messages that were automatically moved from the payload to improve performance (MTOM)). With OutputAttachments you can write the attachments of the target message (there is also a method to copy all the attachments of the outgoing message to the target message).

The following figure gives you an overview of how to access the various parts of a message by using the parameters TransformationInputand TransformationOutput:

This graphic is explained in the accompanying text

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.

There are also APIs available for the following purposes:

      Values mappings
See: Executing Value Mappings

      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 field for read or write purposes at the same time.

      If mapping programs are executed more than once, the content of the static field may be lost. The reasons for this are as follows:

       The content of a static field 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 fields.

Static fields can be used for constants and as a buffer, taking the above-mentioned points into consideration.

 

 

 

 

End of Content Area