Skip to Content
Technical Articles
Author's profile photo Pavan Kumar

REST Look Up using UDF in SAP PO

Hello Experts,

I have read many blog posts for performing the REST Look up using Java mapping but I felt it would be helpful if we can achieve REST look up using UDF. Hence I have tried blogging one of the scenario where I have used REST Look up using UDF.


Scenario: We have a scenario where a field ‘Code’ value has to be checked in the target system for its existence.  Based on its existence I have to pass the value “True” if it exits else I have to pass “False” in my UDF.


Step1: Create a receiver communication channel for your look up using REST adapter.

Communication Channel : CC_LookupChannel_REST

Create a Message type to receive your response message through the lookup channel and assign the message type in the Element name and its namespace respectively.

Step2: Create your Message mapping as required and pass the required source fields to the UDF as inputs. In my case I have passed a value ID and Bussiness Component and Lookup Channel Names as inputs to the UDF.

Step3: Create the UDF in your message mapping using the below code.

Here I am passing business component and Lookup channels as inputs which are passed using parameterized mapping.


Parameterized Mapping Values:

Following Parameterized values are to be passed from your ICO/IFLOW.

Lookup Channel Name(ChannelName): CC_LookupChannel_REST

Business Component: BC_Target



public void RESTLookup(String[] var1, String[] BusinessComponent, String[] ChannelName, ResultList result, Container container) throws StreamTransformationException{


AbstractTrace trace = container.getTrace();
String floc=””;

Channel channel= LookupService.getChannel(BusinessComponent[0],ChannelName[0]);

SystemAccessor accessor = LookupService. getSystemAccessor(channel);

// Look up service xml

String RestXML = “<?xml version=\”1.0\” encoding=\”UTF-8\”?><ns2:MT_RESTIN_V01 xmlns:ns2=\”urn:std:restlookup”><Equipment><Code>”+var1[0]+”</Code></Equipment></ns2:MT_RESTIN_V01>”;

InputStream inputStream= new ByteArrayInputStream(RestXML.getBytes());

XmlPayload payload = LookupService.getXmlPayload(inputStream);

Payload RESTOutPayload = null;

RESTOutPayload =;

InputStream inps = RESTOutPayload.getContent();

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(inps);

NodeList list = document.getElementsByTagName(“Code”);
Node node = list.item(0);
if (node != null) {
//result.addValue( “True”);
//floc = node.getNodeValue();
node = node.getFirstChild();
if (node != null) {
floc = node.getNodeValue();


}catch (Exception e) {

result.addValue( “True”);
result.addValue( “False”);



Hope this will be helpful 🙂


Pavan Kumar P

Reference Blog posts:


Assigned tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Bhargava krishna Talasila
      Bhargava krishna Talasila

      Nice blog.  Thanks

      Author's profile photo Pavan Kumar
      Pavan Kumar
      Blog Post Author

      Thanks Bhargava Krishna.