In this excerpt from Balaji Gaddam’s SAP PRESS book, Capable to Match (CTM) with SAP APO, gain insight into the CTM engine algorithm and understand the constraint-based programming techniques that the CTM engine uses to arrive at a feasible plan for a given demand.
Key Concept
Supply network planning using SAP SCM offers several planning alternatives: the heuristics-based infinite planning tool; a cost-based, finite planning optimization engine; and the Capable to Match (CTM) engine (also referred to as CTM Solver) in SAP Advanced Planning & Optimization. The CTM engine is the central component of the Multilevel Supply and Demand Matching tool available in SAP SCM. It offers a planning algorithm to solve large constraint satisfaction problems in a reasonable amount of time. It uses heuristics-based, depth-first, finite constraint planning logic. It can evaluate very large and complex models quickly to support several what-if planning scenarios. The CTM engine uses a multilevel planning algorithm with depth-first strategy to detect and propagate constraints at all levels of the supply chain model. The goal of the CTM engine is to find an in-time solution for a demand with the required date and quantity, considering all the available sourcing alternatives. The CTM engine creates a late solution for the remaining quantity when no or only a partial in-time solution can be calculated.
Capable to Match (CTM) planning in SAP Advanced Planning & Optimization (SAP APO) is based on constraints. Constraints are generally defined as a condition that must be satisfied for the selected solution, and are represented by a constraint variable. Each constraint variable is defined with domain values or value ranges. The CTM engine tries to generate a feasible in-time solution by satisfying all the constraints and the allowed domain values. Constraint variables are linked with each other; as a result, the corresponding domain values are also linked. Any change or reduction of the domain values for one constraint variable is propagated across all linked constraints. Let me provide you with a brief example to illustrate the basic principles of the CTM engine algorithm using constraints (Figure 1).

Figure 1
Example of CTM engine algorithm principles
X and Y represent the constraint variables that are linked using relationship Y = 2X. Due to this relationship the domain values for Y are reduced with respect to X. This can be further explained in terms of a supply chain planning model. The constraint X represents the resource capacity whereas Y represents the demand quantity. The relationship indicates the resource capacity requirements for fulfilling one unit of demand quantity (i.e., for fulfilling each unit of demand quantity), two units of resource capacity is required. The available resource capacity is limited to 10 units. The resource capacity constraint is thus propagated to the demand variable and limits the maximum allowed demand quantity to 5 units.
A more detailed example is illustrated in Figure 2.

Figure 2
Constraint propagation in CTM multilevel planning
The CTM planning algorithm and the underlying scheduling logic are developed in C++ and hence would require an additional optimizer server connected to the SAP SCM system. Until the SAP SCM 5.0 release, the CTM engine is only available for Microsoft Windows-based 32 bit and 64 platforms. The planning data is exchanged between the SAP SCM system and CTM optimizer server using Remote Function Call (RFC) communication through SAP Gateway.
CTM Planning Algorithm
The CTM planning engine is started after the data preparation phase of the CTM planning run. Master data and transaction data are evaluated based on the CTM profile settings. The selected planning data is uploaded into the CTM engine for generating the supply plan. The CTM engine creates the solution proposal for each individual demand as per the demand prioritization sequence. CTM uses all procurement alternatives to generate the supply plan for the given demand. CTM fulfills the demand late, in case the complete demand quantity cannot be fulfilled in time. You can define the allowed time frame for late demand fulfillment. Once the demand is processed and the generated supply (complete or partial) is saved, the engine continues to plan the next demand in the demand list. It is very important to understand that during the demand processing by the CTM engine, the supply plan created for demand is not changed once the demand is planned. As a result, the demand prioritization sequence determines the sequence of supply and resource allocation.
The next section explains the sequence of supply plan creation for a given demand. As CTM plans the complete supply chain network starting from the finished product to the raw materials, the complete network is evaluated as a tree structure. During the search tree generation by CTM, you can use several standard and user-defined decision criteria to influence the supply plan generated by CTM.
CTM Search Tree Generation
The CTM engine uses a depth-first strategy for creating a supply plan for a given demand. When planning in backward scheduling mode, the goal of the CTM engine is to fulfill the demand quantity as much as possible and as close as possible to the demand date. CTM evaluates the complete supply chain network for every component in sequence. The finished product demand is satisfied by generating a search tree of the components. Each level of the search tree is known as a node. CTM standard search logic and rules are applied at each node locally and represent the key decision points of the search tree. The key decision criteria applied at each of the decision points are:
- Supply selection
- Substitution rules selection
- Source of supply selection
The search tree and the nodes the CTM model uses are shown in Figure 3. The supply chain network for the finished product BP_CYC consists of four locations. The forecast is released at location BL_FRNK_DC, which is a distribution center. The vendor name is BL_FRM_VEND.

