Adapter Specific Message Attributes (ASMA) – dynamic configuration of communication channels

Basic function of SAP PI mappings is tu build target message content.Technical parameters, such as file name, path, target host address, are usually configured in Communication Channels.

Sometimes it is necessary to set these parameters dynamically – depending on the source data. For the most simple cases (such as changing target file name) one can use Variable Substitution method, but much more possibilities can be offered by ASMA (Adapter-Specific Message Attributes).

For the majority of PI adapters there is a set of Communication Channel attributes, that can be defined in PI message header using Dynamic Configuration objects. For particular attributes dynamic configuration with ASMA can be enabled in Advanced tab of Communication Channel details:

Adapter Specific Message Attributes (ASMA)

Adapter Specific Message Attributes (ASMA)

ASMA dynamic configuration in User Defined Functions (UDF) in Java

Message attributes in dynamic configuration can be set using UDF (User-Defined Functions). Every user-defined function includes Container-class object as a parameter. With its methods, one can get Dynamic Configuration object:

[codesyntax lang=”java”]

DynamicConfiguration conf = (DynamicConfiguration) container
 .getTransformationParameters()
 .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

[/codesyntax]

The next step is to create key & value pairs for each object to be configured, keeping in mind a relevant namespace for the given Communication Channel type. Here are some sample attributes for selected Communication Channels:


File Adapter – namespace: http://sap.com/xi/XI/System/File

  • FileName
  • Directory
  • TargetTempFileName (if used)

Mail Adapter – namespace: http://sap.com/xi/XI/System/Mail

  • THeaderFROM – sender
  • THeaderTO – receiver
  • THeaderCC – carbon copy receiver (Cc)
  • THeaderBCC – blind carbon copy (Bcc) receiver
  • THeaderSUBJECT – e-mail subject

JMS Adapter – namespace: http://sap.com/xi/XI/System/JMS

  • DCJMSCorrelationID – Correlation ID
  • DCJMSMessageID – Message ID
  • DCJMSMessageQueue – Message Queue

HTTP Adapter – namespace: http://sap.com/xi/XI/System/HTTP

  • URL

Knowing key name and namespace, value is assigned to attribute key:

[codesyntax lang=”java”]

DynamicConfigurationKey key = DynamicConfigurationKey.create(
 “http://sap.com/xi/XI/System/File”,
 “FileName”);

[/codesyntax]

Finally, attribute key and value is to be assigned to dynamic configuration. In the below example, user-defined function sets target file name attribute based on an input parameter (filename) value:

Adapter Specific Message Attributes (ASMA)

Adapter Specific Message Attributes (ASMA)

Complete list of attributes, which can be configured dynamically for each Communication Channel, can be found on SAP Help portal: Using Adapter-Specific Message Attributes in the Message Header, selecting a specific Communication Channel type and proceeding to Define Adapter-Specific Message Attributes section.

Dynamic Configuration in XSLT mappings

An alternative to UDFs in Java to set Communication Channel attributes in Dynamic Configuration is to use XSLT mappings. The method is described in SAP Help: XSLT Mapping of Adapter-Specific Message Attributes.

Applications

Thanks to dynamic configuration access from message mapping level, wide range of programmable Communication Channel attributes is available. Potential applications are not limited to the following sample usages:

  • choosing target directory depending on plant, storage location number in SAP
  • placing order, invoice number or partner name in file name
  • setting e-mail recipient based on an address included in source message
  • setting e-mail subject depending on message content
  • dynamic URL creation for target HTTP service