Skip to Content
Author's profile photo Former Member

Leveraging PI Java Mapping to integrate PI 7.31 AEX with SFDC cloud Server

1.     Introduction  and Business Requirement:

1.1.     We have seen lot of blogs/docs regarding SFDC and PI integration in SCN then what is new in this blog? Well, in this blog I would like to share my learning/experience on the integration of PI with SFDC in different approach which is very simple, easy and fast way to configure (initial set-up may take little time) and run the interface without any complexity. Without spending more time on what is SFDC cloud server and its CRM capabilities I will jump directly to business requirement/scenario that I am explaining in this blog as most of us know about SFDC.

          Client was having requirement to create eligible customers from SFDC to SAP ECC, Update back SAP customer number from SAP ECC to SFDC as response, Creation of Sales Orders from SFDC to SAP and Update SAP Sales Order Number/Date as response. There were lot of blogs/use case docs regarding SAP PI with SFDC integration in SCN. I followed the steps and  started implementing it in PI, but I felt little complexity in building this interfaces as we have to maintain Session IDs, two SOAP receivers, URL settings, Content type change etc. Then I had searched in SFDC Developers Force link, on how other applications are integrating with SFDC. I got some important info that using Java API generated from enterprise WSDL document provided by SFDC it would be very easy to integrate the SFDC with java applications.

          As SAP PI supports java mapping in Operation mapping, I started developing the code and leveraged it to login to SFDC server and do the DML operations by directly calling simple Java method calls without bothering on session IDs, SOAP message header, Server URLs, Content Type etc. At end, we successfully implemented these scenarios and they are running in production smoothly. So I thought to share this new way of integrating the SAP PI 7.31 with SFDC Cloud Server by leveraging the java mapping program to SAP Ecosystem Community so that others can also get benefit from this blog.

1.2.     Business Scenario:

          1.2.1. Retrieve all the new customer information from SFDC server having StageName field as ‘Order Pending’ and create the Customers in SAP ECC with retried data info and Update back the SAP customer number back to SFDC.

          1.2.2. Retrieve all the new Sales Order Information from SFDC and create Sales Orders in SAP with retried data and update the SAP Sales Order Number back to SFDC.

2.     Currently available solutions in PI:

2.1.     Third party REST adapters which ready to use to integrate with SFDC server.

2.2.     Third party solution/packages.

2.3.     Using PI SOAP Receiver adapters and adding session IDs in SOAP message header. Please check blog links given in reference section. These are little complex scenario and difficult to manage the sessions IDs.

3.     What is the benefit of this new approach (Leveraging PI Java Mapping):

3.1.     No need to have any PI SOAP Receiver adapters! in Integration Directory.

3.2.     No need to add session ID token in the SOAP message header as we are not going to use any SOAP messages at all! We will be to using SFDC java API calls that are generated from enterprise WSDL document.

3.3.     No need to have SOAP lookup code for retrieve the Session ID and No need to use Dynamic Configuration code to set the Sever URL, No need to use MessageTransformBean for changing the content type.

3.4.     Supports request and response messages using simple asynchronous interfaces (i.e. asynch-synch-asynch flow).

3.5.     Simple step to generate the APIs from SFDC enterprise WSDL document. Simple API call Connector.newConnection() to login to SFDC server, Simple API calls like EnterpriseConnection.Create(), update(), query() etc. for DML operations to process the data in SFDC server. Please see the java code below for further info.

3.6.     Simple steps to import Java mapping class, SFDC jars (enterprise.jar, wsc-22.jar) in ESR, simple steps to test the SFDC connection, easy  to troubleshoot as we can add custom log info using getTrace().addInfo() and re-throw the SFDC API exceptions back to PI Mapping runtime.

4.     About SFDC login and WSDL document:

4.1.     SFDC Server API login and Security Token: We use user id and password to login to SFDC server through web browsers, while connecting SFDC from applications e.g. PI, web services, applications need to login through API i.e. through SFDC API call, SOAP based/Rest based web service calls. While login to server through API, we need additional security password called Security Token along with your password. It will be alphanumeric long string that will unique to the particular user id which has to be passed along with password by appending it to password i.e. Mypassword+SecurityToken (without + char).

          You can generate/re-set this security token from SFDC server. Click on Personal Setup –> select My Personal Information –> Reset My Security Token. The new security token is sent to the email address of user.