Figure 2
CTM search tree generation and decision points
At the demand location the first node – Node 1 – of the supply plan is created. The standard CTM decision criterion is applied at this node. CTM first searches for existing supplies with material availability date before the requirement date and then searches for a possible source of supply to create a new order. In this example, as no supply is found at Node 1, CTM creates the stock transfer order using the transport lane from the location BL_FRNK to BL_FRNK_DC.
For the dependent requirement at location BL_FRNK, Node 2 is created, which results in the creation of the planned order for BP_CYC. The planned order generates two dependent requirements for the components BP_TYR and BP_FRM. CTM chooses one of the dependent requirements (BP_TYR) and applies the source selection on Node 3 to generate the stock transfer order from the subcontracting location BL_TYR_PROD. The transfer order requirement represented by Node 4 is fulfilled by the planned order for BP_TYR. In case of any capacity constraints at Node 4, the CTM engine will adjust the solution for BP_CYC created at Node 2 using backtracking. The solution tree generated so far is not saved in liveCache yet.
After Node 3 is satisfied completely, CTM selects Node 5 for the dependent requirement for product BP_FRM and creates the purchase requisition for the vendor location BL_FRM_VEND. As you notice, the search tree for a given input component is generated until the last node of the supply chain network before generating the search tree for other input components. As the supply tree is completely generated with respect to the required demand quantity the solution is saved and the next demand is selected for CTM planning.
For planned orders with multiple input components the sequence of supply tree generation is governed by the internal sequence and cannot be influenced by the user. In any case, this does not cause any limitation because CTM always ensures that all dependent requirements are fully satisfied in time. It is important to understand that the decision criteria are applied locally at each node of the search tree. Once the complete in-time supply plan is generated for a given demand, the search tree is saved. For any open demand quantity, late search is applied to generate the late supply plan. After the in-time and late supply plan creation, the solution is saved and the next demand is planned. Due to the heuristics-based planning approach, once the supply plan is created and saved for a given demand, the succeeding demands do not influence the supply plan already created for the previous demand.
In the next section the key decision criteria used by the engine at each level or node is explained in detail.
CTM Decision Criteria for Source Selection
The CTM engine uses predefined search criteria to generate the supply plan. The default search sequence starts with existing supplies which can be used for a given demand to create in-time solution. Once all supplies available in-time are used, CTM will select another possible source of supply (SOS). The selection of SOS by the CTM engine is based on pre-defined rules which can be influenced by the user.
CTM Supply Selection
CTM supply contains the attribute Supply Quantity, Date, and Category. At each of the decision points CTM searches for existing supplies and consumes the supplies at the demand date. By default, all CTM supplies are created with CTM category 00. The CTM engine implicitly searches for supply with category 00 for both the primary and secondary demands. If no supplies are found for the product before the requirement date then CTM searches for the supplies of the substitute product, provided rules-based substitution is used in CTM planning. By default, only the supplies with category 00 are used for the substitute product. Planning with substitution rules is explained in detail in the later chapters.
If multiple supplies exist that can be used to satisfy the demand, CTM uses the closest supply when planning in backward scheduling mode. As shown in Figure 4, backward scheduling consumes Supply 2 to satisfy the demand of 10 units. On the other hand, with planning in forward scheduling, the earliest available supply is used. In this example, Supply 1 is used for planning the demand of 10 units. The supply selection rules are applied as long as the demand quantity can be satisfied in-time. If the use of the supply would create a late supply plan, then the supply is ignored and CTM would use an alternative source of supply to generate a new order to create an in-time supply plan. It is important to understand that the supply selection is always applied locally at each node of the search tree.

