Skip to Content
0

Zipped multi excel .csv files to Idoc

Mar 29, 2017 at 03:50 PM

177

avatar image
Former Member

Hi,

I have scenario where i have 'header' excel .csv and 'detail' excel .csv files zipped and available on PI server to send it as an IDOC to ECC. Now how do i approach this scenario: Zipped file to IDOC ? Thx!

Moderators, please do not close this thread. i did research on the answers.sap site but i couldnt find the answers. so please. wait. thx!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

7 Answers

Evgeniy Kolmakov Mar 29, 2017 at 07:48 PM
1

Hi Prema!

You could use PayloadZipBean to extract contents of your ZIP file and java mapping to parse that files and compose output IDoc message.

Regards, Evgeniy.

Show 7 Share
10 |10000 characters needed characters left characters exceeded
Former Member

thanks Evgeniy. PayloadZipBean unzips only one file. i have multi files.

0

Hi Prema!

PayloadZipBean extracts ALL files.

And here is PayloadZipBean module code fragment:

      if (bins.size() > 0)
      {
        String filename = (String)bins.get(0);
        setPayload(pld, (Binary)bins.get(1), generateContentType(filename), filename);
        String zipStatus = "Zip: unzipped payload";
        TRACE.infoT("process(ModuleContext , ModuleData)", ModuleCategories.SAP_MODULE_ROOT, zipStatus);
        Audit.addAuditLogEntry(auditkey, AuditLogStatus.SUCCESS, zipStatus);
        if (bins.size() >= 2)
        {
          int count = 0;
          for (int i = 2; i < bins.size(); i += 2)
          {
            String ifilename = (String)bins.get(i);
            XMBPayload ipld = XMBMessageOperator.createPayload();
            ipld.setPayloadDescription(ifilename);
            ipld.setPayloadType(PayloadType.APPLICATION_ATTACHMENT);
            setPayload(ipld, (Binary)bins.get(i + 1), generateContentType(ifilename), ifilename);
            XMBMessageOperator.addPayload(mo, ipld);
            count++;
          }
          zipStatus = "Zip: unzipped additional " + count + " payloads";
          TRACE.infoT("process(ModuleContext , ModuleData)", ModuleCategories.SAP_MODULE_ROOT, zipStatus);
          Audit.addAuditLogEntry(auditkey, AuditLogStatus.SUCCESS, zipStatus);
        }

Regards, Evgeniy.

unzipped.png (5.7 kB)
0
Former Member
Evgeniy Kolmakov

thanks Evgeniy! i was using file to file to unzip files. at the destination folder i was just seeing the first file in the zip file is unziped. why am I not seeing the two files at the destination?

also i was using intigarated configuration(IC) to just move the files.

0
Former Member
Evgeniy Kolmakov

Hi Evgeniy.

Thanks much. :) now i see two files(payloads) in sxmb_moni. i used reciever determination not ICO this time.

now my next question is how do get these files to an IDoc. plaese let me know your thoughts. thx again!!

files-payloads.jpg (45.9 kB)
0

Hi Prema!

I guess you don't see all of your files in destination folder since you use file adapter in receiver channel and it doesn't support attachments. If you use SFTP adapter, for example, it will save your attachments as additional files in target folder as well.

As your source files are .csv files (plain text files), you could use java mapping to read contents of your files and build output IDoc structure.

Regards, Evgeniy.

0
Former Member
Evgeniy Kolmakov

Thanks Evegeniy. let me try uisng SFTP adapter. and see if i get something to proceed further.

0
Former Member

Hi Evgeniy.

i tried with sftp at the reciver. it is getting the first file but for 2nd file i get below error in reciever channel.

files-err.jpg (57.6 kB)
0
Evgeniy Kolmakov Mar 29, 2017 at 09:02 PM
1

Hi Prema!

In this case you can use standard java API to zip/unzip files:

http://www.oracle.com/technetwork/articles/java/compress-1565076.html

Regards, Evgeniy.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

thanks Evgeniy. not sure how and where to use those APIs.

0
Evgeniy Kolmakov Mar 29, 2017 at 09:13 PM
1

Hi Prema!

You can pass your zip file to java mapping and use classes mentioned above to extract files from source zip archive.

Regards, Evgeniy.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

thanks again Evgeniy. I'm not a java person, so not that comfortable playing with this interface. also i have very less time to deliver the interface.

0
avatar image
Former Member Mar 30, 2017 at 12:49 PM
1

Hi Prema,

