Upload
suhail
View
271
Download
8
Tags:
Embed Size (px)
DESCRIPTION
File name creating from mail attachment
Citation preview
Generated by Jive on 2014-12-02+01:001
Process Integration (PI) & SOA Middleware:Creating File Name from Mail Attachmentusing Standard Beans
Posted by sivasakthi danasekaran Apr 2, 2013Business Driver Purchase and Sales information is sent from a partner via Email as a CSV attachment. PI hasto poll the Email server, retrieve these mails and write the CSV files in PI server directory with exactly the samename as the mail attachment. Solution This requirement has popped up many times in the sdnforumsand the solution to this currently is to deploy a custom adapter modulehttp://wiki.sdn.sap.com/wiki/display/XI/Adapter+Module+PI+7.0+Get+Attachment+Name But the same requirementcan be sufficed with absolutely no coding or creation of adapter modules. This can be achievedwith 3 standard beans: MultipartHeaderBean ,PayloadSwapBean and DynamicConfigurationBeanIn this blog I have highlighted only the specific settings that have to be maintained in thecommunication channels to achieve our requirement, all the other ESR & ID objects should becreated as usual. Sender Email Channel Settings In the sender email communication channel makesure to check the Keep Attachments option , which is required to retain the attachment.Also check the Set Adapter-Specific Message Attributes option to enable the DynamicConfiguration attributes to be available. Pic 1.1
Pic 1.2
http://scn.sap.com/people/sivasakthi.danasekaranhttp://wiki.sdn.sap.com/wiki/display/XI/Adapter+Module+PI+7.0+Get+Attachment+Namehttp://wiki.sdn.sap.com/wiki/display/XI/Adapter+Module+PI+7.0+Get+Attachment+Name
Process Integration (PI) & SOA Middleware: Creating File Name from Mail Attachment using Standard Beans
Generated by Jive on 2014-12-02+01:002
The MultipartHeaderBean enables us to access the attributes of other payloads that areappended to the XI message asan additional attachment. In the Module tab add the MultipartHeaderBean with the followingparameters:Parameter Name Parameter Value
requiredHeaders All
dcNamespace http://sap.com/xi/XI/System/Mail
Using the PayloadSwapBean here we can replace the application payload of the XI messagei.e. email content, with another payload that is appended to the XI message i.e. the attachmentAdd the PayloadSwapBean with the following parameters:
Parameter Name Parameter Value
swap.keyName Payload-Name
swap.keyValue MailAttachment-1
Pic 1.3
http://sap.com/xi/XI/System/Mail
Process Integration (PI) & SOA Middleware: Creating File Name from Mail Attachment using Standard Beans
Generated by Jive on 2014-12-02+01:003
Receiver File Channel Settings
Now in the Receiver File adapter we are going to use the DynamicConfigurationBean to retrieve the
attachment name.
The attachment file name is available in the Dynamic configuration attribute Part[1].Content-Description, which
we will write to the PI message interface name.
To the 'Module' tab add the DynamicConfigurationBean with the following parameters:
Parameter Name Parameter Value
key.0 write http://sap.com/xi/XI/System/Mail
Part[1].Content-Description
value.0 message.interface
Pic 2.1
http://sap.com/xi/XI/System/Mail
Process Integration (PI) & SOA Middleware: Creating File Name from Mail Attachment using Standard Beans
Generated by Jive on 2014-12-02+01:004
Using Variable Substitution, create a variable fname referencing the message interface name and access this
variable in the file name field.
Pic 2.2
Process Integration (PI) & SOA Middleware: Creating File Name from Mail Attachment using Standard Beans
Generated by Jive on 2014-12-02+01:005
Pic 2.3
Testing
Process Integration (PI) & SOA Middleware: Creating File Name from Mail Attachment using Standard Beans
Generated by Jive on 2014-12-02+01:006
The configurations are complete. Its time to test our scenario.A sample mail is sent to the mail account which the sender email adapter is polling with the attachment name
MyAttachment1.CSV
Pic 3.1
Integrated configuration was used in this scenario, so we can see the Dynamic Configuration message
attributes in message monitoring.
Note that Part[1].Content-Description has been set to MyAttachment1.CSV at runtime.
Pic 3.2
Process Integration (PI) & SOA Middleware: Creating File Name from Mail Attachment using Standard Beans
Generated by Jive on 2014-12-02+01:007
The payload was swapped successfully and the attachment data has been set to the main payload as shown
below.
Pic 3.3
Process Integration (PI) & SOA Middleware: Creating File Name from Mail Attachment using Standard Beans
Generated by Jive on 2014-12-02+01:008
We can see the output file in the output folder path with the same name as our attachment
MyAttachment1.CSV.
2219 Views Tags: integration
Elmar Fritz in response to Deepak Ravi on page 9Dec 1, 2014 1:58 PM
Hello!
I tried to implement this, but it always fails with this error ...
SOAPFault empfangen vom Integration Server. ErrorCode/Category: XIProtocol/WRONG_VALUE;
Params: SOAP:Envelope(1)SOAP:Header(1)sap:DynamicConfiguration(3)sap:Record(2), attachment;
filename="=?iso-8859-1?Q?Preisliste=5FZertifizierungsgeb=C3=BChren=5Fbrutto=5Fnetto?
==?iso-8859-1?Q?=5F2014.pdf?="; size=27653;creation-date="Tue, 08 Jul 2014 13:32:58
GMT";modification-date="Tue, 08 Jul 2014 13:32:58 GMT", ST: ST_XMS_MSGHDR30_DYNAMIC;
AdditionalText: An error occurred when deserializing in the simple transformation program
ST_XMS_MSGHDR30_DYNAMIC; ApplicationFaultMessage: null; ErrorStack: XML
tag SOAP:Envelope(1)SOAP:Header(1)sap:DynamicConfiguration(3)sap:Record(2)
(or one of the attributes) has incorrect value attachment; filename="=?iso-8859-1?Q?
Preisliste=5FZertifizierungsgeb=C3=BChren=5Fbrutto=5Fnetto?==?iso-8859-1?Q?=5F2014.pdf?
="; size=27653;creation-date="Tue, 08 Jul 2014 13:32:58 GMT";modification-date="Tue, 08 Jul
2014 13:32:58 GMT" An error occurred when deserializing in the simple transformation program
ST_XMS_MSGHDR30_DYNAMIC Data loss occurred when converting attachment; filename="=?iso-8859-1?
Q?Preisliste=5FZertifizierungsgeb=C3=BChren=5Fbrutto=5Fnetto?==?iso-8859-1?Q?=5F2014.pdf?=";
size=27653;creation-date="Tue, 08 Jul 2014 13:32:58 GMT";modification-date="Tue, 08 Jul 2014 13:32:58
GMT"
http://scn.sap.com/community/pi-and-soa-middleware/blog/tags#/?tags=integrationhttp://scn.sap.com/people/e.fritzhttp://scn.sap.com/people/e.fritz
Process Integration (PI) & SOA Middleware: Creating File Name from Mail Attachment using Standard Beans
Generated by Jive on 2014-12-02+01:009
Rams G in response to sivasakthi danasekaran on page 11Oct 21, 2014 10:02 AM
Hi Sivasakthi,
Is it possible to pick the .PDF files from Emails and place them on FTP server with the same file name?
thanks-
Ramesh
Deepak RaviSep 18, 2014 3:16 PM
Hi Sivasakthi,
Your blog helpmed me a lot in creating the same with SOAP attachments.
Everything worked fine, except the file name generation. In dynamic configuration the file name is coming as
. As '' are not permitted in creation of file name, PI is generating it with underscores
(_filename.ext_).
http://scn.sap.com/people/ramesh.gaddalehttp://scn.sap.com/people/ramesh.gaddalehttp://scn.sap.com/people/deepak_rhttp://scn.sap.com/people/deepak_r
Process Integration (PI) & SOA Middleware: Creating File Name from Mail Attachment using Standard Beans
Generated by Jive on 2014-12-02+01:0010
I rectified this issue by using an UDF. But just want to know is there any other way to get the correct file name
in adapter level.
Regards,
Deepak Ravi
divyesh vasaniMar 19, 2014 7:06 AM
Nice Blog
Very well explained... I like the use of MultiPartHeaderBean ...
--Divyesh
mastan valiJan 10, 2014 9:03 AM
Hi Siva,
thank you for letting us the standard beans for mail attachement.
Keep blogging
Regards,
Mastan
Monikandan PanneerselvamJan 10, 2014 8:55 AM
Nice blog siva
One clarification:
If it is FTP folder instead of NFS any specific change need to do or only the adapter selection is enough.
dhinesh kumar raj kumar
http://scn.sap.com/servlet/JiveServlet/showImage/105-525907-544167/Dynamic_Conf.JPGhttp://scn.sap.com/people/divyesh.vasanihttp://scn.sap.com/people/divyesh.vasanihttp://scn.sap.com/people/mastanhttp://scn.sap.com/people/mastanhttp://scn.sap.com/people/monikandan.phttp://scn.sap.com/people/monikandan.phttp://scn.sap.com/people/dhineshkumar.rajkumarhttp://scn.sap.com/people/dhineshkumar.rajkumar
Process Integration (PI) & SOA Middleware: Creating File Name from Mail Attachment using Standard Beans
Generated by Jive on 2014-12-02+01:0011
Jun 7, 2013 1:57 PM
Hi Sivasakthi,
I am working on a file to mail scenario in which i have to send the files as attachment with the same name of
the source file i am sending...but, the received mails are not having the same names for the attachments..My
requirement is to set these names to the attachments dynamically..I am a fresher to PI..can you please help
me to resolve my issue
sivasakthi danasekaran in response to Inder G on page 11Apr 22, 2013 11:31 AM
Thnx
Francis AntonyApr 18, 2013 1:03 PM
Good one.
Inder GApr 11, 2013 6:00 PM
Nice Blog Shakku - Kulwinder
amarnath kashinathApr 2, 2013 9:33 PM
Nice Blog sivasakthi. Got to learn few things about mail adapter with attachments.
Thanks for sharing:)
http://scn.sap.com/people/sivasakthi.danasekaranhttp://scn.sap.com/people/sivasakthi.danasekaranhttp://scn.sap.com/people/francis.antonyhttp://scn.sap.com/people/francis.antonyhttp://scn.sap.com/people/kulwinder.grewalhttp://scn.sap.com/people/kulwinder.grewalhttp://scn.sap.com/people/amarnath.kashinathhttp://scn.sap.com/people/amarnath.kashinath