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


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:

  • FileName
  • Directory
  • TargetTempFileName (if used)

Mail Adapter – namespace:

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

JMS Adapter – namespace:

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

HTTP Adapter – namespace:

  • URL

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

[codesyntax lang=”java”]

DynamicConfigurationKey key = DynamicConfigurationKey.create(


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.


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

User Defined Functions in SAP PI mappings

User Defined Functions (UDF) are functions defined by a programmer, which can be used in SAP PI graphical mappings. UDFs are defined in Java programming language and allow running any custom code on XML field mapping stage, significantly extending possibilities of message field and value mapping.

UDFs are represented by one block in graphical mappings. They can be utulised to simplify implementation of logic, that requires using multiple standard mapping blocks:


UDF can be created by clicking the icon in lower-left corner of graphical mapping editor window:


In the simplest caase it is enough to provide some basic data – function’s name and title, and its input arguments. Arguments’ value can be assigned in the same way as for standard mapping blocks – using arrows on function’s input and output:


The next step is implementation of function in Java programming language. Input and output are handled in the same fashion as other Java functions or methods – through arguments and return statement. The below screen shows a UDF function, that works in the same way that the graphical mapping above.


UDF Parameters

Configuration values can be assigned as UDF parameters. They will be passed to the function as arguments, too, but their values are defined in graphical mapping editor.



UDF Testing

After saving the function, it can be used in graphical mapping, connecting inputs and output. Similarly to standard mapping blocks, after running a test case, a queue of arguments and returned values can be viewed under Display Queue:


In the above example, UDF has been utilised to simplify value mapping implementation. Depending on needs, a programmer can use a variety of Java language features to implement more complex mappings, than standard mapping blocks allow.