Unique Filenames with AS2 Communication Channel

Unique Filenames with AS2 Communication Channel

During the implementation of multiple AS2 interfaces, I found myself very often in a situation where the communication partner expected unique AS2 filenames. Unfortunately, if you leave the filename parameter in an AS2 Receiver Communication Channel (CC) blank, the filename will always be your PIs system name. In case you enter a value like “Invoice”, the filename will always be set to “Invoice”.

Solution:

  1. You can use a dynamic configuration to generate unique filenames. Just add a UDF to you message mapping which sets the property “AS2Filename” in the namespace “http://sap.com/xi/XI/AS2/AS2“. Also, do not forget to enable the checkbox “Respect parameters” in the AS2 Communication Channels configuration.
  2. If you want to generate random, unique filenames only, a dynamic configuration feels like to much effort. Fortunately, there is an easier way to generate unique filename. Just put “%MSGID” into the “Filename” parameter of your AS2 Receiver Communication Channel. The parameter will be replaced with the PIs message ID, which should be unique. Additionally, it is possible to combine the placeholer with static text like “%MSGID.xml”.
    MSGID placeholder in filename parameter in AS2 Receiver Communication Channel
    MSGID placeholder in filename parameter in AS2 Receiver Communication Channel

    Be aware that in case your message fails, in every attempt to resend the mesasge the filename will be the same. Luckily, there are more placeholders available:

    Placeholder Description
    %SEQNUM A sequence number, starting with 1
    %RTSEQNUM A server wide sequence number, starting with 1
    %START The start time of the adapter
    %TIME The archiving period in milliseconds
    %MSGID The XI message ID

If you would like to find out more about the AS2 Adapter, check out the SAP Documentation.

Leave a Reply

Your email address will not be published. Required fields are marked *