cancel
Showing results for 
Search instead for 
Did you mean: 

Date Conversion technique in sap PI 7.1

Former Member
0 Kudos

HI Experts,

I have the requirement where DATAB and DATBI field values comes in the below format.

<DATAB>12-feb-2014 00:00:00</DATAB>

  <DATBI>28-feb-2015 14:00:00</DATBI>

But the SAP system is expecting in the format yyyy.mm.dd


Please advice how to achieve this.


Thanks,

Prathap.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Prathap,

please use this, it will resolve your problem

Thanks,

Prasad Venkata K.

former_member192343
Active Contributor
0 Kudos

Hi, example of solution

Regrads,

Mikhail

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Mikhail,

Without the timestamp it would also work

Regards,

Mark

former_member192343
Active Contributor
0 Kudos

Hi Mark, maybe there is a requirement to change delimiters in time.

Regards,

Mikhail

former_member190624
Active Contributor
0 Kudos

Hi Prathap,

It's very simple with Date transformation function (but you have to manually give input format i.e. "dd-MMM-yy" in  input Date Format parameter ,instead of selecting from drop down). Configure your DateTrans function as shown in below figure.

Thanks

Hari.

Former Member
0 Kudos

But before using the DateTrans function, you'll need to use the subString to ensure that you provide the DateTrans function with the first 11 chars of the date field.

Former Member
0 Kudos

Hi Prathap,

Try this UDF:

import following in the import tab of udf:

java.text.SimpleDateFormat;

java.util.Date;

Sample code:

public String TransDate(String sDate, Container container) throws StreamTransformationException{

   

        Date date;

        SimpleDateFormat sdfSource  = new SimpleDateFormat("dd-MMM-yyyy");

        SimpleDateFormat sdfDestination = new SimpleDateFormat("yyyy.MM.dd");

       

        try{

        date =  sdfSource.parse(sDate);

        String TDate= sdfDestination.format(date);

       

             }catch(Exception e){

         }

        return TDate; 

    }

iaki_vila
Active Contributor
0 Kudos

Hi Prathap,

Use DateTrans function, you have a lot of examples in SCN.

Regards.