Figure 4
CTM supply selection in forward and backward scheduling
CTM Source of Supply Selection
SOS is used in CTM planning to generate the supply plan for the selected demands. In case of multiple SOS, selection of the SOS in CTM depends on pre-defined rules. The sequence of source selection is used as long as the required schedule for the demand can be met. If the source with higher priority leads to creation of late supply, then CTM selects the source with lower priority to meet the demand in-time, as the primary goal of the CTM engine is to create an in-time supply plan considering all the possible SOS alternatives in the complete supply chain.
CTM planning can be executed with three types of supply sources:
CTM planning uses in-house production SOS to create the planned orders using production process models (PPM) and production data structures (PDS). Supply network planning (SNP) and PPM/PDS can be used in CTM based on the planning mode. The PPM describes when a plan can be used to manufacture a product. A location and a lot-size interval are defined in the PPM as validity criteria. The temporal validity is adopted from the output product. The production version from SAP R/3 corresponds to the PPM in SAP APO. On the other hand, PDS contains the master data for planning in SAP APO. Production data structures are generated from R/3 data (classic master data such as bill of material [BOM], routing, and recipe).
CTM planning uses external procurement SOS to create the purchase requisitions or stock transfer orders using transportation lanes and purchasing information records. The transportation lane in SAP APO defines the transportation route between two locations in a supply chain model. The use of scheduling agreements and contracts is not supported in CTM planning.
Substitution rules can be used to select the supplies of the alternate products. Product interchangeability groups and Form-Fit-Function classes can be used not only to select supplies for alternate products but also to create procurement or production for the alternative products. Substitution orders are created using the substitution rules.
SOS (in-house production, external procurement) selection in CTM uses predefined rules to select the appropriate SOS when multiple SOS exists for a given demand. As shown in Figure 5, CTM source selection uses the Procurement type as the first selection criteria to determine the SOS that can meet the demand due date. Similar to the supply selection strategy the SOS selection is also applied locally at each individual node of the supply search tree.

Figure 5
CTM source determination sequence
The source determination is applied by the CTM engine to select the SOS while considering several planning parameters, product parameters and the SOS parameters to generate an in-time supply plan for the demand.
Source Selection with Procurement Type
The procurement type defines how a product is obtained. The procurement type is a classification that indicates whether a material is produced internally, procured externally, or both. The procurement type can be defined for each product location. SCM system offers four possible procurement types that can be assigned to the individual product location. Source selection in CTM depends on the procurement type of the products selected for planning.
With procurement type F, CTM planning can use transport lanes to create purchase requisitions with a source. If no transport lanes are available then CTM creates the purchase requisition without a source location.
With procurement type E, CTM planning can use PPM and PDS to create planned orders. If no PPM/PDS is selected in the CTM planning then CTM cannot create any planned order without a source, unlike SNP heuristics. The selection of the PPM or PDS for planning can be influenced by the parameter Plan Explosion in the product master or using the global setting in CTM customization as shown in Figure 6.

