Skip to Content

Error while Integrating SAP PI to Salesforce using SFDC Advantco adapter

Hello Experts,

We are integrating Salesforce using the SFDC Advantco adapter.

We are using the lookup logic for upserting the objects.

blow are the process we follow.

Step 1:Upsert the records in the Product2 object.

Step 2.Upsert the records in Sales Org object for the respective object where we use the Lookup to reference the product2 object

I am using below lookup logic

In this im passing the operation and object type as a input

// declare parameters String elmfValue=""; String OptionValue=""; String sfdcXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Account>" + "<Operation>" + Operation[0] + " </Operation> " + "<ObjectType>" + ObjectType[0] +"</ObjectType>" + "<sObjects><sObject><GB_Sap_Prod_Code__c></GB_Sap_Prod_Code__c>"+"</sObject></sObjects></Account>"; AbstractTrace trace = container.getTrace(); SystemAccessor accessor = null; ByteArrayOutputStream out = null; try { // 1. Determine a communication channel (Business system + Communication channel) Channel channel = LookupService.getChannel("*","Bussiness component name","Communication channel"); // 2. Get a RFC accessor for the channel. accessor = LookupService.getSystemAccessor(channel); // 3. Create an XML input stream that represents the RFC request message. InputStream inputStream = new ByteArrayInputStream(sfdcXML.getBytes()); // 4. Create the XML Payload XmlPayload payload = LookupService.getXmlPayload(inputStream); // 5. Execute the lookup. Payload resultLookup = null; resultLookup = accessor.call(payload); InputStream in = resultLookup.getContent(); // 6. Create a DOM structure from the input XML DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(in); NodeList list = document.getElementsByTagName("queryResponse"); // Node node = list.item(0); if (node != null) { node = node.getFirstChild(); if (node != null) { list = document.getElementsByTagName("Product2"); node = list.item(0); if (node != null) { //trace.addWarning("Account : " + node.getTextContent()); list = document.getElementsByTagName("GB_Sap_Prod_Code__c"); node = list.item(0); if (node != null) { trace.addWarning("GB_Sap_Prod_Code__c : " + node.getTextContent()); result.addValue(node.getTextContent()); } } } // 7. To free resources, close the accessor.. if (accessor!=null) { try { accessor.close(); } catch (LookupException e) { trace.addWarning("Error while closing accessor " + e.getMessage() ); } } } catch (Exception e) { trace.addWarning("Error" + e); }

But I am getting following error:(channel is not getting called inside the lookup logic)

<Trace level="1" type="T">Interface Mapping OM_GL_IR_SalesORG</Trace> <Trace level="1" type="T">*** START APPLICATION TRACE ***</Trace> <Trace level="1" type="T">Errorcom.sap.aii.mapping.lookup.LookupException: Error when calling an adapter by using the communication channel SFDC_Salesforce_Receiver (Party: *, Service: BC_HHGL_Salesforce_Test, Object ID: b3f11c959e293ceba7a5ef4d866b6f83) XI AF API call failed. Module exception: 'Permanent error: Adapter call failed. Reason: com.sap.aii.af.lib.ra.cci.XIAdapterException: '. Cause Exception: 'com.sap.aii.af.lib.ra.cci.XIAdapterException: '.</Trace>

CAn anybody help me on this

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers