Additional Blogs by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Introduction

As many of you already know, Variable Substitution, allows you to dynamically set the target file name scheme or target directory location by substituting a variable placeholder with a value from the XI message payload or XI message header.  Adapter-Specific Message Attributes (ASMA, a.k.a. "DynamicConfiguration") are additional message attributes specific to each adapter.  For example, the File Adapter has ASMAs like FileName and Directory.   Using ASMAs alone, the target directory and/or target file name (more common case) can easily be set to the source directory and/or source file name by setting the appropriate indicators on the sender and receiver channel configuration.

Because such File ASMAs (i.e. FileName and Directory) are available, it would make a lot of sense to be able to use these ASMAs in conjunction with the Variable Substitution feature (e.g. to use the original file name or directory as a prefix or suffix to the target file name scheme or target directory location).    Unfortunately, access to the File ASMAs is not accessible by the Variable Substitution feature, even though they exist in the XI message header (within DynamicConfiguration header element).  When using Variable Substitution, only certain standard message header attributes can be used/accessed (e.g.  sender_party, sender_service, receiver_party, receiver_service, interface_name, interface_namespace, message_id).   This is where the DynamicConfigurationBean can be leveraged as a simple workaround.  Plus, since the bean is an adapter module, a mapping is not needed to do this.  Even if there was a mapping, there wouldn’t be a need to create a field in the target payload to carry the File ASMA so that it can be used in Variable Substitution via the payload option.

Adapter Framework DynamicConfiguration Module

The DynamicConfigurationBean is a standard, SAP-delivered module (e.g. like PayloadSwapBean) that allows you to:

  • Insert or delete some specific ASMAs
  • Read some XI message header attributes into ASMAs
  • Write some ASMAs into XI message header properties
  • SAP Note 974481 provides more detailed information on the configuration and use of this module, including other example usages.

    Using File ASMAs for Variable Substitution

    In the following example, the FileName ASMA will be accessed and used for Variable Substitution.  Since there are only particular XI message header elements that can be used for Variable Substitution and the DynamicConfigurationBean can read ASMAs and write to many of the common XI message header attributes, we can simply write the FileName ASMA to an inconsequential message header attribute - in this case, we’ll use interface_name.  Here are the steps:

    In the sender file channel, the relevant ASMA indicators set ...

    ... and in SXMB_MONI, the File Name ASMA has been populated in the XI message header

    In the receiver file channel, the File Name Scheme is set to xi_%fName% as shown below:

    Variable Substitution is enabled, with the variable fName matching the variable above in the file name scheme and the Reference set to message:interface_name.

    The key to this example is in the following settings.  The DynamicConfigurationBean module configuration takes place here.  To use the bean, the Module Name has to be set to AF_Modules/DynamicConfigurationBean and should be the first module in the sequence.

    Referencing the Module Key (1) for the DynamicConfigurationBean, the following parameters must be set in the Module Configuration section.

    As a result, the target file name incorporates the FileName ASMA value.

    CAUTION!!!

    SAP PI Development strongly advises against modifying XI message attributes such as those accessible for Variable Sustitution (e.g. Sender Party, Sender Service, Receiver Party, Receiver Service, Interface, and Interface Namespace) as unforeseen side effects can potentially occur after such modification.  In general, these fields are designed to contain type information only and not data that is specific for a given message (e.g. filename).

    One known side effect occurs in scenarios where the sender requests a system acknowledgement.  In this case, upon processing of an acknowledgement message by the Integration Engine, additional address records are created in ABAP table SXMSPFADDRESS.  So in the context of this blog example, if the sender requests an acknowledgement, a unique filename ends up creating new records in this table when the acknowledgement message is processed.

    In order to avoid any unknown consequences and in order to meet the requirement fulfilled by this blog, a mapping that writes the necessary File ASMA into the payload, which can then be used for Variable Substitution would be advised. If no mapping is involved in your scenario, one will need to be created with a field in the target message where the retrieved File ASMA can be set.

    Useful Link

    For other standard SAP modules, check this XI_Adapter_Notes Wiki page.

    25 Comments