Figure 6
Plan explosion for PPM/PDS selection, SAP APO transaction /sapapo/ctmcust, CTM Customization; APO transaction /sapapo/mat1, Product Master
- External procurement or in-house production (X)
With procurement type X, CTM planning can use PPM/PDS and transport lanes to create planned orders and purchase requisitions with source location. In case no PPM/PDS or transport lane is selected in CTM Planning, then CTM can create purchase requisitions without any source location.
- External procurement planning (P)
With procurement type P, CTM planning does not create any new orders or consume any supplies for the demand. The requirement for the product with procurement type P is not planned in CTM.
Substitution orders in CTM can be created for procurement type E, X, and F. The selection of a particular SOS in CTM planning can be ignored using the parameter Exclude Procurement Alternatives in the CTM profile. Using the setting for PPM/PDS, transport lanes and external procurement available in the CTM profile under technical settings, you can exclude the usage of the procurement alternative for CTM planning. It is also possible to temporarily reassign the procurement type for the product used in CTM planning using the setting Replace Procurement Type, which is also available under the Settings tab of the CTM profile.
Source Selection with Inbound Quota
After the SOS selection using procurement type, further source selection is determined by quota values. The quota arrangement defines which part of a product quantity should be assigned to a given source of supply. Quota arrangements represent dimensionless proportions that are used as a basis for splitting a quantity. Quota arrangements are either inbound or outbound. With inbound quota arrangements, the source location of a shipment is defined. For each product, a quota arrangement specifies which part of the quantity should be sourced from which of the possible sources. Possible sources include locations, PPMs, and procurement relationships listed as sources for a specific destination location by transportation lane. For outbound quota arrangements, the destination location of a shipment is defined. For each product, a quota arrangement specifies which part of the quantity should be transported to which of the possible destination locations. Possible destination locations are all those that are the destinations of transportation lanes starting at the defined source location.
CTM supply planning considers only inbound quota values whereas CTM supply distribution considers outbound quota values. CTM planning with inbound quota is used to define the percentage of quantity that must be sourced from a given SOS. In case multiple SOS exist for a given product location, using inbound quota the SOS selection function selects the SOS that can fulfill the quota requirement. Inbound quotas can be maintained for a given location and can be maintained for a given product and planning version. Inbound quotas can also be maintained and used in CTM planning for locations, in-house production and means of transports assigned to the transport lanes. For products with procurement type X, inbound quotas can be maintained across transport lanes and PPM/PDS. Inbound quotas (Figure 7) can be maintained using the SAP APO transaction /SAPAPO/SCC_TQ1 or using the SAP Easy Access menu path Advanced Planning and Optimization > Master Data > Quota Arrangement.

Figure 7
Inbound quota arrangements used for CTM planning, SAP APO transaction /sapapo/scc_tq1
Source selection in CTM using inbound quota is applied either for the total demand quantity of the complete planning run or for each individual demand using the Requirement Split setting of the inbound quota.
- Inbound quota without requirement split
Source selection with quota is applied as soft constraints (i.e., quota values) are used for CTM planning only in case the demand quantity can be fulfilled in-time. With inbound quota CTM uses the SOS so as to reach the quota levels as much as possible. For each demand (primary and secondary), all possible sources are evaluated to generate the new supply plan which is as close as possible to the required quota values. If you have maintained quota for an SOS, then alternatives without any quota values are ignored completely from planning. Similarly, sources with zero quota values are also ignored completely. Quota values are evaluated for each CTM run and the history of the quota requirement from previous planning runs is not considered for CTM source selection. For example, if there are purchase orders for a vendor where quota is maintained, then CTM does not consider quota from purchase orders for SOS selection during the creation of new purchase requisitions. Let me give you an example. Suppose a DC can source from two locations L1 and L2. The required quota of 80/20 is maintained across locations L1 and L2 (Table 1).

Table 1
Source selection with reference to quota
For each demand both the sources L1 and L2 are evaluated. The new quota value with each source is compared with the required quota values. Source of supply with minimum deviation (Delta) is finally selected for the given demand. The same logic is applied for each demand selected for planning in a given CTM run. As inbound quota values are considered as soft constraints, based on the demand situation and the capacity constraints the net quota values proposed by the CTM run can be different from the required quota values. CTM applies the quota values only if the demand can be satisfied in-time.
- Inbound quota with requirement split
With SAP SCM 5.0, CTM planning considers the inbound quota with requirement split. Requirement splits can be enabled for the inbound quota values in the master data maintenance of the inbound quota values. The inbound quota values are used in CTM planning to split the original demand quantity in the proportion of the quota requirements. Each proportional demand quantity is planned in CTM using the corresponding source for supply. If time-phased inbound quota values are used for CTM planning, then the demand date (for primary and secondary demand) is used to select the inbound quota interval. In an unconstrained planning situation and without any lot size requirements the supply plan is generated as per the required quota requirements. Let me give you another example. Suppose a DC can source from two locations L1 and L2. The required quota of 80/20 is maintained across locations L1 and L2 (Table 2).