If you are using any SOAP applications e.g. SOAP UI, PI SOAP adapter, you also need session Id to be passed in the SOAP Message header. You need to pass this every time while you hit the SFDC server and in some times, you have to maintain/manage this session IDs for complex transactions.  In our approach, we are login through SFDC APIs generated from enterprise WSDL, which does not require session ID to be maintained or to be added in the SOAP header! See 5.2.3 section for more info.

4.2.    SFDC Enterprise WSDL: To access the SFDC server’s Web services, you need a Web Service Description Language (WSDL) file.  SFDC provides the enterprise WSDL file to download from its server. Using this we can generate the APIs to login to SFDC server and do the DML Operations (Select/Insert/Update/Delete). We can download this WSDL by log in to your organization and click Setup –> Develop –> API, right-click on ‘Generate Enterprise WSDL’ and save it in local drive, rename the file from .xml to .wsdl.


4.3. Generating Enterprise.jar using WSDL: First download the SFDC’s wsc-22.jar file from at And to generate the enterprise.jar file, run the following command in command prompt. Provide the directory path of wsc-22.jar, enterprise.wsdl where these are stored and output directory path, make sure you have installed Java JDK 1.6+ in your system to run this command.

java –classpath pathToJAR/wsc-22.jar pathToWsdl/WsdlFilename  pathToOutputJar/OutputJarFilename

e.g. java –classpath C:\SFDC\wsc-22.jar C:\SFDC\enterprise.wsdl  C:\SFDC\enterprise.jar

5.     PI ESR Configurations:

5.1.     Below is Flow diagram of Retrieving SOs from SFDC updating in SAP data flow.

Flow Daigram.jpg

SAP side there will be a batch program running which will be scheduled in background, which will initiate the PI interface with asynch ABAP Proxy call. At receiver determination step, operation mapping is called and which in turn calls java program which does all the login to SFDC, issuing DML operations and processing of records returned from SFDC. Once DML operation is successful, java program forms the target message type structure and sends to receiver system. Since data is required at SAP ECC side, using receiver SOAP adapter in XI mode, asynch ABAP Proxy is called and forwards the records that is received from SFDC. Please refer below sections for java code.

5.2.     Java mapping code to login and to process SFDC data to do DML Operations:

5.2.1.     In SAP NWDS, create the class eg. PISelectSalesOrders which will extends the AbstractTransformation class so that it can override the transform() method. You need to import the enterprise.jar and wsc-22.jar file as library jars to compile the java code.

5.2.2.     Then next step is that in the transform() method, prepare a SQL Query string to be issued to SFDC Server, see below screen shot:


5.2.3.     Login to SFDC Server through API: Please check the below screen shot to connect to SFDC server by using Connector.newConnection()  method call, please note that, for password input you have send both SFDC login password appended with security token corresponding to the user id.


5.2.4.     Issue SQL query using connection.query(queryString) method by passing SQL query that you formed in previous steps and store the response from SFDC server in QueryResult object. Use getTrace.addInfo() after every operations so that you will get to know what step it crossed and it would be helpful in case of trouble-shooting.


5.2.5.     Process the Result using QueryResult object and form Target Message Type structure by using String builder object.


5.2.6.     Similar to above other DML Operations like create/Update and Delete can be used, in below screen shot you can see that code is updating back the SAP Sales Orders from SAP ECC to SFDC by using connection.update().


5.2.7.  Please note that from SFDC side, Opportunity.Id column is unique Id using which we can retrieve/update/delete the records in SFDC, so we need to store this value in SAP custom Z table (e.g. SFDC_Opportunity_ID field) when we first retrieve the data. Set the flags in Z table whenever we update back the SO number or customer number so that we should not update same records again and again.


5.3.     Importing SFDC jar files into ESR using Imported Archives: Once you are done with java mapping program and testing, import the generated enterprise.jar and wsc-22.jar files into ESR namespace using Imported Archives Object along with java mapping jar/zip file.

5.4.     Create the Operation Mapping in the ESR and assign java mapping program to it. Now we all set to do testing the connection and issuing DML queries to SFDC. Ready from ESR side.

5.5.     Before testing the java mapping make sure that you have disabled VM parameter –|iaik.protocol as this will disable to use iaik security package as default security package. For connecting SFDC server using https protocol we need to use underlying Java security package.

6.     PI ID Configurations:

