Skip to Content
Author's profile photo Former Member

PI.DOC – Successfactors BizX Integration using PI Java Mapping – Query Operation on CompoundEmployee Entity – Part I

Landscape / System Details:

SAP PI Version: SAP Netweaver 7.30    &Single Stack

SFSF BizX Entity : CompoundEmployee

Source System: Non SAP – SOAP System

Target System: File System

Query System: Successfactors

   

Target Audiance :

1. Consultant want to integrate Third-parties with SFSF BizX.

2. Consultant want to know How to call Client WSDL  in Java Mapping.

                

Document Objective:     

Sample Scenario : Query Employee Data from SFSF – CompoundEmployee Entity.

The document provides a step by step execution of test scenario “querying employee information from SFSF Biz X – CompoundEmployee Entity”.

This process can be resused for other entities too.

Requirements as per FD :-

Image 3.JPG

Implemented Solution :

    

All above said requirement can be full filed by using Employee compound application programming interface (API) for SuccessFactors’ Employee Central.

The service is used to extract employee data out of Employee Central. This API allows you to easily integrate data with external systems and applications.

The API compound Employee selects multiple entities related to an employee and returns all data in hierarchically-structured response XML with the employee person data as the root node.

              

Image 4.jpg

Select items

     

The select items are a list of all entities to be returned as part of the hierarchical query result xml. The restriction of fields is not supported.

The following sub-structures are supported:

person

personal_information

address_information

phone_information

email_information

person_relation

employment_information

job_information

compensation_information

paycompensation_recurring

paycompensation_non_recurring

payment_information

accompanying_dependent

alternative_cost_distribution

job_relation

direct_deposit

national_id_card

    

Image 5.jpg         

    

Where expression

The where expression can be used to filter the query result. The compound API does not support expressions with complex conditions on several fields and different logical operators.

The API supports the following fields and operators:

Field Remark Valid Operators

LAST_MODIFIED_ON

COMPANY_TERRITORY_CODE

PERSON_ID

PERSON_ID_EXTERNAL

COMPANY

EMPLOYEE_CLASS

DEPARTMENT

DIVISION

BUSINESS_UNIT

LOCATION

JOB_CODE

PAY_GROUP

EFFECTIVE_END_DATE

      

Image 6.jpg

Note : There is no SAP ECC System involved in this Scenario.

    

Technical Solution:

     

This document explains the configuration of SAP PI scenario which can be used for query employee data. Entire process consisting of the login, logout, query and QueryMore operation on SF Side.

Image 1.jpg

Above Screenshot: Integration solution to integrate Non SAP System with SFSF to File System using SAP PI Middleware.

          

Third Parties and SAP PI integrated through SOAP (HTTP) and FTP connector.

SAP PI to SFSF connection has been maintained in Java Mapping using  Java Class “SOAPConnectionFactoryclass and its family.

All calls are Asynchronous in nature between SAP PI and Third-Party.

All calls are Synchronous in nature between SAP PI and Successfactors.

         

SFSF Demo Endpoint URL: https://salesdemo4.successfactors.com:443/sfapi/v1/soap

     

Image 2.jpg

Above Screenshot: Operation Mapping has two mappings added in it

1. Java Mapping : Establish connection from Successfactor and based on Select request Query it will return the Intermediate Response XML Data.

2.Graphical Mapping : Perform transformation function returned response XML Data and finally pass it to Target File Communication channel.

Technical Solution

Step 1. Source System triggers the process with Select Query XML Data.i.e. here Source System is Webservice Navigator or SOAP UI.

Step 2. Data will be received to SAP PI using SOAP [HTTP] Sender adapter.

Step 3. Then this Select Query and SF Credentials XML Source Data will be passed to Java Message Mapping.

Step 4. Java Message mapping is written to perform Login , Query , Query more , Logout opreations and pass the Intermediate XML response / result to Next Mapping of Opeartion Mapping.

     4.1. A successful login will return a session ID as Lookup Response.

     4.2. Then this cookie must be passed back to all subsequent SF API Operation Calls in order to authenticate.

     4.3. Then we will call the Select Query Opeartion to fetch employee data. There is a limitation of 800 records in one call.

     4.4. We can check this on the basis of hasMore parameter. If it comes as true then we will call the queryMore operation to fetch remaining records on the basis of QuerySessionID parameter.

     4.5 Again there is limitation of 800 records in one call. So we will have to call step 4.4 in loop until hasMore paramter comes as false.

Step 5. Later Intermediate XML Data fetched during 4.1 to 4.5 step will be passed to graphical Mapping to handle the transformations and finally pass it to Target Communication channel.

Step 6.  Target Adapter or Communication Channel will create a Response XML file on FileSystem.

              

Important points to consider before setting up Integration scenario between SAP PI and SFSF interface are following :-

1. Opening firewall unidirectional port 443 from SAP PI to SFSF

