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

There are 2 answers

0
AudioBubble On BEST ANSWER

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

4
Junjie Tang On

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>);