cancel
Showing results for 
Search instead for 
Did you mean: 

Unzipping multiple files from Mail and creating IDoc in ECC

Former Member
0 Kudos

Hi,
I have got a requirement where I will be receiving .zip file ( which has multiple files in it) via Mail.
I have to unzip the zip file and create an IDoc from each '+' seperated flat file.

I have referred the link below for java mapping of unzipping the zip file.
http://scn.sap.com/docs/DOC-61234

In the Modules tab of the Sender communication channel, I have specified 'AF_Modules/PayloadSwapBean' and the corresponding parameters in module key.

The error that I am getting while executing the scenario is :
exception caught during processing mail message[1]; com.sap.aii.af.lib.mp.module.ModuleException

Could you please help?

Accepted Solutions (1)

Accepted Solutions (1)

engswee
Active Contributor
0 Kudos

Hi Sneha

My article that you referred to is about unzipping the main payload into multiple attachments (of the same message.)

Your scenario is a bit different and requires a combination of techniques to work.

1) Getting the zip file attachment as the main payload

You need to check if the zip file is coming as an attachment or as the main payload. Just try setting up a scenario without any mapping/modules and see how it looks like in the logs. If it is an attachment, then you need to use the PayloadSwapBean to swap it to the main payload. You can refer to the solution in the thread below for the parameters for the swap

2) Unzip the main payload (with zip content from above swap)

For this step, you can refer to my article on the logic to unzip using ZipInputStream/ZipEntry

3) Create multiple IDocs

My article creates attachments instead of multiple child messages. So, you need to adapt the logic to create multi child messages instead for each file in the zip file. You can achieve this via multi-mapping within the Java mapping. Refer to the wiki below for that.

Multi-Mapping using Java Mapping - Process Integration - SCN Wiki

Alternatively, if you don't want to complete this in one complex scenario, you can break it down into a few scenarios.

- The first scenario gets the zip attachment, swaps it, unzip it into multiple attachment and saves all the attachment in a temporary file location

- Second scenario picks up those files individually and maps it to IDoc and post to ECC

Rgds

Eng Swee

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Thank you all for your suggestions & help.

Broke down the requirement into two steps :

Step 1 ) Created a Java mapping to unzip the file received by email. After unzipping the file, the sub-files were created in the NFS directory

Step 2) Created second interface to pick the files from NFS directory and created a Sales Order in ECC system.

engswee
Active Contributor
0 Kudos

Sneha

Thanks for coming back and updating the thread. Glad to know that the suggested approach worked for your scenario

Rgds

Eng Swee

iaki_vila
Active Contributor
0 Kudos

Hi Sneha,

The document that you have mentioned is about the zipping in java mapping. If you are using PayloadSwapBean i think you want to replace the PI payload with the mail attachment. I haven't tried it but i think you can have any problem if the payload is not a XML, although per documentation you can try changing the content-disposition and it could work.

On the other hand, you are doing the zipping process via java mapping, therefore why don't develop all the stuff inside the java mapping?, you can access to the attachments at mapping level (depending your PI version), like the java code shared by Vinay P in this blog

Regards.

Former Member
0 Kudos

HI Sneha,

Please provide the screen shot of the module tab

Regards,

Sriram