Developing ERP to SIMATIC BATCH Interfaces: Creating Formulas via the SIMATIC BATCH API

Developing ERP to SIMATIC BATCH Interfaces: Creating Formulas via the SIMATIC BATCH API

In SIMATIC BATCH V8.1 and higher, automating formula creation from an ERP or MES system is achieved using the SIMATIC BATCH COM/REST API interface. To create a formula programmatically passing materials, quantities, and parameter values, initialize an API session with ISB_API::Login, retrieve the target Master Recipe object (ISB_Recipe), call ISB_Recipe::CreateFormula, populate the formula category and parameter value collection, and commit the changes using ISB_Recipe::Save.

Table of Contents

Architecture of the SIMATIC BATCH API for ERP/MES Integration

In ISA-88 compliant batch processing facilities operating SIMATIC PCS 7, the SIMATIC BATCH system manages master recipes, formulas, production orders, and electronic batch records (EBR). In enterprise production environments, formulation data originates from an Enterprise Resource Planning (ERP, e.g., SAP S/4HANA) or Manufacturing Execution System (MES).

To eliminate manual data entry and human formulation errors, SIMATIC BATCH provides an open programmatic interface: the SIMATIC BATCH API (historically exposed via Component Object Model - COM interfaces, and in modern versions via .NET assemblies and REST web services).

The relationship between Master Recipes and Formulas in SIMATIC BATCH follows a structured hierarchy:
1. Master Recipe (MR): Defines the procedural control logic (recipe header, unit procedures, operations, phases, and transitions).
2. Formula Category: Defines the data schema (the template of required materials, input ingredients, setpoint parameters, and process limits).
3. Formula: A concrete instance containing specific numerical setpoints and material quantities (e.g., Product A - 500 kg Batch, with specific chemical ratios).

Using the API function ISB_Recipe::CreateFormula (or ISB_API::CreateFormula), external software connectors can dynamically generate, parameterize, and release new production formulas directly into the BATCH server database.

BATCH API Interface and Formula Data Model Matrix

Review the core interfaces and methods utilized in SIMATIC BATCH ERP formulation connectors:

COM Interface / ClassKey MethodsSystem FunctionPurpose in ERP IntegrationISB_API / SB_APIClassLogin(), Logout(), GetProject()Main API entry point and authenticationEstablishes secure connection to BATCH ServerISB_ProjectGetRecipes(), GetMaterials()Accesses plant recipe and material catalogsRetrieves master data for parameter validationISB_RecipeCreateFormula(), GetFormulas(), Save()Manages recipe-level objects and formulasContainer for formula creation and persistenceISB_FormulaSetParamValue(), SetMaterial(), Release()Represents an individual formula instanceAssigns material weights, temperatures, and statesISB_MaterialGetQuantity(), SetQuantity()Encapsulates material code and unit of measureMaps ERP material codes (e.g., SAP Material Number)

Licensing notice: Utilizing the SIMATIC BATCH API requires the 'SIMATIC BATCH API' engineering/runtime software license.

Step-by-Step Implementation: Creating Formulas via C# / .NET COM API

Follow this verified programming workflow to instantiate and populate a formula using C#:

  1. Add COM References to Visual Studio Project:
    * Add reference to the SIMATIC BATCH API Type Library:
    Siemens.SimaticBatch.API.dll (located in C:\Program Files (x86)\Siemens\BATCH\bin).
  2. Authenticate and Open Project Session:
    ```csharp
    using Siemens.SimaticBatch.API;

SB_API batchApi = new SB_APIClass();
int result = batchApi.Login("BATCH_SRV", "ERP_Connector", "Password123", "Plant_Project");
if (result != 0) throw new Exception("Failed to login to SIMATIC BATCH API: " + result);

ISB_Project project = batchApi.GetProject();
3. **Retrieve Recipe and Invoke `CreateFormula`**:csharp
// Locate target Master Recipe by Name
ISB_Recipe recipe = project.GetRecipeByName("MasterRecipe_Polymer_A");

// Create a new formula instance under the recipe
string formulaName = "ERP_Formula_Lot_2026_01";
string categoryName = "Standard_Chemical_Category";
ISB_Formula formula = recipe.CreateFormula(formulaName, categoryName);

// Set parameters: Temperature setpoint, Mix duration
formula.SetParameterValue("Reaction_Temp", 75.5); // Target in deg C
formula.SetParameterValue("Agitator_Speed", 450.0); // Target in RPM

// Assign materials and quantities
formula.SetMaterialQuantity("MAT_SOLVENT_01", 350.0, "kg");
formula.SetMaterialQuantity("MAT_CATALYST_B", 12.5, "kg");

// Save and release formula
recipe.Save();
formula.Release();
batchApi.Logout();
```

Handling Material Quantities, Parameter Validation, and Recipe Release

To ensure high availability and robust data exchange between ERP and PCS 7:
1. Validate Material Codes and Units: Before calling SetMaterialQuantity, query project.GetMaterials() to verify that the ERP material code exists in the SIMATIC BATCH material library and units of measure (kg, L, g) match exactly. Mismatched units trigger API error 0x8004xxxx.
2. Enforce Engineering Parameter Limits: In the Master Recipe, parameters feature High and Low warning/abort limits. The API returns an error if the ERP setpoint falls outside recipe bounds. Always catch exceptions and return detailed validation logs back to ERP.
3. Formula Release State: A formula created via API is initially in state Draft / In Work. Calling formula.Release() validates formula consistency and flags it as Released for Production, allowing the BATCH Control Center (BCC) to instantiate batches immediately.

Verification

Verify automated formula generation in SIMATIC BATCH:
1. Execute the custom C# connector script.
2. Open the SIMATIC BATCH Control Center (BCC) on the batch server.
3. In the navigation tree, expand Master Recipes > MasterRecipe_Polymer_A > Formulas.
4. Confirm that ERP_Formula_Lot_2026_01 appears in the list with state Released.
5. Open formula properties: Verify that material quantities (350.0 kg, 12.5 kg) and process setpoints (75.5 °C, 450 RPM) match ERP database records exactly.
6. Create a test batch using the formula: Confirm that batch creation succeeds without validation warnings.

Limitations and Operational Precautions

  • Never call CreateFormula concurrently from multiple asynchronous threads without database locking; concurrent API writes to the same Master Recipe can cause SQL deadlocks on the BATCH server.
  • Releasing formulas via API bypasses manual operator approval; ensure the ERP connector enforces digital signature compliance (FDA 21 CFR Part 11) where required by regulatory standards.
  • The SIMATIC BATCH API must communicate over a secure, isolated network; never expose the API COM port or REST endpoint directly to public business subnets without industrial DMZ firewall protection.

Engineer FAQ

Does SIMATIC BATCH provide sample code for the API?

Yes. Siemens publishes official Application Example 92344632 containing a complete C# sample project demonstrating batch creation, formula generation, and material management.

Can formulas be created while a batch is actively running on the recipe?

Yes. Formulas are data parameter sets; creating or modifying a formula does not alter active batches running on previously generated control recipes.

What license is required to use the SIMATIC BATCH API?

Using the API requires the 'SIMATIC BATCH API' license installed on the SIMATIC BATCH Server via Automation License Manager (ALM).

Technical References

Related Articles

Related Tags

  • SIMATIC BATCH
  • BATCH API
  • CreateFormula
  • ERP Integration
  • ISA-88
  • C# .NET
  • Recipe Management
  • PCS 7 Batch
6 respuestas