Skip to Content
author's profile photo Former Member
Former Member

Files of zip type

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Nov 22, 2007 at 09:21 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 22, 2007 at 09:08 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.