2. Being B2B – Secure call this would need security Certificates in Trusted CA and WebStore.

3. You may not have Axis protocol in your SAP PI Box. Get it deployed explicitly.

    

Note : Please follow <Click Here> to get more information on above points.

     

PI ESR Object Development Overview

Source Message Type : Request

Message Type is created  to carry select query and username/password/company id from source side.

Select query can be dynamic all the time but should be in proper syntax.

Username-Password -Company will be used to get the sessionID from SFSF.

Image 15.JPG

                   

Intermediate Message Type : CompoundAPI_XSD

XSD is created based on structure similar to CompoundEmployee Entity and uploaded in External Defination.

You can use tool like Altova XMLSpy to handle such cases.

Image 7.JPG

    

Target Message Type : Employee_Response_MT

Message Type is created on the basis of Target file Struture given in FD.

Image 8.JPG

Create Outbound and Inbound Asynchronous service interface.

Name : WSDLCalling_Async_Out

Image 9.JPG    

    

Name: WSDLCalling _Async_In

Image 10.JPG

    

Message Mappings:

Java Mapping : Source XML to Intermediate XML.

Establish connection from Successfactor and based on Select request Query it will return the Response XML Data.

Name: com/sap/integration/sfsf/CompundWSDLMapping_New

Image 14.JPG    

Image 13.JPG

     

Graphical Mapping: Intermediate XML to Target Message Type.

Perform transformation function returned response XML Data and finally pass it to Target File Communication channel.

Name: CompoundAPI_MM

Image 11.JPG

              

ROperation mapping – There are two message mappings in one operation Mapping.

Name : OperationMapping_WSDLCalling_JavaMapping

Image 12.JPG

Due to Size limitation rest will be continued to PI.DOC – Successfactors BizX Integration using PI Java Mapping – Query Operation on CompoundEmployee Entity – Part II

