MDM to Mail: Exploit UDF Santhosh Kumar V


In this Blog(My first Blog :)) I will explain how to send mail with the content of the file getting displayed in the row column format. Even though there are some Blogs speaking about sending mail, the Blog eMail Reporting by Prakash Arunachalam explains of sending the mail with the data getting displayed in the row column format using XSLT mapping. However in this Blog I will exercise the same scenario using a User Defined Function.

Requirement:

In a landscape where XI integrating MDM and R3, the requirement is to send the materials that are created in the MDM in a mail to the Data Administrator who has to approve or reject the material. Sending mail can be done with the use of MDM workflow, however it will flood the inbox with these mails being sent for each and every material created. The other best solution for this is MDM will send a file every one-hour with the material details and XI has to send mails with those material details and the URL of the portal page to approve/reject. Even the same requirement can be from R3 where it sends the list of purchase order created in an IDoc, which should be sent as a mail. Let us start creating the scenario.

1. Import the XSD of the source structure and the Mail in the external definition.

You can download the mail structure from the following link

https://websmp205.sap-ag.de/~sapidb/012006153200000361852004E/ximail30_xsd.txt

2. Create Message Interface for the Source and the Mail.

3. Map the product details to the Mail XSD as shown.







































The above mapping enables to dynamically send mails as shown in the Blog Mail Adapter (XI) - how to implement dynamic mail address by Michal Krawczyk.













4. Concatenate and map the fields for the Subject.















5. Use the following UDF to generate the content of the mail.

public void Content_test(String[] ID,String[] No,String[] Desc,String[] Type,String[] product,String[] JobID,String[] WF_Status,String[] Form_Id,ResultList result,Container container) { String Val,temp; int j; Val = "Hi," + "\n" + "The Following Form " + Form_Id[0] + " is " + WF_Status[0] + "\n\n" + "Form Details:\n " ; Val = Val + "\n\n" + "MDM Id " + "Material Number " + "Description " + "Material Type"; for(int i =0;i
6. Map the filed to be displayed in the mail content to the Content_test UDF and map it to Content of the mail structure.































7. In the Directory Create Receiver Determination and Interface Determination between MDM Business System and MailServer.

8. Configure the File Sender CC,Receiver Mail CC and create the Sender Agreement and Receiver Agreement respectively.

[Hint:You can find the URL of mail server using Tcode SCOT->Double Clicking SMTP->Mail Host. remember to suffix it with smtp:// in CC]

We are now prepared to trial the scenario. Post the file in the Fileserver and the mail knocks the Inbox.

Source.XML

53 21 santhosh.vellingiri@wipro.com 12345 ABC bcd 001 Pending For Approval 54 21 santhosh.vellingiri@wipro.com 12345 ABC bcd 001 Pending For Approval 55 21 santhosh.vellingiri@wipro.com 12345 ABC bcd 001 Pending For Approval 56 21 santhosh.vellingiri@wipro.com 12345 ABC bcd 001 Pending For Approval 57 21 santhosh.vellingiri@wipro.com 12345 ABC bcd 001 Pending For Approval

Output Mail











































Santhosh Kumar V is a Netweaver XI/PI Consultant working with WIPRO Technologies.



SAP MDM Training
SAP MDM Training