Since login and issuing DML commands are all happening in Operation Mapping (Java Program) there are only little configurations required at ID side.

6.1.     If we are having Update/Create Query (SAPàPIàSFDC) then we can use simple File adapter at Receiver side to complete end to end scenario and while interface determination, Operation Mapping would be called and does the Update/Create operation.

6.2.     If we are having Select Query (Batch ProgramàPIà SFDC for fetching data, SAPßPIßSFDC Updating to SAP) wherein we have to fetch all the records from SFDC depending condition and Update the retried data to SAP then we should have ABAP Batch Programà PIà ABAP Proxy scenario where operation mapping will fetch all the records and forma the target Message Type and it would be send across to ABAP Proxy. For PI point of view this transaction is asynchronous but in java mapping it is handling request-response messages.

6.3.     In case of any errors while login or DML operations, Java program would throw error with appropriate log and Operation mapping will get fail and interface would fail which will send out PI alert mail to respective support team.

7.     Summary:

In summary, using PI java mapping and SFDC enterprise WSDL document, wsc-22.jar and SFDC java APIs we can easily integrate the SFDC Cloud Server without worrying on Session IDs, SOAP Header, Server URLs and concentrate only on business logics and DML query.  I really enjoyed while writing java code after long timeJ, here with this I would like to conclude this blog. Comments are welcome.

