Powered By

Free XML Skins for Blogger

Powered by Blogger

Wednesday, December 31, 2008

Container Object in XI Message Mappings

Use

This object enables you to cache the values that you want to read again when you next call the same user-defined function. An instance of the container object is transferred to each user-specific function by using the container parameter.

Integration

When using the container object, you do not just temporarily save values for a user-defined function, you also access the following objects as well:

· MappingTrace object to write messages to the trace.

· GlobalContainer object to exchange values between different user-defined functions.

· Map object to access mapping runtime constants.

The following figure shows how the GlobalContainer and Container objects access mapping runtime constants.

This graphic is explained in the accompanying text

Features

Methods of the Container Object

Method(s)

Use

void
setParameter
(String parName, Object obj);

Saves the obj object under the name parName in a container for a user-specific function.

Object
getParameter
(String parName);

Returns the parameter that was saved under the parName name in this user-specific function by using the setParameter method. If no such parameter exists, getParameter returns null.

AbstractTrace getTrace();

Returns a MappingTrace object with which you can transfer messages to the mapping trace.

GlobalContainer getGlobalContainer();

Returns a GlobalContainer object with which you can save the values that can be read by any user-specific functions in the same message mapping.

java.util.Map container.getTransformationParameters()

Returns a map with the mapping runtime constants. For a description of which constants you can access by using this map, see Java Mapping. The constants are attributes of the class com.sap.aii.mapping.api.StreamTransformationConstants (also see the example below).

Example

The following source code queries the constant INTERFACE_NAMESPACE in a user-defined function, displays it as information by using the MappingTrace object and returns it as a result of the function:

AbstractTrace trace;
String headerField;
java.util.Map map;

trace = container.getTrace();

// get constant map
map = container.getTransformationParameters();

headerField = (String) map.get(
StreamTransformationConstants.INTERFACE_NAMESPACE);
trace.addInfo("INTERFACE_NAMESPACE:" + headerField);

return headerField;

At design time, the mapping runtime constants do not yet have any values. Therefore, the mapping editor only displays a test string for each constant in the test environment.

See also: Special Access to Mapping Runtime Constants.

No comments: