Skip to Content
0

HCI : Conversion of Date Format in Hana Cloud Integration

May 23, 2017 at 10:34 AM

594

avatar image

Dear Experts ,

i have a requirement where i need to convert the date format .for example the input format is 23.05.2017 where as expected format is 2017-05-23T00:00:00.000 . i am using the hana cloud integration as a middleware .Please provide the udf to achieve this requirement.

Regards

Giridhar Vegi.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Sriprasad Shivaram Bhat May 23, 2017 at 11:27 AM
0

Hello Giridhar,

Below UDF will do the same.

import com.sap.it.api.mapping.*;
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){
    
    Date inputDate_parsed=new SimpleDateFormat("dd.MM.yyyy").parse(arg1);  

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

    def converted_datetime=dateFormat_required.format(inputDate_parsed);
    
    return converted_datetime;
}

Regards,

Sriprasad Shivaram Bhat

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Sriprasad,

I have a requirement to convert current date time value from UTC to other timezone in SAP CPI-PI.

Actually I am using below date now function to get the current date time.

${date:now:dd-MM-yyyy HH:mm z}

But by default I am getting value in UTC timezone.

I am expecting date time value in EET timezone.

Can this be achieved using groovy script.?

Regards,

Deva

0
Santosh Giridhar vegi May 24, 2017 at 05:31 AM
0

Dear prasad,

Thanks alot for your support. but i am getting the error as attached in the screenshot. please suggest me on this.svkm-unparsable-error.jpg if i have given single record.if i have given multiple records i am getting the error as follows.

java.lang.ClassCastException: Cannot cast class java.util.ArrayList to class java.util.HashMap

For reference i am attaching the following input file that needs to be mapped.attandance.jpg .

Also i am getting the following error

com.sap.gateway.core.ip.component.odata.exception.OsciException: Request Payload: Either the OData metadata content available in the server is outdated or the request payload seems to be incorrect = https://api8preview.sapsf.com/odata/v2_defaultTenant_shrivilepaT with error => Cannot convert 20170523 000000.000 to java.util.Calendar

please suggest me on this.

Regards

Giridhar Vegi.


Show 3 Share
10 |10000 characters needed characters left characters exceeded

Giridhar,

I have tested,It works perfectly fine with single value.I am not sure from where you are getting this "java.util.ArrayList to class java.util.HashMap". Have you changed anything to script or what is the input you are passing to that field[ Is it single field or list of values ]

Also please let me know you are using above code as Custom Function [ In SAP PI terminology UDF ] in Graphical Message Mapping?

Regards,

Sriprasad Shivaram Bhat

0
Former Member

Hello Giridhar,

Currently we are facing same issue "java.lang.ClassCastException: Cannot cast class java.util.ArrayList to class java.util.HashMap."

when we are passing multiple values but the message is successful when there is only one message. Could you please let us know how the issue was fixed so that it could be helpful for us.

Thanks & Regards

Vijay S B

0

hello Vijay,

If you want to pass list of values ( queue ) to Custom Function then follow the below post.

https://answers.sap.com/questions/186497/udf-in-hci.html

Regards,

Sriprasad Shivaram Bhat

0