0

Using the SAP B1 .edmx with 3.39.0 and trying to update DeliveryNotes with new DocumentPackages. However, the list of DocumentPackage that eventually gets passed by the execution of the update operation is empty.

Code:

var packagesUpdateDocument = new Document();

packagesUpdateDocument.setDocEntry(1);

var documentPackages = new ArrayList<DocumentPackage>();
var documentPackage = new DocumentPackage();

documentPackage.setNumber(10);

documentPackages.add(documentPackage);

packagesUpdateDocument.setDocumentPackages(documentPackages);


var updateDeliveryPackagesRequest = service.withServicePath("etc")
                    .updateDeliveryNotes(packagesUpdateDocument);

var updateDeliveryPackagesResponse = updateDeliveryPackagesRequest.tryExecute(serviceLayerDestination);

Looking at the logs of the service layer I can see this is the request which was eventually sent by the client:

PATCH /b1s/v2/DeliveryNotes(1)

{"DocEntry":1,"DocumentPackages":[{}],"@odata.type":"SAPB1.Document"}

From my understanding, PATCH requests will automatically disregard anything the generated client deems as 'unchanged.'

Printing the changed fields:

System.out.println(packagesUpdateDocument.getChangedFields());

Yields:

{
  DocEntry=175017, 
  DocumentPackages=
    [DocumentPackage
      ( 
        super=VdmObject(customFields={}, 
        changedOriginalFields={}), 
        odataType=SAPB1.DocumentPackage, 
        number=10, 
      )
    ]
  .....
}

I believe the Package is not recording the fields which have changed. Although I am not certain.

Is there a step I am missing or is this a feature gap?

Conner
  • 17
  • 5

2 Answers2

0

Yes this is a feature gap currently. PATCH will only consider properties of the root entity and navigation properties while disregarding changes in complex properties.

Until that is supported updating with PUT instead via the .replacingEntity() option should work.

MatKuhr
  • 505
  • 4
  • 13
  • Unfortunately the PUT operation isn't totally workable in this scenario as Document has hundreds of fields that cannot be updated, causing errors if you issue a PUT request. – Conner Mar 18 '21 at 16:46
  • I was able to use the generic client to make the request, so I think we should be okay for now. – Conner Mar 18 '21 at 18:44
  • Yeah that would have been my next suggestion. I'll update here once the SDK supports it natively. – MatKuhr Mar 18 '21 at 21:50
0

As of SAP Cloud SDK 3.42.0 we support updating complex properties with PATCH out-of-the-box. See the release notes for more details.

Emdee
  • 1,689
  • 5
  • 22
  • 35