IBM Sterling Transformation Extender

 View Only

 ZIP adapter and file paths

Jim Davee's profile image
Jim Davee posted Tue March 11, 2025 11:06 AM

Customer wants a zip file from two input files.  I have the ZIP adapter working to do this:

=VALID(PUT(
   "ZIP", "FILE," + 
    GETDIRECTORY(ZIPOut) + "output.zip, " + GETFILENAME(File1) + " " + GETFILENAME(File2), " "), "Failed ZIP")

The two input files are not in the same directory as the output zip or the map itself, so I have to provide the full path to the two input files.

As a result, in the output zip the two files are embedded in a directory structure.  Is there any way to just put the two input files at the root level of the zip in spite of providing the full path to the zip command? 

Lisa Edwards's profile image
Lisa Edwards

Replying here for the benefit of the thread, but I have a little test map I can share with you and will send it in email.  The short answer to how I solved this is to use the MEMORY adapter setting instead and to add each file individually to the same Archive.  You could have 2 output cards to add to same archive or you can run the map multiple times with new files to add to the archive.  Here I have given the Archive an explicit name - can probably use the override and just get the whole name from either an input or the output card...  then sending in the filename only so no path is retained with the ECHOIN for the data.

=VALID(PUT(
   "ZIP", "MEMORY," + GETDIRECTORY(ZipOut) + "output.zip," + SUBSTITUTE(GETFILENAME(ZipFile2), GETDIRECTORY(ZipFile2), ""), ECHOIN(1, ZipFile2)), "Failed ZIP")

Don't get mad - I needed a little distraction from the ETL and this was perfect. (o:  For everyone else, this is my boss and I was supposed to be working on something else.

Stephanie Fetzer's profile image
Stephanie Fetzer

Now that I'm done laughing at this thread, I have a request for one of you. I had also played with the archive adapters a bit when I saw Jim's question and was thinking along the same lines as Lisa but had not gotten it to work before becoming distracted by something else. If you could open up an AHA Idea on the ER portal to enhance the zip adapter (maybe a flag to ignore directory paths for the content when creating the zip) I would appreciate that.

https://watsonsupplychain.ideas.ibm.com/?project=ITX

Using the Zip adapter should not be a challenge to be solved; especially for such experienced mappers as yourselves. I expect it could be made to work in a more obvious manner.

-Steph

Jim Davee's profile image
Jim Davee

Steph, the enhancement idea has been submitted!  I recommended a simple command line option like -j (what works in Unix zip to "junk" the paths).  I think the ZIP adapter just suffers from being very old and unmodified for years.  Different syntax, little to no options.  Time to drag it kicking and screaming into the 21st century.

Lisa's dereliction of duty has been noted but mitigated by providing a workable solution to the ZIP problem.  Now back to the ETL salt mines!