File Lookup in UDF: We almost are familiar with lookups and its types in SAP XI/PI i.e. JDBC, SOAP and RFC. These adapters support synchronous call and it's possible to send request and get response in Message Mapping.
I encountered a scenario in which I need to do lookup from "File" in UDF. This file contains some entries or better to say key-value. Based on the key I have to pick the value and need to Map it to the target field.
Let me demonstrate it with dummy example:
Below file (lookup.txt) contains the key-values information where "FFFF" is the customer name and "6666 is the corresponding customer number with it.
In the Message Mapping based on the CustomerName the value of CustomerNo need to map.
This can be achieve by creating a UDF, see the below screen.
UDF name here "getCustomerNumber" accept the two string values
1. For CustomerName and
2. lookup file name (from which we need to read the values/text).
Code look like this: -
//Create and Open the connection with FTP server using URL class,
// get the Input Stream, Stream reader and buffered reader...
// read the buffer and get the values based on condition/matching
// close the buffer and return the value from UDF
Unknown User (bkm90xj)
I am having a similar requirement as mentioned in your blog.I tried to implement the same but i am getting some errors
1.For using URl calls in the UDF which package we need in import.I am getting an error "cannot resolve symbol URL class and URL connection class"
2.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.
Can we do the lookup if the file is in this format ?
Your inputs will help me allot
Unknown User (x1sfwa5)
Its too long but i came to this blog today... Its very good for understanding for starters like me.
Sri try importing java.Net.URL or java.Net.* package, it may work.