cancel
Showing results for 
Search instead for 
Did you mean: 

Not a valid date in accord with the XML format for ABAP

mike_reader3
Active Participant
0 Kudos

All,

I have read seemingly every article about dates and GW services but still cannot solve this one.

I am attempting a POST with a deep insert (I don't think that is related but maybe), the payload is JSON and I am formatting the date like this:

"MyDate":"2015-02-08T00:00:00Z",


In SEGW the date is formatted as Edm.DateTimeOffset and typed as DATS with 0's for the Precision, Scale and Max Length and Nullable is checked.


The response I get back is:


Value 20150208000000 is not a valid date in accord with the XML format for ABAP


I have tried clearing the cache with:


/IWFND/CACHE_CLEANUP and

/IWBEP/CACHE_CLEANUP


Any ideas?


Thanks, Mike



Accepted Solutions (0)

Answers (1)

Answers (1)

AshwinDutt
Active Contributor
0 Kudos

Hello Mike,

Please check as below.

1. Use Edm.DateTimeOffset with 0's for the Precision, Scale and Max Length and Null-able is checked.

2. In ABAP Type editor maintain as below.

3. Generate run-time objects and clear /IWFND/CACHE_CLEANUP & /IWBEP/CACHE_CLEANUP

4. Send Date as below in milliseconds in the JSON payload

{

...

"MyDate":"/Date(1467164260445)/",

...

}

Where

Wed Jun 29 2016 07:07:40 GMT+0530 (Asia/Kolkata)

equals

1467164260445 milliseconds

Regards,

Ashwin

0 Kudos

Hi Ashwin,

               I believe if Mike puts the date as datetime'2015-02-08T00:00:00'  along with the abap datatype as timestamp it should also work. Let me know if my thinking is correct, I do not have much frontend experience hence I could be wrong.

Thanks

Arka

AshwinDutt
Active Contributor
0 Kudos

Hello Arkajeet,

Yes it works for all the below formats ->

"MyDate":" 2016-06-29T23:59:59Z"

"MyDate":" 2016-06-29T23:59:59"

"MyDate":"/Date(1467224999000)/"


Regards,

Ashwin

mike_reader3
Active Participant
0 Kudos

Ashwin,

Thanks for the reply, one question.

I am using a structure (not a custom one) that defines that entity and the date field is typed as DATS - so I cannot change it to TIMESTAMP.

I suppose I could add a custom date field that I could type as TIMESTAMP.

Is there a way I can use the existing field and make this work?

-Mike

AshwinDutt
Active Contributor
0 Kudos

Ok considering the existing type is DATS , then instead of Edm.DateTimeOffset use Edm.DateTime


Then pass date as below in the JSON payload. It should work. Please check.


"MyDate":"2015-02-08T00:00:00"

mike_reader3
Active Participant
0 Kudos

Ok that worked, so clearly I don't understand the difference between

Edm.DateTimeOffset and

Edm.DateTime


I thought the offset part was just to show timezone difference? Why would this work with DATS?


-Mike