Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update requests send no longer all fields to the SAP S/4HANA system

Since the update to the Cloud SDK version 2.0.0 we now have problems to add fields to the request. It is mainly about the process step "Count Physical Inventory Document Item". Here the manually set properties for the items are not sent into the request.

These are the properties we actually set and send to S/4 System:

Java Coding

These are the properties that are embedded in the query:

Request in S4

like image 938
N.Kryl Avatar asked May 30 '18 07:05

N.Kryl


1 Answers

Quick answer

Call the method includingFields(PhysInventoryDocItem.MATERIAL, ...) on the update fluent helper.

Longer explanation

Version 1.11.1 of the SAP S/4HANA Cloud SDK slightly changed the behavior of the Java Virtual Data Model (VDM) during update requests. The release notes state:

Update requests with the Java Virtual Data Model (VDM) no longer send all non-null fields to the SAP S/4HANA system, but only changed fields. You may need to adapt the logic in your code to explicitly change fields by using the setters of the entity classes, or use the includingFields method to manually specify fields to include.

So in your case, by default only fields will be sent that have a different value compared to the result returned by the get-by-key OData request, as typically expected for PATCH requests. For example, the value of the field material likely didn't change, because it was "MAT_KONSI_APP1" before.

Because there are cases that require some mandatory fields to be always sent, the SAP S/4HANA Cloud SDK allows you to control which fields to always send. Use the includingFields method on the update fluent helper of the VDM to specify the fields that shall be sent in any case, also if their value has not changed.

In your case, if you want to send the material and unit of entry fields, which may be mandatory properties, you need the following code:

service.updatePhysInventoryDocItem(itemToUpdate)
    .includingFields(PhysInventoryDocItem.MATERIAL,
                     PhysInventoryDocItem.UNIT_OF_ENTRY)
    .execute()
like image 187
Henning Heitkötter Avatar answered Jan 02 '23 10:01

Henning Heitkötter