Table 2
Unconstrained planning without any lot size requirements
It is important to understand that the lot size specification or the resource constraints are not considered for calculating the proportional demands quantities using the inbound quota values. In constrained planning situations, if the proportional demand quantity cannot be fulfilled in-time, then CTM will use the procurement priority to select the alternate source of supply.
Source selection with Procurement Priorities and Costs
If no quota is used for planning, then procurement priority and costs are used to select the source for planning. For products with procurement type E, the priority assigned to the PPM/PDS is used. The PPM/PDS with the highest priority that can generate in-time supply plan is selected. Similarly, the transport lane priority is used to select the transport lanes for products with procurement type F. For products with procurement type X where production and procurement is possible, the priority across PPM/PDS and transport lanes is used to select the source. Fixed multilevel cost assigned to the PPM is used for SOS selection in case priority is not maintained or if the SOS has same priority. For transport lanes, the cost assigned to the Means of Transport (MoT) is used to select the lowest cost MoT.
As shown in Figure 8, the priority and costs are applied locally at each node of the search tree. For the demand at the distribution location, the transport lane from Plant 1 and Plant 2 are checked for highest priority. Once the lane is selected the MoT is selected using the MoT costs. The MoT with the lowest cost is selected. For the dependent requirement at the plant the priority assigned to the PPM/PDS is used in such a way that the highest priority PPM/PDS is selected for creating in-time supply plan. It is important to understand that the source selection is applied locally at each location and not across locations. For example, it is not possible for CTM to check for highest priority PPM from Plant 1 and Plant 2 before using the low priority PPM in Plant 1 and Plant 2. Source selection in CTM is a soft constraint, i.e., if the source with higher priority results in a late supply plan then the source is ignored and low priority source is selected.

Figure 8
CTM source selection with priority and costs
Source Selection with Validity Date
When source selection using inbound quota and procurement priority does not result in a unique source, then CTM selects the SOS using the validity date of the PPM/PDS and transport lanes. The source with the largest end date has the highest priority provided the source selection results in in-time solution. SOS with the validity start date after the demand date will not be selected for CTM planning unless late demand fulfillment is allowed for the selected demand.
Source Selection with PPM/PDS Lot Size
If multiple sources have the same priority and validity date then the source selection is based on the maximum lot size value assigned to the PPM/PDS. The PPM/PDS with the largest maximum lot size would have the highest priority. PPM/PDS with the minimum lot size larger than the demand quantity is completely ignored by CTM. This is to avoid creation of excess supply due to PPM/PDS minimum lot size. Excess supply in CTM can be only created due to the product lot size. The PPM/PDS lot size is used only for source selection. Minimum and maximum lot sizes for the transport lanes are not used for source selection. Lot size values for the transport lanes maintained using the lot size profile is used mainly for the order quantity selection. PPM/PDS selection with lot size can lead to partial quantity fulfillment.
Let me give you an example:
Original Demand = 100 Units
PPM Lot size requirements [Min, Max] = [30, 40]
CTM Proposed Quantity
- Order 1 = 40
- Order 2 = 40
- Order 3 = 20 (Fails due to the minimum lot size restriction of the PPM)
- Due to the minimum lot size restriction of the PPM of 30 units, the partial demand of 20 units cannot be fulfilled. As a result the demand of 100 units is fulfilled by a supply of only 80 units.
In this example the complete quantity of 100 units can be fulfilled with three orders of 40, 30, and 30 units. Such lot size optimization is not supported in CTM planning.
Source selection with CTM is followed by scheduling and creation of the order using the selected source. Initial source selection does not ensure that the selected source can create a feasible plan. When the selected source fails to create a feasible plan then CTM rejects the source and new source determination is carried out using the same rules again.
Balaji Gaddam
Balaji Gaddam is a team lead of SAP SCM Center of Expertise and is based out of SAP headquarters in Newtown Square, PA. Balaji recently celebrated his 10-year anniversary at SAP and has been involved with SAP SCM/CTM solution development, implementation, and support for the last eight years. He is the author of Capable to Match (CTM) with SAP APO, available at www.sap-press.com. You find Balaji on LinkedIn at https://www.linkedin.com/pub/gaddam-balaji/5/210/454.
You may contact the author at balaji.rao.gaddam@sap.com.
If you have comments about this article or publication, or would like to submit an article idea, please contact the editor.