cancel
Showing results for 
Search instead for 
Did you mean: 

UDF Mapping DATUM-TIMESTAMP, SAP PI 7.3.1

Former Member
0 Kudos

Hi Gurus/Experts

The date format for DATUM is 20130424--- And I want to Split it. Please see the E.g Below

Date coming in like this "20130424" which should be "2013-04-24T15:36:28 -05:00" 15:36:28 is the time and -05:00 is constant.

I tried all, but this can only be done in UDF, I tried the threads and codes but nothing worked, Please suggest a code for this UDF.

This is the code I'm trying-

DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create("DATUM")

String SourceFileName = "C1." + a + ".C2";

conf.put(key, SourceFileName);

return " ";

Thanks in Advance!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Vaibhav,

You can simply achieve your requirement using dateTrans inbuild fn .No need to any udf

select Input date format as yyyyMMdd and o/p date format as yyyy-MM-dd .Do the same for time as well if you require.

Regards

Venkat

Former Member
0 Kudos

Hi ,

General error handling standard we follow for date transformations is opening error segment (ZBAPIRET) and passing error message and failing the IDoc at SAP end.This we can achieve by writing small udf.

Ex:Invalid input date format..etc

Regards

Venkat

Answers (2)

Answers (2)

manigram
Active Participant
0 Kudos

HI your input value contains only date, but in your output you want the time also, what time do u want to keep either current system time or any constant time value you want to keep.

clarify your requirement

regards,

Manigandan

Former Member
0 Kudos

Hi Manigandan,

I'm sorry for not making it clear but  "DATUM" sends the Time Stamp along with the date as well. So we want to make it current system time...

Thanks

former_member184789
Active Contributor
0 Kudos

Hi,

You can try with simple date format class. Here is an example which I used some time ago:

DateFormat dateFormat = new SimpleDateFormat(""yyyy-MM-dd'T'HH:mm:ss.SSSZ"");

           newFilename = oldFilename+"_"+dateFormat;

           conf.put(key, newFilename);

In this one I had added the time stamp in the above format to the file name. You can modify it as per your requirement. Refer to the below link:

http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html

Former Member
0 Kudos

Hi Adrash,

After writing the UDF as suggested by you- this is the error I'm getting!