8.     References:






Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Santhosh Kumar Vellingiri
      Santhosh Kumar Vellingiri


      So basically this is a adapter less communication to SFDC and achieved using a Java Client Proxy application in form of PI Java Mapping.

      Pls can you explain bit more how the synchronous response from SFDC to the Java Mapping was transformed and sent back to SAP asynchronously.


      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Santosh,

      Response from SFDC will be in ResultSet Object that will be processed in java mapping after issuing the DML commond. With ResultSet you will form the Message Type(MT) according to SAP asynch MT and In configuration at reciver side you will be providing SAP ECC (using SOAP in XI mode). With this scenario you convert synch response from SFDC to asynch SAP call.

      Let me know if you need more info on this.


      Author's profile photo Raj Thukiwakam
      Raj Thukiwakam

      well written..good blog.

      Author's profile photo Sandeep Narayan
      Sandeep Narayan

      God one Raju! ­čÖé

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Sandeep..

      Author's profile photo Former Member
      Former Member


      I also do ecc 2 sfdc interface. But I don't use java mapping, instead, I use udf to implement it. For the channel, I use http and soap.

      There are too many tech problem to solve. Though I worked it out, but I still think it is not a good solution.

      Now we use websphere cast iron to implement the interface. It has the sfdc adapter. The adapter can do lots of dirty job, like split the msg.

      The cloud is coming, I hope xi not drop out.

      Author's profile photo Former Member
      Former Member

      Hi Rajendra,

      I am currently doing some POC to verify which of the integration methods are best suited for our interfaces betrween SFDC and SAP CRM. We are using PI 7.11 as the middleware layer between the two applications. At this stage I am very much in favor of using your Java API based integration, as it is the least complex of all I scenarios I have seen so far.

      In the title of your blog you mention PO 7.3, does this mean your sample only works with this version or have you tested it against other version such as PI 7.11. The reason I am asking is that I get an exception "java.lang.UnsupportedOperationExcetion, Method not implemented" in my java mapping when establishing the connection to SFDC. My java program works fine when running it outside PI using NWDS. I am using JDK 1.5 and have created the jar archives accordingly. I used Java 1.5 because PI 7.11 is using it as well.

      I did notdo the step|iaik.protocol

      as I did not see it set PI startup log. Also I don't know where to set\verify this in PI 7.11, maybe you can point me to the correct place.

      Do you know whether this is causing my problem or could you give me some indication what the problem might be.

      Thanks in advance.


      Below are the default trace entries related to the problem......

      #2.0#2013 12 11 11:44:43:654#+1100#Error#System.err# J2EE Engine JTA Transaction : [03effffffe5ffffffc20021ffffffc2]#AFB96D4B0BC81000CDC9F3C9CF2B0171#afb96d4b0bc81000cdc9f3c9cf2b0171#afb96d4b0bc81000cdc9f3c9cf2b0171#0#Thread[RMI/IIOP Worker [0],5,Dedicated_Application_Thread]#Plain##

      1. java.lang.UnsupportedOperationException: Method not implemented.#

      #2.0#2013 12 11 11:44:43:654#+1100#Error#System.err# J2EE Engine JTA Transaction : [03effffffe5ffffffc20021ffffffc2]#AFB96D4B0BC81000CDC9F3C9CF2B0171#afb96d4b0bc81000cdc9f3c9cf2b0171#afb96d4b0bc81000cdc9f3c9cf2b0171#0#Thread[RMI/IIOP Worker [0],5,Dedicated_Application_Thread]#Plain##


      #2.0#2013 12 11 11:44:43:654#+1100#Error#System.err# J2EE Engine JTA Transaction : [03effffffe5ffffffc20021ffffffc2]#AFB96D4B0BC81000CDC9F3C9CF2B0171#afb96d4b0bc81000cdc9f3c9cf2b0171#afb96d4b0bc81000cdc9f3c9cf2b0171#0#Thread[RMI/IIOP Worker [0],5,Dedicated_Application_Thread]#Plain##


      #2.0#2013 12 11 11:44:43:654#+1100#Error#System.err# J2EE Engine JTA Transaction : [03effffffe5ffffffc20021ffffffc2]#AFB96D4B0BC81000CDC9F3C9CF2B0171#afb96d4b0bc81000cdc9f3c9cf2b0171#afb96d4b0bc81000cdc9f3c9cf2b0171#0#Thread[RMI/IIOP Worker [0],5,Dedicated_Application_Thread]#Plain##


      #2.0#2013 12 11 11:44:43:654#+1100#Error#System.err# J2EE Engine JTA Transaction : [03effffffe5ffffffc20021ffffffc2]#AFB96D4B0BC81000CDC9F3C9CF2B0171#afb96d4b0bc81000cdc9f3c9cf2b0171#afb96d4b0bc81000cdc9f3c9cf2b0171#0#Thread[RMI/IIOP Worker [0],5,Dedicated_Application_Thread]#Plain##


      #2.0#2013 12 11 11:44:43:654#+1100#Error#System.err# J2EE Engine JTA Transaction : [03effffffe5ffffffc20021ffffffc2]#AFB96D4B0BC81000CDC9F3C9CF2B0171#afb96d4b0bc81000cdc9f3c9cf2b0171#afb96d4b0bc81000cdc9f3c9cf2b0171#0#Thread[RMI/IIOP Worker [0],5,Dedicated_Application_Thread]#Plain##


      #2.0#2013 12 11 11:44:43:654#+1100#Error#System.err# J2EE Engine JTA Transaction : [03effffffe5ffffffc20021ffffffc2]#AFB96D4B0BC81000CDC9F3C9CF2B0171#afb96d4b0bc81000cdc9f3c9cf2b0171#afb96d4b0bc81000cdc9f3c9cf2b0171#0#Thread[RMI/IIOP Worker [0],5,Dedicated_Application_Thread]#Plain##


      #2.0#2013 12 11 11:44:43:654#+1100#Error#System.err# J2EE Engine JTA Transaction : [03effffffe5ffffffc20021ffffffc2]#AFB96D4B0BC81000CDC9F3C9CF2B0171#afb96d4b0bc81000cdc9f3c9cf2b0171#afb96d4b0bc81000cdc9f3c9cf2b0171#0#Thread[RMI/IIOP Worker [0],5,Dedicated_Application_Thread]#Plain##


      #2.0#2013 12 11 11:44:43:654#+1100#Error#System.err# J2EE Engine JTA Transaction : [03effffffe5ffffffc20021ffffffc2]#AFB96D4B0BC81000CDC9F3C9CF2B0171#afb96d4b0bc81000cdc9f3c9cf2b0171#afb96d4b0bc81000cdc9f3c9cf2b0171#0#Thread[RMI/IIOP Worker [0],5,Dedicated_Application_Thread]#Plain##


      #2.0#2013 12 11 11:44:43:654#+1100#Error#System.err# J2EE Engine JTA Transaction : [03effffffe5ffffffc20021ffffffc2]#AFB96D4B0BC81000CDC9F3C9CF2B0171#afb96d4b0bc81000cdc9f3c9cf2b0171#afb96d4b0bc81000cdc9f3c9cf2b0171#0#Thread[RMI/IIOP Worker [0],5,Dedicated_Application_Thread]#Plain##

      at com.sforce.soap.enterprise.EnterpriseConnection.login(

      #2.0#2013 12 11 11:44:43:654#+1100#Error#System.err# J2EE Engine JTA Transaction : [03effffffe5ffffffc20021ffffffc2]#AFB96D4B0BC81000CDC9F3C9CF2B0171#afb96d4b0bc81000cdc9f3c9cf2b0171#afb96d4b0bc81000cdc9f3c9cf2b0171#0#Thread[RMI/IIOP Worker [0],5,Dedicated_Application_Thread]#Plain##

      at com.sforce.soap.enterprise.EnterpriseConnection.<init>(

      #2.0#2013 12 11 11:44:43:654#+1100#Error#System.err# J2EE Engine JTA Transaction : [03effffffe5ffffffc20021ffffffc2]#AFB96D4B0BC81000CDC9F3C9CF2B0171#afb96d4b0bc81000cdc9f3c9cf2b0171#afb96d4b0bc81000cdc9f3c9cf2b0171#0#Thread[RMI/IIOP Worker [0],5,Dedicated_Application_Thread]#Plain##

      at com.sforce.soap.enterprise.Connector.newConnection(

      #2.0#2013 12 11 11:44:43:654#+1100#Error#System.err# J2EE Engine JTA Transaction : [03effffffe5ffffffc20021ffffffc2]#AFB96D4B0BC81000CDC9F3C9CF2B0171#afb96d4b0bc81000cdc9f3c9cf2b0171#afb96d4b0bc81000cdc9f3c9cf2b0171#0#Thread[RMI/IIOP Worker [0],5,Dedicated_Application_Thread]#Plain##

      at com.dieterbauer.common.SFDCIntegrationUsingJavaAPI.transform(

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Dieter,

      You have two queries here.

      1. Does sample example works only with PI 7.3?

      Ans -> No. solutions works with all versions PI . 7.0 to 7.4 (PO). Proof is that, as you said outside ESR, in NWDS solution works and it able to connect to SFDC server.

      2. How to solve the "java.lang.UnsupportedOperationExcetion, Method not implemented" issue.

      Ans -> As per my knowledge, even I had face this issue at the beginning. When I rasied the SAP ticket regarding this then SAP Support guys asked me to disable the VM parameter to avoid iaik security package to be used while connection.

      So you need to disable this VM parameter|iaik.protocol from the NWA or Config Tool of PI server. I tool basis team help in disabling this parameter. You can take help from your basis team and disable it and then try connecting to SFDC and make sure that you have imported the enterprise.jar and wse-22.jar files into ESR namespace. Please let me know the results once you re-test it.

      All the best,


      Author's profile photo Former Member
      Former Member

      Hi Rajendra,

      I have had some success today getting your solution to work with PO 7.31. By removing the value|iaik.protocol from parameter java.protocol.handler.pkgs I was able to do the call to SFDC from within PO (Operation mapping test tool and at runtime of the interface).

      However my customer for which I need this solution is using PI version 7.11 and I checked the java settings of that system to verify whether the parameter java.protocol.handler.pkgs exists.

      Unfortunately there is no trace of this parameter in either the NWA Java system properties or the offline Config tool. The error message I am receiving in PI 7.11 is the same as it was in PO 7.31 which I have been able to resolve with the above change. The parameter java.protocol.handler.pkgs appears to be only applicable to later versions of PI \ PO (7.3x and 7.4x). I have done a test by adding this parameter to the PI 7.11 java system properties, however this didn't make a difference either.

      You mentioned you reported the problem to SAP initially, did they recommend a different parameter to change for older release of PI (< PI 7.1x). Is there an OSS note about this that you could share so that I can go back to OSS asking how to resolve the issue in PI 7.1x.

      Also, would you know what the impact will be for other HTTPS based integration scenarios (SOAP \ HTTP) if this parameter is disabled in PO. Did you have any negative experiences by changing this parameter.

      Thanks in advance.


      Author's profile photo Anupam Ghosh
      Anupam Ghosh

      Hi Rajendra,
      Nice blog. Thanks for publishing the same.


      Author's profile photo KARUNAKAR ADAPA

      Hi Rajendra,

      Nice blog. Thanks for publishing the same.

      i am integration SAP with salesforce through SAP PI7.5 using REST adapter and Oauth2.0.

      able to connect salesforce and able to insert & delete records.

      Please help me to Query salesforce as mentioned in blog using REST adapter and Oauth2.0.

      Thanks in advance for your help.

      Best Regards,