2

According to the documentation of the SAP Cloud SDK the quantity of a variable-size item in a bill of material needs to be recalculated after changing a field that affects this property (e.g. size1, size2, size3, formulaKey).

To do this the contents of quantityVariableSizeItem should be deleted. How can this be accomplished?

I tried several values to update an existing variable-size item using the MaterialBomItemRequestBuilder.update method (which results in a PATCH request):

const item = MaterialBomItem.builder()
    /*request fails with error message: Property 'QuantityVariableSizeItem' at offset '[...]' has invalid value '-Infinity'*/
    //.quantityVariableSizeItem(new BigNumber('-Infinity))
    /*request fails with error message: Property 'QuantityVariableSizeItem' at offset '[...]' has invalid value 'NaN'*/
    //.quantityVariableSizeItem(new BigNumber(NaN))
    /*TypeScript error before request is sent: Argument of type 'null' is not assignable to parameter of type 'Value'.*/
    //.quantityVariableSizeItem(null)
    /*TypeScript error before request is sent: Argument of type 'undefined' is not assignable to parameter of type 'Value'.*/
    //.quantityVariableSizeItem(undefined)
      .billOfMaterialItemNodeNumber(<value>)
      .billOfMaterial(<value>)
      .material(<value>)
      .billOfMaterialCategory(<value>)
      .billOfMaterialVariant(<value>)
      .billOfMaterialVersion(<value>)
      .headerChangeDocument(<value>)
      .plant(<value>)
      .build();
const result = await MaterialBomItem.requestBuilder()
        .update(item)
        .withCustomHeaders(<headers>)
        .execute(<destination>);
    

Thanks in advance,

ujj

2 Answers2

2

The type of the parameter passed to the method billOfMaterialItemNodeNumber() is BigNumber, which makes it hard to be undefined. We'll consider a proper fix for this use case.

For the time being, you can try to use the work around like below:

const item = MaterialBomItem.builder()
    // this is not possible
    //.quantityVariableSizeItem(undefined)
      .billOfMaterialItemNodeNumber(<value>)
      .billOfMaterial(<value>)
      .material(<value>)
      .billOfMaterialCategory(<value>)
      .billOfMaterialVariant(<value>)
      .billOfMaterialVersion(<value>)
      .headerChangeDocument(<value>)
      .plant(<value>)
      .build();
// work around
item.quantityVariableSizeItem = undefined;
const result = await MaterialBomItem.requestBuilder()
        .update(item)
        .withCustomHeaders(<headers>)
        .execute(<destination>);
Junjie Tang
  • 362
  • 1
  • 15
  • 1
    Thanks for the quick reply. I have tried the workaround but it did not work for me. It seems quantityVariableSizeItem is not added to the ODATA request payload at all if it has no value (null or undefined). –  Oct 02 '20 at 06:43
  • 1
    The fix is merged. We are going to release a new version and will let you know. – Junjie Tang Oct 02 '20 at 09:36
  • @ujj, the latest release is 1.30.0, which should solve your issue. – Junjie Tang Oct 13 '20 at 12:04
  • Thanks for the notification. It works with release 1.30.0 of @sap-cloud-sdk/core and @sap/cloud-sdk-vdm-bill-of-material-v2-service. Sorry for the late reply. –  Mar 01 '21 at 10:25
0

This is solved with release 1.30.0 of @sap-cloud-sdk/core and @sap/cloud-sdk-vdm-bill-of-material-v2-service.