on 04-25-2009 2:07 PM
Hi All,
I have some doubts regarding accessing file from PI application server. I am writing UDF which reads say "plant.txt" flat file from the PI application server. Is it possible to access file in UDF?
Below is the sample code I have wriiten in eclipse editor which is working fine. And tell where I need to keep this file.
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public
class CsvTest {
public void readFile() {
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader("D://plant.txt"));
String line = null;
int totalElements=0;
while ((line = br.readLine()) != null) {
String[] values = line.split(",");
totalElements= totalElements + values.length;
for(int i=0;i<values.length;i++)
{ System.out.println(values<i>);
}
}
System.out.println(totalElements);
}
catch (FileNotFoundException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
finally {
try {
if (br != null)
br.close();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
public static void main(String[] args) {
CsvTest test =
new CsvTest();
test.readFile();
}
}
Please help me out.
Thanks in Advance,
Nisha
Hi,
We have 2 options.
1:) If you need to pick a file from file server using XI, then it has to be picked by the File adapter which needs all the required detials like IP address,folder name and file name,etc..
2:) If you need to pick it from IR, then you need to export it.But you need not require to mention the file path as you have mentioned.(D:
fileName).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Accessing a file in UDF/Mapping would be a very bad design approach. I would strictly recommend not doing this. If the file is important as per your interface, then you should be thinking about a BPM with a separate receive step to get the content of the file and not just access it via UDF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you are talking about the java code then you need to generate the Jar file and need to load into the IR (Imported archive section) and then make use at mapping..
If you are talking the file path then you can keep at NFS share of PI(i.e sap/global/sys/...) path
i.e there is one folder where application relation data can be kept(chk with basis for exact path)
Rajesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
We can keep file in any folder(it should be read & write permission else will throw error while reading. Generally will keep D or F drive) in you current server, meanwhile we can access file from UDF. Better to keep file in restricted folder to prevent access from other one. But according to SAP PI standards it is not good practise to access file from UDF. According to your requirement choose RFC or JDBC lookups. I hope now clear
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.