ThBillOfMaterial
TheThBillOfMaterial
class extends a tree node with logic specific to ERP-style bill of materials processing.It supports cost aggregation, quantity scaling, production tracking, and hierarchical relationships between manufactured and raw items.
Each instance is linked to a
ThTreeNode
and provides calculation methods to interpret and traverse the BOM structure recursively.This class enables generation, display, and interaction with multilevel production structures within the UI and logic layers.
ThBillOfMaterial – Public Variables
Variable | Description |
---|---|
UniqueID: ThNumeric | Unique internal identifier for this BOM entry, used for tracking and linking. |
Inserted_By_End_User: Boolean | Indicates if this entry was manually added by a user instead of automatically generated. |
Catalogic_Number: String | ERP or catalog item number identifying the product or component. |
Product_Name: String | The descriptive name of the product or item. |
Unit_Of_Measure: String | The unit used to express quantities (e.g., 'pcs', 'kg'). |
Quantity_Per_Parent: Double | Quantity of this item required per single unit of its parent item in the BOM tree. |
TotalQuantity: Double | Total calculated quantity based on parent recursion and quantities. |
Width: Double | Physical width in millimeters. |
Height: Double | Physical height in millimeters. |
Depth: Double | Physical depth in millimeters. |
Weight: Double | Physical weight in kilograms. |
Integer_Unit_Quantity: Boolean | If True, quantity must be handled as whole units (no decimals allowed). |
Fix_Quantity: Boolean | If True, the total quantity is fixed and cannot be auto-adjusted by scaling (according to parent quantity). |
Tax_Free_Cost_Price: Double | Cost price excluding tax (net cost). |
Taxable_Cost_Price: Double | Cost price including applicable taxes. |
Cost_Currency: String | Currency in which the cost prices are defined (e.g., 'USD'). |
Tax_Free_Selling_Price: Double | Net selling price without tax. |
Taxable_Selling_Price: Double | Selling price including tax. |
Selling_Currency: String | Currency in which selling prices are expressed. |
Charge_For_Child_Nodes_Additions: Boolean | If True, additional costs from child nodes will be included in pricing calculations. |
Warranty_Period_In_Months: Double | Warranty duration for this item, expressed in months. |
Extra_Info: String | Optional free-text field for notes, tags, or metadata. |
Allow_To_Change_Width: String | Defines if and how width can be changed (often holds permission or rule names). |
Allow_To_Change_Height: String | Defines if and how height can be changed. |
Allow_To_Change_Depth: String | Defines if and how depth can be changed. |
Workflow_ID: Integer | ID of the associated production or approval workflow. |
Workflow_ID_2: Integer | Alternative or secondary workflow identifier. |
rt_Event_FieldModified: String | Runtime trigger name or flag used when a field is modified. |
Clear
Clears the BOM content for the current node, optionally removing product info and dynamic fields.Used to reset the structure or prepare for new data injection.
procedure Clear(ProductInfo, DynamicFields: Boolean);
Parameters
- ProductInfo: Boolean; If True, clears main product-related fields such as catalog number and dimensions.
- DynamicFields: Boolean; If True, clears runtime or user-defined fields like cost, price, and extra info.
Add_Child
Adds a new child node to the current BOM item using catalog number and dimensional data.function Add_Child(Catalogic_Number, Extra_Info: String; Quantity_PP, Width, Height, Depth: Double): Boolean;
Parameters
- Catalogic_Number: String; Catalogic number or code of the child item.
- Extra_Info: String; Optional notes or additional metadata for the child.
- Quantity_PP: Double; Quantity per parent — how many units of the child are needed per unit of this parent.
- Width: Double; Width of the child item in millimeters.
- Height: Double; Height of the child item in millimeters.
- Depth: Double; Depth of the child item in millimeters.
Return Value
Returns True if the child was successfully created and added to the current node.Returns False if the operation failed (e.g., duplicate or invalid parameters).
Alert
Displays or logs a message related to this BOM node, typically used for warnings or user notifications.procedure Alert(TextMessage: String);
Parameters
- TextMessage: String; The message text to be shown, logged, or dispatched.
Run_Phantom
Initializes or regenerates a special substructure for the given catalog number as a "phantom" BOM node.Used in scenarios where a child group is dynamically constructed on demand rather than from fixed records.
procedure Run_Phantom(Catalogic_Number: String);
Parameters
- Catalogic_Number: String; The part number for which the phantom node structure should be generated.
FieldsCount
Returns the total number of public fields exposed by the BOM for reporting, export, or UI rendering.This includes fixed and dynamic fields depending on implementation.
function FieldsCount: Word;
Return Value
Returns the number of exposed fields in this BOM item.Used for iterating over field names, values, or structures.
GetFieldObj
Retrieves a field object by index, representing a structured value in the BOM item.Used for advanced access to field metadata and runtime manipulation.
function GetFieldObj(Index: Word): ThBillOfMaterial_Field;
Parameters
- Index: Word; The zero-based index of the field to retrieve.
Return Value
Returns aThBillOfMaterial_Field
instance representing the requested field.-
ThBillOfMaterial_Field
TheThBillOfMaterial_Field
record defines a single dynamic or extended field within a BOM item.
It includes metadata for display, data type, user access, and optional value selection menu support.
Field Description Name: String
Internal name of the field, used for identification and serialization. Visual_Name: String
User-friendly label for display in UI components like grids or forms. Kind: ThtpKindType
Specifies the field’s data type or logical role (e.g., string, numeric, boolean)./td> Value: Variant
The current value stored in this field, supporting multiple types via Variant. Readonly: Boolean
If True, the field is locked from user editing in the interface. SelectFromMenuID: Integer
Optional ID used to link this field to a predefined selection menu. -
ThtpKindType
TheThtpKindType
enumeration defines the data type classification for aThBillOfMaterial_Field
.
Each value represents a distinct logical or formatting category used in UI, validation, and data processing.
Value Description StringType
Textual string value. IntegerType
Whole number value without decimals. RealType
Floating-point or decimal number. MoneyType
Numeric value representing a currency amount, often formatted with symbol and precision. BoolType
Boolean value — True or False. DateType
Date-only value without time component. DateTimeType
Full timestamp value including both date and time. ProtoType
Custom or prototype value; placeholder for extension or unknown type. HourType
Time or duration value, typically represented in hours or HH:MM format.
GetFieldName
Returns the internal name of the field at the specified index.This name is typically used for storage, scripting, or JSON exports.
function GetFieldName(Index: Word): String;
Parameters
- Index: Word; The index of the field whose internal name should be returned.
Return Value
Returns the internal (code-level) name of the specified field.GetFieldVisualName
Returns the user-friendly or translated name of the field at the specified index.This is used in grids, editors, or printed documents where readable labels are needed.
function GetFieldVisualName(Index: Word): String;
Parameters
- Index: Word; The index of the field whose visual name is requested.
Return Value
Returns the display name of the field, suitable for UI presentation.Get_Dynamic_Fields_As_Memo
Generates a formatted text block containing dynamic field values and their labels.Can optionally include empty fields and bold formatting for values.
function Get_Dynamic_Fields_As_Memo(IncludeEmptyFields, BoldValues: Boolean): String;
Parameters
- IncludeEmptyFields: Boolean; If True, even fields with no value will be listed in the output.
- BoldValues: Boolean; If True, values will be visually marked or formatted in bold (in supported views).
Return Value
Returns a multilineString
representing all dynamic fields and values, optionally styled.AddField
Adds a new dynamic field to the BOM item with metadata and an optional initial value.This allows custom fields to be defined per item, extending the standard structure.
procedure AddField(Name, Visual_Name: String; Kind: ThtpKindType; Readonly: Boolean; InitValue: Variant;
SelectFromMenuID: Integer);
Parameters
- Name: String; Internal identifier for the field.
- Visual_Name: String; User-facing label for display in forms or grids.
- Kind: ThtpKindType; Defines the type and format of the field.
- Readonly: Boolean; If True, the field will be locked for editing.
- InitValue: Variant; The initial value assigned to the field upon creation.
- SelectFromMenuID: Integer; Optional menu ID for selection-based fields.
RemoveField
Removes a dynamic field from the BOM item based on its internal name.This permanently deletes the field and its associated value from the current node.
procedure RemoveField(Name: String);
Parameters
- Name: String; Internal name of the field to remove.
Add_Child_From_ProtoType
Creates a new child BOM item based on a prototype definition stored at the specified index.Applies quantity and dimension values to the generated child node.
function Add_Child_From_ProtoType(Index: Word; Extra_Info: String; Quantity_PP, Width, Height, Depth: Double): Boolean;
Parameters
- Index: Word; The index of the prototype field definition to use.
- Extra_Info: String; Optional notes or metadata for the new child node.
- Quantity_PP: Double; Quantity per parent — how many units of this prototype are required.
- Width: Double; Width of the child in millimeters.
- Height: Double; Height of the child in millimeters.
- Depth: Double; Depth of the child in millimeters.
Return Value
Returns True if the child node was successfully created from the prototype.Returns False if the operation failed or the prototype index was invalid.
Refresh
Recalculates and updates internal values of the BOM item, including totals and derived fields.Used after modifying quantities, costs, or structure to ensure accurate state.
procedure Refresh;
String_Command
Executes a string-based operation on a field, supporting generic scripting or dynamic assignment logic.Used to apply expressions, commands, or assignments across fields at runtime.
procedure String_Command(Command, PropName, AssignTo: String);
Parameters
- Command: String; The action to perform (e.g., 'assign', 'copy', 'add').
- PropName: String; The name of the source field or property to use.
- AssignTo: String; The name of the destination field or property where the result will be applied.
Find_Node_By_UniqueID
Searches recursively within the current BOM structure for a node matching the specified UniqueID.function Find_Node_By_UniqueID(FindID: ThNumeric): ThTreeNode;
Parameters
- FindID: ThNumeric; The unique identifier of the target node to locate.
Return Value
Returns theThTreeNode
that matches the given ID, or nil
if not found.Copy_To_PropGrid
Copies all relevant field data from the BOM item into a visual property grid control.Used to populate editors or configuration UIs with current values.
procedure Copy_To_PropGrid(Target_HPropGrid: TSYE_Control; FieldTypes: String);
Parameters
- Target_HPropGrid: TSYE_Control; The property grid control to which the fields will be exported.
- FieldTypes: String; A filter or tag string used to limit which field types are copied (e.g., 'all', 'pricing').
Field
Provides dynamic access to field values by nameproperty Field[Name: String]: Variant;
Parameters
- Name: String; The internal field name to access.
Return Value
Returns or updates the value stored in the specified dynamic field.Supports both read and write operations.