Filter for Filename or Subject in AS2 Sender Communication Channel

Filter for Filename or Subject in AS2 Sender Communication Channel

In a current project we had the demand to send XML files from a windows server to an SAP ERP system via SAP PO. As additional requirement the files should be signed and an acknowledgment should be send back to the sender system. Therefore, we decided against the classical (S)FTP(S) and for AS2, as signature and Message Delivery Notifications (MDN) are firm elements of the AS2 specification. With mendelson AS2 there is an excellent tool available, which grabs files out of a directory and sends it to an AS2 receiver, in this case SAP PO.
Unfortunately, XML files with different data structures (Receipts, Orders, Invoices, …) were stored in the same directory and therefore send to the same URL. As the filenames looked like “Order_xxxxxxx.xml” and “Invoice_xxxxxxxx.xml” we looked for a way to separate the different files on SAP PI.

Filter for AS2 filename on SAP Process Orchestration / Process Integration

The AS2 Sender communication channel is not able to filter for a filename schema, hence you would receive all the different files with one AS2 Sender Communication Channel and route them through one Integrated Configuration (ICO). There are multiple ways to handle this:

  • You could use the EDI Separator to filter the files in a second step, but I highly recommend against using the EDI Separator in XML scenarios.
  • The filename is available as dynamic configuration and can be used as condition in an ICO.

    AS2Filename as condition in an Integrated Configuration
    AS2Filename as condition in an Integrated Configuration
  • If the structure of the XML files is different you can use an exists check as condition in your ICO.

    Check for an XPath in the condition of an ICO
    Check for an XPath in the condition of an ICO

Separating the different files with conditions in the ICO is possible, but bad practice. You have to use a dummy Sender Interface, as the data can have different structures. As a result, the selection of an Operation Mapping and the PI checks wont work. Fortunately, with mendelson AS2 it is possible to use the filename as subject. Just open the Partner configuration and type “${filename}” into the Payload Subject field.

Configure mendelson AS2 to use the filename as subject
Configure mendelson AS2 to use the filename as subject

Filter for AS2 subject on SAP Process Orchestration / Process Integration

A great feature of the AS2 Sender Communication Channel is to use regular expressions for the different expected values, like the subject. If you would like to receive only AS2 messages with a subject starting with “Order_” you can simply use “Order_.*”.

Regular Expressions in AS2 Sender Communication Channel
Regular Expressions in AS2 Sender Communication Channel

The dot has the meaning of any character and the Asterisk means zero or more occurrences. To learn more about regular expressions or test your regular expression the page regex101.com is a good place to start.

Leave a Reply

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