Assigned Tags

      14 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi Prabhat,

      Very interesting implementation of integration with SFSF.  This eliminates the need for using BPM when the queryMore is looped.

      I have a couple of questions for your example:

      1. For the XSD of CompoundEmployee, how did you generated it using XMLSpy? Did you use the result of describeEX of CompoundEmployee?  If it was generated from the response XML of actually executing it in a tool like soapUI, then the XSD would only contain the elements you selected in the request.  This would not be complete for all queries.
      2. Is it possible to make this generic enough for all queries, not just CompoundEmployee?
      3. Would you recommend this for update operations?  Using a mapping program might result in other type of problems.
      4. Is it possible to include the complete code of your java mapping program?

      Nice job.

      Thanks,

      William

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

      Hey William,

      First of all @ thanks for appreciating my efforts.

      feedback and comments from PI Expert like you always encourages
      us to write more useful Blogs.

      Now about your Queries :-

      1.For the XSD of CompoundEmployee,
      how did you generated it using XMLSpy? Did you use the result of describeEX of
      CompoundEmployee?  If it was generated
      from the response XML of actually executing it in a tool like soapUI, then the
      XSD would only contain the elements you selected in the request.  This would not be complete for all queries

      Answer :-

      XSD :

      1. Taken Sample Response XML given in Successfactor EC_CompoundEmployee_API_Documentation_1305 Document

      2. Then I compare it with DescribeEX CompoundEmployee Response to cross check whether every fields is present in XML or not, So whatever fields were missing, I added them manually in XML.

      3. Append/Add this XML Structure under the QueryResponse XML Payload and QueryMore Response XML Payload.

      4. And Now Genearted XSD on that final XML.

      Result : So Now XSD has all the field in it. So can be reused for any CompoundEmployee Entity Interface but Yes for Other Entities say USER we need to repeat this activity.

      2.Is it possible to make this generic enough for all queries, not just CompoundEmployee?

      Java Mapping

      Create by me is very Generic , It can be used for any Entity Query except ADHOC Reports.

      but I believe with availabilty of CompoundEmployee Entity we donot need Adhoc Reports anymore which actual was the idea behind releasing CompoundEmployee Entity in Market.

      We just need to pass the Select Query beat Compound Employee beat User or any other entity . It will return the Combined XML Response from( Query and QueryMore Opeartion with Status Field as “S”
      value )

      Even this Java Code will handles exceptions also if any exception raise in between it return Exception XML with Status as “E” ).

      3.Would you recommend this for update operations?  Using a mapping program
      might result in other type of problems

      Answer : I would Never Recommend Update operation through Java Mapping or Lookups .. I would Suggest Only Select operations through Java Mapping Lookups.

      4.Is it possible to include the complete code of your java mapping program?

      Answer : Yes. if required.

      Regards

      Prabhat Sharma

      Author's profile photo Former Member
      Former Member

      Thanks Prabhat.

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

      Thanks Stuart for appriciating.

      Author's profile photo Ruben Hernan Mircin Ramirez
      Ruben Hernan Mircin Ramirez

      Great post! I'm looking forward to learn about SAP Process Orchestration and this example has given me a great initial overview of the components that interact in a PI sceneario.

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

      Thanks Ruben Hernan Mircin Ramirez for appriciating doc !!!!!!!!

      Author's profile photo Former Member
      Former Member

      Brilliant blog Prabhat!Thanks for sharing this with us.Keep on blogging.

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

      Thank You @ Biplab Sir

      Author's profile photo Former Member
      Former Member

      Hi Prabhat,

      Good job with your blog. I have few questions -

      1. As you mentioned in your blog that you used SOAPConnectionFactory, I am very much interested in knowing how are you appending sessionID in http header for query and logout calls ?

      One of the option I tried was Lookup API but I think we cannot append HTTP headers while using Lookup API

      2. Could you elaborate on how are you handling queryMore in Java Mapping i.e. are you storing data temporarily in Map etc ?

      Again, thanks for your time and effort

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

      Hi Akhil,

      In response to your Query 1

      public

      static String QueryOperation(String SID)


                      {


      try


                         {


                              System.

      out.println("2. Inside Query Operation");


                              String Request_Query =

      "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sfobject.sfapi.successfactors.com\"><soapenv:Header/><soapenv:Body><urn:query><urn:queryString>"+Var_SelectQuery+"</urn:queryString><urn:param><urn:name>batchSize</urn:name><urn:value>500</urn:value></urn:param></urn:query></soapenv:Body></soapenv:Envelope>";


                              SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance();


                              SOAPConnection connection = soapConnFactory.createConnection();


                              MessageFactory messageFactory = MessageFactory.newInstance();


                              SOAPMessage Inmessage = messageFactory.createMessage();


                              MimeHeaders hd = Inmessage.getMimeHeaders();


                              hd.addHeader(

      "Cookie", "JSESSIONID="+SID);


                              SOAPPart soapPart             = Inmessage.getSOAPPart();


      byte[] buffer                 = Request_Query.getBytes();


                              ByteArrayInputStream stream   =

      new ByteArrayInputStream(buffer);


                              StreamSource source           =

      new StreamSource(stream);


                              soapPart.setContent(source);


      //SOAPMessage returnedSOAPMessage = connection.call(Inmessage, "https://salesdemo4.successfactors.com:443/sfapi/v1/soap");


                              SOAPMessage returnedSOAPMessage = connection.call(Inmessage,

      "https://api4.successfactors.com:443/sfapi/v1/soap");


                              ByteArrayOutputStream Out =

      new ByteArrayOutputStream();


                              returnedSOAPMessage.writeTo(Out);  


                              String strMsg =

      new String(Out.toByteArray());


                              strMsg = strMsg.replace(

      " xsi:nil=\"true\" ","");


                              strMsg =strMsg.replace(

      "<?xml version='1.0' encoding='UTF-8'?>","");


                              strMsg = strMsg.replace(

      " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"","");


                              strMsg = removeXmlStringNamespaceAndPreamble(strMsg);


      Var_Exception = strMsg.contains("error");


                             

      if (Var_Exception == false)


                              {


      String_Query = strMsg.trim();


                              }


      else


                              {


      String_Query = strMsg.trim();


                             

      ErrorCode = "Error";


                                 

      ErrorDesc = strMsg.trim();;                     


                              }


                         }


      catch (Exception e)


                         {


                         }


      return String_Query;

      Author's profile photo Former Member
      Former Member

      Thanks..

      Author's profile photo Former Member
      Former Member

      Hi Prabhat,

      Good Day!

      Nice work! Keep it up!

      Thank you so much for sharing!

      Have a nice day!

      Regards,

      Hari Suseelan

      Author's profile photo Arijit Das
      Arijit Das

      Hi Prabhat

      Thanks for sharing this blog. I have a ques.

      Requirement is -

      select fields from compound employee

      where last modified date ge cust_table-start date and

      last modified date le interface run time date (current date).

      SAP PO has has dynamic query for OData adapters. Refer to Note 2051137 - PI Successfactors adapter : Dynamic odata query and single synchronous sfapi query

      Eg - select fields from position (this is what you state in OData query path in the comms channel; this is static); and you have an advanced tab in comms channel where you mention dynamicquery and set it to true (this points to a XSD which has the keyword TOP, SKIP & FILTER in it).

      This gets the filter values passed from the BPM from another query (from a OData cust_table).

      So the whole query is - select fields from position filter field a = x field b = y etc. Field a field b are fields in position that are you passing values x and y in run time of the interface.

      SAP PO also has the advanced tab feature for SFAPI for dynamic query. Ques is how to use it? In the sense what the XSD will look like etc. How to pass values to the fields in the Where clause for SFAPI.

      Any ideas?

      Thanks

      Arijit

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

      Arijit,

      First Compound Employee is a SOAP API. Where as . $Filter, $top are all parameters for OData Query.

      So kindly check and try