In this blog, SAP PI UDF example is been provided for below functionalities:
- To check file names in sap application directory with some starting key words
- If file is present, then compress it with zip extension and move it to other directory
- Post Archival, delete the file from source path
Java Imports required in UDF as
-
java.io.BufferedReader java.io.FileReader java.io.IOException java.util.zip.ZipEntry java.util.zip.ZipOutputStream
Java UDF Execution Type is “All Values of Queue”
Java UDF Code is as below:
public void file_Read_Move_Delete(ResultList result, Container container) throws StreamTransformationException{ String RequestDataStr = "XYZ"; //File Name Starting Key String FilePath_str = "/folder1/folder2/"; //File directory String FileArchival_Path = "/folder1/folder2/folder2/"; //File Archival Path String fileContentStr = ""; boolean StartsWithStr_Found = false; File[] dirFiles = new File(FilePath_str).listFiles(); if (dirFiles.length > 0){ //Check if Directory is not empty for (int i=0; i
New NetWeaver Information at SAP.com
Very Helpfull