In this blog, SAP PI UDF example is been provided for below functionalities:
- To read file contents of a file from sap application directory,
- here read only those files which names starts with some key words
- To archive same file to other sap application 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 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