Task 2: Create the Insert action
In this task, you will create an Insert action and define joins between the orders_full, location_dimension tables and the recipe sites keys and recipe Products key tables generated from your model recipe. You will then create statements to map DDM data into the AggregateProductionConstraints in your model.
-
Access Macros on the Supply Chain landing page.
-
In the Layout Designer, click New..., then select Project.
-
Optionally, edit the project Name and click OK.
-
With the project selected, click New..., then select Macro.
-
Optionally, edit the macro Name and click OK.
-
With the macro selected, expand the Logic Objects action section.
-
Drag and drop the Insert action to the macro board.
-
Change the Label value to "Insert Production Constraints".
Now you will create the required table joins.
-
In the Insert action, click the Configure tab.
-
In the Connection Name field, select your DDM.
-
In the Table Joins section, click Create Joins.
-
Expand the Views node, and drag and drop the following tables to the joins board. The tables that start with MB are those that were generated from your model recipe. Note that the <xxxxxxxx> is replaced by the GUID for your recipe from Task 1. In the example below, the value is 57a7fc45:
-
orders_full
-
locations_dimension
-
MB_<xxxxxxxx>_LKU_Sites
-
MB_<xxxxxxxx>_LKU_Products
-
-
Create joins between the following table.column combinations:
-
locations_dimension.location_dimension_Ckey to MB_<xxxxxxxx>_LKU_Sites.location_dimension_Ckey
-
orders_full.source_location_dimension_Rkey to MB_<xxxxxxxx>_LKU_Sites.location_dimension_Ckey
-
orders_full.product_dimension_Rkey to MB_<xxxxxxxx>_LKU_Products.product_dimension_Ckey
-
-
Click Save. You see the summary of the table joins.
Next, you create the mappings to the model table.
-
In the Output Scoped Connection Options section, for the Connection Name, select the model you generated using the model building recipe.
-
For Into Table, select "AggregateProductionConstraints". The table columns are listed.
-
Check the Clear Table Before Executing checkbox.
-
In the Columns section, click the Clear Statement icon
to clear the mapping for the AggregateProductionConstraintID column. This removes the 0 from the statement.
-
Edit statements to map the DDM data into the AggregationProductionConstraints table for these columns.
-
SiteName: Tables = MB_LKU_<xxxxxxxx>_Sites, Fields = SiteName
-
ProductName: Tables = MB_LKU_<xxxxxxxx>_Products, Fields = ProductName
-
ProductionRequirement: Tables = orders_full, Fields = item_quantity, Functions = Sum().ToString()
-
ProductionRequirementType: value = 'Min'
-
In Conditions, click Add Statement and define a condition to limit the location_type to 'MFG':
Tables = location_dimension, Fields = location_type, Operators =, value = 'MFG'
Again, you can use Edit Statement to define the 'MFG' constant value.
-
Click OK.
You can use Edit Statement to add the ToString() function on ProductionRequirement and to define the 'Min' constant value on ProductionRequirementType:
You are now ready to run the macro and review the results in your model.