Skip to main content

system.mes.productionOrder.saveBillOfMaterialsItem

Description

Creates or updates a Production Order Bill of Materials record in the system based on the provided parameters.

Syntax

system.mes.productionOrder.saveBillOfMaterialsItem(**bill_of_materials_data)

Parameters

ParameterTypeNullableDescription
productIdString (ULID)FalseThe ULID for the material produce to be produced.
productionOrderIdString (ULID)FalseThe ULID for the production order associated with this bill of materials.
materialNameStringTrueThe name of the material that is a component of the produce.
materialIdString (ULID)FalseThe ULID of the material that is a component of the produce.
quantityPerProducedUnitDoubleFalseThe quantity of the material used per unit produced of the product.
quantityOrderDoubleFalseThe quantity of the material used per order.
unitOfMeasureIdString (ULID)FalseThe ULID of the unit of measure for this bill of materials.
unitOfMeasureNameStringTrueThe name of the unit of measure for this bill of materials.
positionIntegerFalseThe position of this bill of materials for the product. Default value is 0
materialGroupStringFalseThe material group of the material associated with this bill of materials.
materialTypeStringFalseThe material type of the material associated with this bill of materials. Default value is PRODUCT
idString (ULID)TrueThe ULID of the bill of materials (optional, used for updating an existing bill of materials).
notesStringTrueNotes related to the bill of materials.
enabledBooleanTrueIndicates if the bill of materials is active and enabled. Default value is true
spare1StringTrueAdditional field for user-defined context.
spare2StringTrueAdditional field for user-defined context.
spare3StringTrueAdditional field for user-defined context.

Returns

Returns a JSON representation of the saved bill of materials.

Code Examples

# Generate the object structure for a new bill of materials object, set the initial arguments and save it
new_bill_of_materials = system.mes.productionOrder.newBillOfMaterialsItem()
new_bill_of_materials['quantityOrder'] = 1000.0
new_bill_of_materials['materialGroup'] = 'CAN'
new_bill_of_materials['unitOfMeasureId'] = '01JCH3EPVP-1MNNDJTS-37Z75NGB'
new_bill_of_materials['materialId'] = '01JCH3ENGW-82KJDZDR-JHGYCXQN'
new_bill_of_materials['quantityPerProducedUnit'] = 10.0
saved_bill_of_materials = system.mes.productionOrder.saveBillOfMaterialsItem(**new_bill_of_materials)

# Output the JSON representation of the saved bill of materials
print(saved_bill_of_materials)

# Generate the object structure for another new bill of materials to update the previous bill of materials
bill_of_materials_data = system.mes.productionOrder.newBillOfMaterialsItem()

# Set basic attributes for the updated bill of materials
bill_of_materials_data['id'] = saved_bill_of_materials.id
bill_of_materials_data['quantityOrder'] = 1000.0
bill_of_materials_data['materialGroup'] = 'CAN'
bill_of_materials_data['unitOfMeasureId'] = '01JCH3EPVP-1MNNDJTS-37Z75NGB'
bill_of_materials_data['materialId'] = '01JCH3ENGW-82KJDZDR-JHGYCXQN'
bill_of_materials_data['quantityPerProducedUnit'] = 10.0
bill_of_materials_data['position'] = 1
# (You can continue setting other properties as needed here)

# Save the bill of materials to update it in the system
updated_bill_of_materials = system.mes.productionOrder.saveBillOfMaterialsItem(**bill_of_materials_data)

# Output the JSON representation of the updated bill of materials
print(updated_bill_of_materials)