Skip to Content

Mapping Logic to get the yesterday record only using HCI

Dear Experts,

i have requirement where we are integrating the multiple clock in and clock outs from success factors using Hana Cloud integration as a middle ware.Here my query is i need to get the records for yesterday only. i dont want the previous records. please. For example todays date is 27/07/2017 i need only 26/07/2017 date records.Please suggest me on this

For reference i have attached the screen shot of mapping

last-modified-data.jpg

Regards

Giridhar Vegi.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

11 Answers

  • Best Answer
    Oct 03, 2017 at 06:20 AM

    Hello Giridhar,

    Find the below details it migh help you to resolve your issue.

    Input Data:

    <Root>
    	<Record>
    		<D1>03/10/2017</D1>
    		<F1>KK1</F1>
    		<F2>PP1</F2>
    		<F3>TT1</F3>
    	</Record>
    	<Record>
    		<D1>02/10/2017</D1>
    		<F1>KK2</F1>
    		<F2>PP2</F2>
    		<F3>TT2</F3>
    	</Record>
    	<Record>
    		<D1>02/10/2017</D1>
    		<F1>KK3</F1>
    		<F2>PP3</F2>
    		<F3>TT3</F3>
    	</Record>
    </Root>
    

    Mapping Details:

    Output Data:

    <?xml version="1.0" encoding="UTF-8"?>
    <Root>
    	<Item>
    		<O1>02/10/2017</O1>
    		<O2>KK2</O2>
    		<O3>PP2_TT2</O3>
    	</Item>
    	<Item>
    		<O1>02/10/2017</O1>
    		<O2>KK3</O2>
    		<O3>PP3_TT3</O3>
    	</Item>
    </Root>

    Regards,

    Sriprasad Shivaram Bhat

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 28, 2017 at 10:17 AM

    Hello Giridhar,

    I am assuming you want to filter out records at mapping level and to achieve the same create a Custom Function & map it to record level to send only yesterdays data.

    Mapping Snapshot:

    Custom Function:

    import com.sap.it.api.mapping.*;
    import java.util.HashMap;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    
    
    //Add MappingContext as an additional argument to read or set Headers and properties.
    
    
    def String customFunc(String arg1){
       
       Calendar cal = Calendar.getInstance();
       DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
       cal.add(Calendar.DATE, -1);
       
       def y_date=dateFormat.format(cal.getTime())
       y_date=y_date.toString()
       
       if ( arg1 == y_date)
         return "true"
       else
    	 return "false"
    }
    
    
    

    Regards,

    Sriprasad Shivaram Bhat

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 01, 2017 at 06:16 AM

    Hello Giridhar,

    Could you please share input XML payload to mapping and expected output payload.

    Regards,

    Sriprasad Shivaram Bhat

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 30, 2017 at 12:37 PM

    Dear Sriprasad,

    Thanks for providing the solution with the Custom Function. Do i need to pass any date field for D1 as per the screenshot which you have provided or can i pass the header element?

    Regards

    Giridhar Vegi.

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 30, 2017 at 02:00 PM

    Dear Prasad,

    i have mapped as you said . but i am not getting any records after mapping.

    records-maintained-in-sf.jpg

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 30, 2017 at 03:00 PM

    Hello Giridhar,

    You have to pass the date( dd//mm/yyyy format ) to custom function.

    Regards,

    Sriprasad Shivaram Bhat

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 01, 2017 at 04:45 AM

    Dear prasad ,

    i have tried as you said but i am getting only one record i.e. only clock in record for a single date.i am not getting all records for a single date.

    Regards

    Giridhar Vegi.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 20, 2017 at 05:38 AM

    Hello Sriprasadh,

    In custom function do we have to write java code here for this requriment.

    Regards

    Sanjay

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 12 at 01:27 PM

    Hi SriPrasad,

    How to check the date not equal to null condition for transferring the date format(From yyyy-MM-dd to dd-MM-yyyy or any other). I am using standard functionality like stringequals and NOT with ifs-else; but i am getting error like:

    Error Details com.sap.xi.mapping.camel.XiMappingException: com.sap.aii.mappingtool.tf7.MessageMappingException: Runtime exception during processing target field mapping /Data_Target/DateOfHire. The root message is: Unparseable date: "false", cause: java.text.ParseException: Unparseable date: "false" Please give me some input on this. Even i tried using XSLT. That time i am getting the below error:Error Details ValidationException: Invalid dateTime value "04/01/1994" (Non-numeric year component)<DateOfHire> <xsl:if test="DateOfHire!=''"><xsl:value-of select="format-dateTime(DateOfHire,'[D01]/[M01]/[Y0001]')"/></xsl:if> </DateOfHire>
    Add comment
    10|10000 characters needed characters exceeded

  • Mar 12 at 01:27 PM

    Hi SriPrasad,

    How to check the date not equal to null condition for transferring the date format(From yyyy-MM-dd to dd-MM-yyyy or any other). I am using standard functionality like stringequals and NOT with ifs-else; but i am getting error like:

    Error Details com.sap.xi.mapping.camel.XiMappingException: com.sap.aii.mappingtool.tf7.MessageMappingException: Runtime exception during processing target field mapping /Data_Target/DateOfHire. The root message is: Unparseable date: "false", cause: java.text.ParseException: Unparseable date: "false" Please give me some input on this. Even i tried using XSLT. That time i am getting the below error:Error Details ValidationException: Invalid dateTime value "04/01/1994" (Non-numeric year component)<DateOfHire> <xsl:if test="DateOfHire!=''"><xsl:value-of select="format-dateTime(DateOfHire,'[D01]/[M01]/[Y0001]')"/></xsl:if> </DateOfHire>
    Add comment
    10|10000 characters needed characters exceeded