There is a very common problem, that while doing a post request or any kind of update containing empty dates are not allowed by default via SEGW based OData-Services.

How to enable this is described here: DateTime field in OData entity – Points to take care when the UI is throwing run-time error. | SAP Blogs

Problem:

But maybe you struggle here anyway, even when using the workaround as described before – but why? Take a look here at the column DEL_DATE:

CDS%20Preview%20on%20TOA01

It looks fine in the ADT Data-Preview, even if 0000-00-00 is not a very nice date.

But testing the OData-Service based on this CDS View returns an error “the Value ____ is no valid Date according to XML-formats for ABAP”:

Error%20in%20/IWFND/ERROR_LOG

Error in /IWFND/ERROR_LOG

Rescue from the past – thank you SE16:

The solution can be found via our old tooling like the good, old SE16 – here we see the true value of DEL_DATE:

The field does not contain any value – its empty, space or even null, but not 0000-00-00 as shown in ADT! And “space” or “empty string” can’t be interpreted as a date! How to fix it? Simply extend your CDS with an easy CASE-Statement, that sets a value OData can handle – like the one mistakenly shown in ADT:

define view entity ZABC
  as select from toa01
{
  key sap_object                 as SapObject,
      @UI.hidden: true
  key object_id                  as ObjectId,
      @EndUserText.label: 'Content Repository'
  key archiv_id                  as ArchivId,
  key arc_doc_id                 as ArcDocId,

      case del_date
      when '' then '00000000'
      else del_date end          as DelDate
}

This should normally not be necessary and is clearly due to a program error, but still: some kind of solution.

Enjoy!

 

Sara Sampaio

Sara Sampaio

Author Since: March 10, 2022

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x