cancel
Showing results for 
Search instead for 
Did you mean: 

Help required on Datetime string conversion

Former Member
0 Kudos

Hello Experts,

I have a string with value '2010-07-16T07:30:00+03:00' which came from a webservice string data.Please advice how to declare variable in abap to get the correct date and time from this string?

From my previous exp, if I had the xml structure with this field as xsddatetime and in abap proxy, if I assign it to a char/string variable it used to do the calculation based on the timezone and give me the value as 20100716043000.

Please advice.

(I'm not sure if I had to post this in the ABAP forum, but thought the PI experts might have faced and solved this problem before)

Mat

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member208856
Active Contributor
0 Kudos

If you need to transform the same on PI system, use standard function Date --> DateTrans.

check the below link for standard functions :

http://help.sap.com/saphelp_nwpi711/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm

Former Member
0 Kudos

Hello Sandeep,

For other technical reasons, I'm doing the XML parsing in ABAP itself. So need to convert this date time in string format to the correct date and time fields by ABAP coding.

Mat

former_member208856
Active Contributor
0 Kudos

Hi,

Take help from this example code

ABAP Code example :

data : a(30) type c,

b(30) type c.

a = '2010-07-16T07:30:00+03:00'

concatenate a0(4) a5(2) a8(2) a11(2) a14(2) a17(2) into b.

Target value will be in variable b.

Former Member
0 Kudos

Thanks Sandeep for your time and effort, but the problem here is this wont consider the +3 timezone in below example.

Generally if you have a date time field in xml structure, while generating proxy ..it creates the field in abap with XSDDATETIME_Z dataelement and automatically converts to the correct date time.(below ex date = '2010-07-16' time = 04:30:00'

If I offset and do the math myself, I have to handle various cases like different time zones as well as time closer to midnights( then the date has to be changed too ).

I was hoping for a straight forward way of declaring it and getting the values.

Thanks again.

Mat

vijay_kumar133
Active Participant
0 Kudos

Hi Joseph,

Approach1.

Use datetransform standard function and create two different char variables for date and time and do mapping accorindly ..

Approach2.

create one string variable and do coding for string handeling in the proxy class.

Regards

Vijay G

Former Member
0 Kudos

Thanks for your reply

Approach 1 : The entire XML payload is coming in a string and I'm doing the XML parsing in ABAP.So this is ruled out.

Approach 2 : This is what I'm trying to do , I have the value 2010-07-16T07:30:00+03:00 in a string, but unsure about how to proceed.How do I convert this to date and time taking care of the timezone considerations.

Mat