0

We upgraded to cloud SDK to the following version which is causing weird behavior for the patch call. This looks to be bug in Cloud SDK as we see the different behavior between Post & Patch for the EDM DateTime. Could you please confirm if this a bug.

In the Odata service, the property definition is this

<Property Name="DeliveryDate" Type="Edm.DateTime" Precision="0" sap:display-format="Date" sap:label="Delivery date" sap:quickinfo="Item delivery date" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>

In the VDM, the same property is defined as

 @SerializedName("DeliveryDate")
    @JsonProperty("DeliveryDate")
    @Nullable
    @JsonSerialize(using = com.sap.cloud.sdk.s4hana.datamodel.odata.adapter.JacksonLocalDateTimeSerializer.class)
    @JsonDeserialize(using = com.sap.cloud.sdk.s4hana.datamodel.odata.adapter.JacksonLocalDateTimeDeserializer.class)
    @JsonAdapter(com.sap.cloud.sdk.s4hana.datamodel.odata.adapter.LocalDateTimeAdapter.class)
    @ODataField(odataName = "DeliveryDate", converter = com.sap.cloud.sdk.s4hana.datamodel.odata.adapter.LocalDateTimeCalendarConverter.class)
    private LocalDateTime deliveryDate;

Version: <cloud-sdk.version>3.34.0</cloud-sdk.version>

Is the OData Service a Version 2.0 ? Yes, OData 2.0(OdataV2)

Exact payload for both the cases ?

Payload and code invocation for Create:

{
        "Quantity": 2,
        "Price": 20,
        "UnitOfMeasure": "EA",      
        "DeliveryDate": "2020-03-23T07:16:23Z"    
}

code invocation

ItemCDSViewForGuidedBuying item = new ItemCDSViewForGuidedBuying();

// with some setter fields... 

item = s4ReqService.createItemCDSViewForGuidedBuying(item)
          .asChildOf(header, HeaderCDSForPRForGuidedBuying.TO_PURCHASEREQUISITIONITEM_WD)
          .withHeader(HttpHeaders.ACCEPT_LANGUAGE, requestContext.getAcceptLanguages())
          .executeRequest(getS4Destination())
          .getModifiedEntity(); 

Payload and code invocation for Update:

{
"DeliveryDate": "2020-09-18T07:16:23Z"        
}

code invocation

   ItemCDSViewForGuidedBuying item = new ItemCDSViewForGuidedBuying();
    
    // with some setter fields...
    
    s4ReqService.updateItemCDSViewForGuidedBuying(item)
              .modifyingEntity()
              .withHeader(HttpHeaders.ACCEPT_LANGUAGE, requestContext.getAcceptLanguages())
              .executeRequest(getS4Destination()); 

Please confirm whether or not the modules s4hana-all or s4hana-connectivity are part of your dependencies?

Yes, s4hana-connectivity is part of it along with following dependencies

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.sap.cloud.sdk</groupId>
            <artifactId>sdk-bom</artifactId>
            <version>3.34.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Few other dependencies in the POM.xml

<dependency>
    <groupId>com.sap.cloud.sdk.datamodel</groupId>
    <artifactId>odata-core</artifactId>
</dependency>
<dependency>
    <groupId>com.sap.cloud.sdk.s4hana</groupId>
    <artifactId>s4hana-connectivity</artifactId>
</dependency>

For Create entity call : Post Call ODataEntitySerializer.serializeEntityForCreate() when this is called, the Date field value goes as expected to the back-end something like this: 2020-08-18T07:16:23 and works as expected. Cloud SDK uses the following code to generate the request payload :

final JsonObject jsonObject = GSON.toJsonTree(entity).getAsJsonObject();

For Patch call: Does not work ODataEntitySerializer.serializeEntityForUpdatePatch() when this is called, the Date field value goes incorrectly. If we enable the gateway trace in the s4 system, we receive the payload like the below one which is incorrect in terms of OData Edm.DateTime.

"DeliveryDate":{"date":{"year":2020,"month":9,"day":18},"time":{"hour":7,"minute":16,"second":23,"nano":0}}

Cloud SDK uses the following code to generate the patch payload which is producing incorrect value :

final JsonObject o = Objects.requireNonNull((JsonObject) serializeComplexValue(patchValues, parentObjects));

Stacktrace:

owns: NioEndpoint$NioSocketWrapper  (id=14260)  
    ODataEntitySerializer$PatchSerializerHelper.toJson() line: 139  
    ODataEntitySerializer.serializeEntityForUpdatePatch(VdmEntity<?>, Collection<FieldReference>) line: 106 
    ItemCDSViewForGuidedBuyingUpdateFluentHelper(FluentHelperUpdate<FluentHelperT,EntityT>).getSerializedEntity() line: 421 
    ItemCDSViewForGuidedBuyingUpdateFluentHelper(FluentHelperUpdate<FluentHelperT,EntityT>).toRequest() line: 384   
    ItemCDSViewForGuidedBuyingUpdateFluentHelper(FluentHelperUpdate<FluentHelperT,EntityT>).executeRequest(HttpDestinationProperties) line: 372 
    S4RequisitionSourceImpl.updateReqLineItem(UUID, RequisitionItems) line: 239 
    

Let us know the resolution or workaround for the same.

  • Could you please edit your question to more clearly outline: Which code do you invoke exactly? Is the OData Service a Version 2.0 or 4.0 service? What is the exact exception that you see? What is the exact payload in the two cases you outline? – MatKuhr Dec 28 '20 at 14:40
  • Also please confirm whether or not the modules `s4hana-all` or `s4hana-connectivity` are part of your dependencies. – MatKuhr Dec 28 '20 at 14:43
  • Edited the question with more details as requested and outlined it more clearly. Please have a look. Let me know if you require any other details. – Surendra Gupta Jan 04 '21 at 09:33
  • All information given, thanks for the detailed explanation, that was quite helpful. – Emdee Jan 06 '21 at 09:07

1 Answers1

0

This seems to be a bug in the SAP Cloud SDK, we're investigating this issue.

SAP Cloud SDK 3.36.0 fixes this issue. Please update the Cloud SDK version in your application. Refer to the release notes for further reference.

Emdee
  • 1,689
  • 5
  • 22
  • 35