Skip to Content

How to use response from request reply in next step in CPI

Hi Experts,

I have a requirement to fetch employee data from Employee Central and since our payroll system is S4 I need to fetch few fields from S4 based on the employee number which comes as a response from Employee central.

Please see the design below -

Here, I want to fetch the employee ID from the response from step 2 and then store and use send the SOAP request to S4 system and fetch the response and then merge it in the original message.

Can someone provide some hint on how to achieve this after step 2. How the flow should be achieve this.

Regards,

Akash

cpi1.png (12.0 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on Aug 04, 2020 at 07:05 PM

    Use XSLT to transform your data.

    <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    	<xsl:template match="/">  
    		<ZHTR_LEAVE_SAL_ADVANCE>
    			<I_PERNR>
    				<item>
    					<PERNR>
    						<xsl:value-of select="EmployeeTime/EmployeeTime/userId"/>
    					</PERNR>
    				</item>
    			</I_PERNR>
    		</ZHTR_LEAVE_SAL_ADVANCE>
    	</xsl:template>
    </xsl:stylesheet>
    
    Add a comment
    10|10000 characters needed characters exceeded

    • try below XSLT for multiple records:

      <?xml version="1.0" encoding="UTF-8"?>
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      	<xsl:template match="/">  
      	<xsl:for-each select="EmployeeTime/EmployeeTime">
      		<p2:ZHTR_LEAVE_SAL_ADVANCE xmlns:p2="urn:sap-com:document:sap:rfc:functions">	
      			<I_PERNR>
      				<item>
      					<PERNR>
      						<xsl:value-of select="userId"/>
      					</PERNR>
      				</item>
      			</I_PERNR>
      		</p2:ZHTR_LEAVE_SAL_ADVANCE>
      		</xsl:for-each>
      	</xsl:template>
      </xsl:stylesheet>
      
  • Posted on Jul 29, 2020 at 04:39 PM

    Hi Akash,

    In addition to content enricher you can also use property to save the body, and can use the value inside the property through out the iflow.

    When you want to use it again, you can map it again in the body.

    if you want to use XSLT to map data you can use multiple property values along with the body inside the XSLT's

    Regards,

    Yatan


    screenshot-1.jpg (43.8 kB)
    screenshot-1.jpg (43.8 kB)
    screenshot-2.jpg (19.0 kB)
    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Yatanveer Singh,

      Thank you for the reply.

      My requirement is to fetch userId from the response.

      Can you please help to understand how to get that from response payload.

      Response Payload:

      <EmployeeTime>
      	<EmployeeTime>
      		<approvalStatus>CANCELLED</approvalStatus>
      		<lastModifiedDateTime>2020-02-24T15:35:19.000</lastModifiedDateTime>
      		<externalCode>012c5fd9fbe74331a3b233c665155c47</externalCode>
      		<cust_SickLeaveReason/>
      		<deductionQuantity>1</deductionQuantity>
      		<endDate>2020-02-24T00:00:00.000</endDate>
      		<timeTypeNav>
      			<TimeType>
      				<externalCode>1016</externalCode>
      				<externalName_defaultValue>Annual Leave</externalName_defaultValue>
      			</TimeType>
      		</timeTypeNav>
      		<displayQuantity>1</displayQuantity>
      		<lastModifiedBy>100050</lastModifiedBy>
      		<quantityInDays>1</quantityInDays>
      		<createdDateTime>2020-02-24T15:34:53.000</createdDateTime>
      		<timeType>1016</timeType>
      		<workflowRequestId/>
      		<userId>100050</userId>
      		<createdBy>100050</createdBy>
      		<startDate>2020-02-24T00:00:00.000</startDate>
      		<originalQuantityInDays>1</originalQuantityInDays>
      	</EmployeeTime>
      

      Xpath for userId: EmployeeTime/EmployeeTime/userId

      After fetching userId I will use this is another SOAP request and fetch data from S4 system. Request structure below -

      <?xml version="1.0" encoding="utf-8"?>
      <ZHTR_LEAVE_SAL_ADVANCE>
      	<I_PERNR>
      		<item>
      			<PERNR>userId</PERNR>
      		</item>
      	</I_PERNR>
      </ZHTR_LEAVE_SAL_ADVANCE>

      Regards,

      Akash

  • Posted on Jul 29, 2020 at 03:52 PM

    Hi Akash Shrivastava,

    You could use Content enricher where user ID could be key post request reply Step you mentioned.

    reference:

    https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/8827f9feb94e4264aaf42ac1c6ce11b7.html

    hope this helps !

    thanks and regards,

    Praveen T

    Add a comment
    10|10000 characters needed characters exceeded