Quantcast
Channel: SCN : All Content - Process Integration (PI) & SOA Middleware
Viewing all articles
Browse latest Browse all 7030

SAP PI 7.0- UDF - Vlookup not exporting value to RFC FM to ECC

$
0
0

we are using SAP PI 7.0, in which, i have enhanced a UDF for one inbound interface.

the problem is, the new parameter i have added as importing parameter to rfc fm via lookup is not been passed to fm. the value is passed as blank. let me know what is the mistake i am doing by looking into the code below.


Importing Parameter in FM at ECC end.rfc_fm_ecc.JPG

 

 

The importing parameter, is coming as blank/space to FM. But the other existing parameters are working properly.

only the newly added parameter in the above screenshot is not getting passed. Where can be the mistake.

 

i have tagged the new changes i made as 'NEW CODE BEGIN/END". Only 3 lines i added. The other 3 existing parameters are working properly, only the newly inserted line with tag 'NEW CODE BEGIN/END' is not getting passed. where can be the mistake, am i missing something!!?


Code:


/****************
(1) Initialization
*****************/
AbstractTrace trace;
trace = container.getTrace();
String content = new String();
String returnValue = new String();
BussinessUnitId = BussinessUnitId.trim();
BusinessUnitName = BusinessUnitName.trim();
PayperiodStartDate = PayperiodStartDate.trim();

trace.addWarning ("Duplicate Enabling Flag: "+Duplicate_Enabling_Flag);

if (Duplicate_Enabling_Flag.equals("YES"))
{
/*******************************************************
(2) filling the string with our RFC-XML (with values)
*******************************************************/
trace.addWarning("Business Unit Id and Store No and PayperiodStartDate. passed to RFC Lookup: " +BussinessUnitId+ " and " +BusinessUnitName+ " and " +PayperiodStartDate);

String m ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
m = m.concat("<ns0:ZHCM_CHECK_DUP_FILES xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\">");
m = m.concat("<BUNIT>");
m=m.concat(BussinessUnitId);
m=m.concat("</BUNIT>");
m = m.concat("<STORE>");
m=m.concat(BusinessUnitName);
m = m.concat("</STORE>");
m = m.concat("<EMAIL_ID>");
m=m.concat(email_id);
m=m.concat("</EMAIL_ID>");
//NEW CODE BEGIN
m = m.concat("<PAYPERIODSTARTDATE>");
m =m.concat(PayperiodStartDate);
m = m.concat("</PAYPERIODSTARTDATE>");
//NEW CODE END
m=m.concat("</ns0:ZHCM_CHECK_DUP_FILES>");

RfcAccessor accessor = null;
ByteArrayOutputStream out = null;

try{

/****************************************************************************
(3) Determine a channel (Business system, Communication channel)
****************************************************************************/
Channel cChannel = LookupService.getChannel(ecc_bs,rfc_chnl);

/*******************************************************
(4) Get a RFC accessor for a channel.
*******************************************************/
  accessor = LookupService.getRfcAccessor(cChannel);

/****************************************************************************************
(5) Create a xml input stream representing the function module request message.

****************************************************************************************/
  InputStream inputStream = new ByteArrayInputStream(m.getBytes());

/*******************************************************
(6) Create xml payload
*******************************************************/
  XmlPayload payload = LookupService.getXmlPayload(inputStream);

/*******************************************************
(7) Execute lookup / Trace
*******************************************************/
Payload result = accessor.call(payload);
InputStream in = result.getContent();

/*****************************************************************
(8) XML parsing - Create a DOM structure from the input XML
*****************************************************************/
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(in);
  
// (8.1)The lookupValue is available as STATUS tag in the response
NodeList list = document.getElementsByTagName("STATUS");
  Node node = list.item(0);

if (node != null) {
node = node.getFirstChild();
returnValue = node.getNodeValue();
trace.addWarning("File Duplicate Flag received from RFC Lookup: " +returnValue);
}

if (accessor!=null) {
try {
accessor.close();
}
  catch (LookupException exp) {
trace.addWarning("Error in RFC Lookup: " +exp.getMessage());
return returnValue;
}
  } 


  }

catch(Exception exp){
  return exp.getMessage();
  }

if (returnValue.equals("Y")) {
RuntimeException re=new RuntimeException("Duplicate File encountered for Business Unit Id " +BussinessUnitId+" for the store: " +BusinessUnitName);
throw re;
}

return returnValue;
}
else 
return "N" ;




Viewing all articles
Browse latest Browse all 7030

Trending Articles