Per default, PI messages include just one single XML message (the main payload).
When integrating such messages through some communication channel, for example the Mail Receiver adapter, the XML message can be either sent as an attachment or in the Mail body.
While sending the NFe XML file as an attachment is the most desirable approach, several times it may also be desirable to include some custom predefined message in the Body of the e-mail that will be sent to the customers.
The code below is a proposal for an Adapter Module that would:
- create the XML message as attachment in the email;
- set the XML file name with a specific value (instead of "Untitled.xml");
- set the Body of the e-mail message with some pre-defined message for the customers.
Notice that the Adapter Module reads data from two inputs:
- the Message Module parameter (to be included in the Module Processor tab of the communication channel)
- one Adapter Specific Message Attribute with the File Name to be set to the attachment. Here, it was used an unexisting parameter ("http://www.sap.com/grc/nfe", "Name"), which was previously filled in the Message Mapping with a dynamic value for the File name (based on the NFe Access Key, for example).
As a debug feature, the Module will also add NFe specific entries to the communication channel Audit Log (which can be seen through the Communication Channel Monitoring or Message Monitoring tools of the Runtime Workbench of SAP PI).