cancel
Showing results for 
Search instead for 
Did you mean: 

Files of zip type

Former Member
0 Kudos

Hi friends,

sender Legacy system is sending files in .Zip format.

how the adapter is going to process those files?

what configurations r to be needed in adapter configuration?

& also for processing of .pdf files what configurations should be done?

thanks in advance.

shiva.

Accepted Solutions (1)

Accepted Solutions (1)

Shabarish_Nair
Active Contributor
0 Kudos

i have a better solution

use standard modules provided by sap itself.

Zip or Unzip your Payload with the new PayloadZipBean module of the XI Adapter Framework - /people/stefan.grube/blog/2007/02/20/working-with-the-payloadzipbean-module-of-the-xi-adapter-framework

/people/michal.krawczyk2/blog/2007/02/08/xipi-command-line-sample-functions

Answers (1)

Answers (1)

udo_martens
Active Contributor
0 Kudos

Hi Shiva,

the adapter can process the file. At mapping time you need to dezip the msg. An example in java:

import java.io.*;
import java.util.Map;
import java.util.zip.*;

import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;


public class DecompressMapping implements StreamTransformation {

	/* (non-Javadoc)
	 * @see com.sap.aii.mapping.api.StreamTransformation#setParameter(java.util.Map)
	 */
	public void setParameter(Map arg0) {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see com.sap.aii.mapping.api.StreamTransformation#execute(java.io.InputStream, java.io.OutputStream)
	 */
	public void execute(InputStream arg0, OutputStream arg1)
		throws StreamTransformationException {
			try {
		int len;
		byte[] buf = new byte[8192];
		boolean first_iter = true;
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		while((len = arg0.read(buf) ) != -1)
		{
			if (first_iter)
			{
			  if ((buf[0] != 'P') || (buf[1] != 'K'))
			  {
			  	arg1.write(buf, 0, len);
				while((len = arg0.read(buf) ) != -1)
				{
					arg1.write(buf, 0, len);				  	
				}			  	
			  	return;	
			  }
			  else
			  {
			  	first_iter = false;
			  }
			}
			baos.write(buf, 0, len);
		}				
		byte[] in_data = baos.toByteArray();
		
		ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(in_data));
			ZipEntry ze = zis.getNextEntry();
			if (ze != null)
			{
				while((len = zis.read(buf) ) != -1)
				{
					arg1.write(buf, 0, len);
				}				
			}
		} catch (IOException e) {

			e.printStackTrace();
		}
   
           
	}

}

Regards,

Udo

Former Member
0 Kudos

Hi Udo,

Thanks alot. this sample coding is very helpful me.

one more question?

where should i write this code? whether in module procesor or where?

plz let me know solution.

thanks & regards

siva

udo_martens
Active Contributor
0 Kudos

Hi Siva,

its an Java MAPPING.

Regards,

Udo