You could also Use "Run OS command before message processing" in file adapter and unzip the files using command line (this requires addon to be installed on your PI SERVER may be WinZip or 7Zip) and then process files individually.

Below are the reference links

https://archive.sap.com/discussions/thread/3195587

https://blogs.sap.com/2007/02/08/xipi-command-line-sample-functions/

https://wiki.scn.sap.com/wiki/display/XI/SAP+XI+File+Adapter+OS+Command+Line+Feature?original_fqdn=wiki.sdn.sap.com

This has little overhead of programming batch file and placing on application directory but its not that difficult to implement.

Thanks,

Amit

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

thanks Amit. but avoiding any dependencies like os commands etc when there is upgrades.

it such comman requiremnt, why SAP did not comeup with solution?

0

Hi Amit!

Did you try it? As far as I know OS command is executed after picking up the source file but before its processing by adapter.

Regards, Evgeniy.

0
avatar image
Former Member Mar 31, 2017 at 07:35 AM
1

You would need to look into file content conversion

https://wiki.scn.sap.com/wiki/display/XI/Basic+File+Adapter+Content+Conversion

https://help.sap.com/saphelp_nw75/helpdata/en/44/6713ec3f914ddee10000000a1553f7/frameset.htm

However, in your setup it might be difficult (maybe someone can weigh in here) to operate on two different files (HeaderExport.csv / DetailExport.csv). You might want to look into merging those two files in one CSV before you enter File Content Conversion (which resides in the sender adapter, so before mapping) and then use "complex structures" feature of FCC which allow you to operate on multiple structures (e.g. headers and detail records) within one file. See here: http://www.riyaz.net/sap/xipi-file-content-conversion-for-complex-structures/79/

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Hi Jens!

I would like to ask: how can we use FCC with zipped source file?

Because even if we use PayloadZipBean first, at further step we can use only first unzipped file contents in FCC (or another one if we use PayloadSwapBean in sequence). And what to do with the rest files stored as attachments? Please advise.

Regards, Evgeniy.

0
Former Member
I honestly did not know about that limitation (or if there's a workaround) for the FCC only picking up the first file.

That's the reason why I brought up if it may be feasible to merge the two files before handling them on PI.

1. If you have the sender system under your control or could issue feature request to the sender system's owner that might be an option.

2. If not, there might be an intermediate option, using a new separate flow upfront your content conversion to effectivle create two PI messages each containing one file (one header, one details) out from one zip file. You then pick up that two (now unzipped) files (e.g. you could store them on NSF of your PI system temporarly) with your target flow and do FCC there, separately for each file (which means that you need two sender channels, each for one file type as FCC seems only to operate on one file).

3. Another option would be to pickup the zip file as is and then pass it to a file receiver which is configured to store the file (temporarly) via NSF on the PI server. In that receiver channel you could issue an OS command to unzip the file and pipe the unzipped contents of the files to a newly created merged file, effectively containing the header and details of the zip in one text file. After that you have another flow that picks up that new textfile and does FCC in the file content adapter for structured content.

4. Yet another option would be to develop an custom adapter for this which does all the heavy lifting. While it takes some teething pains to get into adapter development, it might (from an architectural point of view) be the most cleanes solution that comes to my mind.

5. Maybe there's some silver bullet solution out there, waiting to be posted by some guru :-)

0

I'm surely not a guru :-), but taking two plain text files (one from main payload and another one from attachment) and building DOM (or even just string) structure of outcoming IDOC by java mapping is quite simple and straightforward way.

Regards, Evgeniy.

0
Former Member

Sorry Evgeniy, didn't realise you are not the Thread Owner :-D. Of course Java Mapping (instead of Adapter Module) would be way more feasible :)

0
avatar image
Former Member Mar 30, 2017 at 08:56 PM
0

thanks Evgeniy..

can somebody tell me to convert the below two payload files into an Idoc? Thx!


Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Mar 31, 2017 at 12:20 PM
0

Thanks Evgeniy and Jens. much appreciated your time and help.

i was thinking of the following steps to achevie this interface.

- interface 1: to unzip the files(which are available on PI server from Ariba) and place files on PI server.

- interface 2: merge files and place it in different folder on PI server.

- Interface 3: use merged file to convert to IDoc.

and as i said I'm not java person. may be lil difficult to get into it. but i'm ABAP programmer, i can tweak into java programming.

or i have to pass the files to ECC and process with ABAP program, dont know the consequnces. thx!

Share
10 |10000 characters needed characters left characters exceeded