Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
xavisanse
Active Participant


It's possible that in some scenarios you should compress  as a ZIP and send a document through  a WebService in base64. For achieve this we can use UDF and some libraries.

The UDF will be this:

public String invoice2zip(String invoice, String filename, Container container) throws StreamTransformationException{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
BASE64Encoder encoder = new BASE64Encoder();
String encoded = "";
try{
zos.putNextEntry(new ZipEntry(filename));
zos.write(invoice.getBytes());
zos.close();
encoded = encoder.encode( baos.toByteArray());
}catch(Exception e){
return "";
}
return encoded;
}

We need to import a library for Base64 encoding:  sun.misc.BASE64Encoder

Mapping:



UDF:



Regards

3 Comments
Labels in this area