cancel
Showing results for 
Search instead for 
Did you mean: 

File lookup

Former Member
0 Kudos

Hi Experts

I am trying to implement a simple file lookup, can any one tell me which package i need to import while writing the UDF.I am getting an error message ("cannot resolve symbol URL class and URL connection class")

which package is to be imported so that URL class and URL connection etc will work.

Actually URL is the location where the file which i am using for lookup is placed .I need to open a connection to that and do the lookup.

The information stored in the file which i am using is not having "=" instead it has a ":" in between the source and the value

like in this case it will look like :FFFF:66666 in my file not FFFF=66666(tried out same scenario suggested by farooq in his wiki)

Can we do the lookup if the file is in this format ?

Your inputs will help me allot

Regards

Sri

Accepted Solutions (1)

Accepted Solutions (1)

prateek
Active Contributor
0 Kudos

Try this and u may access any set of values

Regards,

Prateek

Answers (4)

Answers (4)

Former Member
0 Kudos

Solved,

You need to inport java.net.* in case you get a error "URL not found"

Try with only one input to UDF and give the file name in the FTP path itself.

Thanks

Former Member
0 Kudos

Hi Experts,

I was trying to implement a file lookiup.I tried what is suggested in the blog by Farooq

[https://www.sdn.sap.com/irj/sdn/wiki?path=/display/xi/file%2blookup%2bin%2budf]

i wanted to test the mapping after writing the UDF, but it gives error where URL is mentioned.

The ftp path/url which i have given is accessable to me and the path mentioned is also correct.

How do i specify the username and password in the udf as the URL which i mentioned in a scecured path?

Is there anything i have to write in the Imports, any java libraray etc.?

Your help will be appreciated

Regards,

Sri

Former Member
0 Kudos

Hi Sri

You can do like this


URL url = new URL("ftp://user:password @ somewhere.com/pub/somefile.xxx");

URL belong to java.lang.object

with this you can use FTP API from Jscape to do FTP from UDF


import com.jscape.inet.ftp.*;

Ftp ftp = new Ftp("ftp.myserver.com","user","password");

// establish connection
ftp.connect();

// perform directory listing
String listing = ftp.getDirListingAsString();

// print directory listing to console
System.out.println(listing);

// Perform directory listing
Enumeration files = ftp.getDirListing();

// iterate through listing
while(files.hasMoreElements()) {
FtpFile file = (FtpFile)files.nextElement();

// only print files that are directories;
if(file.isDirectory()) {
System.out.println(file.getName());

// change local directory
ftp.setLocalDir(new File("C:/tmp");

// Change remote directory
ftp.setDir("temp");

// upload a file named test.txt in c:/tmp directory
ftp.upload(new File("c:/tmp/test.txt"));

// download a file named test.txt in remote directory
ftp.download("test.txt");

// release the FTP server connection
ftp.disconnect();

These can help for lot of FTP related developments

Thanks

Gaurav

former_member192295
Active Contributor
0 Kudos

Hi,

I think the problem is due to URL, check with URL whether have access right or not. We can do, before that first try to open file from UDF after that pick values. No need any extra packages, we can do using simple java code. But better to choose RFC lookup why because file is not suggested way.

Find below link will help u fr file loop up

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/xi/file%2blookup%2bin%2budf

Former Member
0 Kudos

Hi,

Check this on how to do a Lookup on File

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/xi/file%2blookup%2bin%2budf

Regards

Seshagiri