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