Sub topic 6
Dependencies and the order in which to load objects
This chapter assumes you know what a migration object is and how a migration project groups objects. It also assumes you can tell master data from transactional data. Here you will learn why load order matters, which kinds of dependencies exist, how to work out a sequence, and what goes wrong when the sequence is wrong.
Why order matters
Business data refers to other business data. An open purchase order names a supplier, a material, a plant, and a company code. If one of those does not exist in the target system when the order is loaded, the system rejects the order. The migration cockpit does not bypass this check. It creates data through the same application logic that a user would trigger, so each record must pass the checks of the target application.
Load order is therefore a correctness issue, not only a convenience. A wrong order leaves you with a long list of "does not exist" errors. They look like data problems, but they come from sequencing.
Kinds of dependencies
Dependencies come in four kinds. Keep them apart, because each is fixed in a different place.
| Kind | Example | Where you fix it |
|---|---|---|
| Configuration | A plant or company code that a record refers to | Customizing in the target system, before any migration |
| Object to object | Supplier and material must exist before an open purchase order | Load order within the project |
| Value mapping | Legacy payment terms need a target payment term | Value mapping, before simulation |
| Shared data | Customer and supplier roles that rely on the same business partner | Check the documentation of the specific objects |
Configuration is the most often forgotten. The cockpit moves business data, not the organizational structure and settings the data depends on. Company codes, plants, chart of accounts settings, and similar entries must already exist in the target client. If they do not, no load order will help.
Typical layers of a load sequence
A sequence usually has layers. Objects in a layer can normally load in any order relative to each other. Objects in a later layer need the earlier ones.
- Organizational and finance foundations, such as G/L accounts and cost centers.
- Master data, such as business partners (customers and suppliers) and materials.
- Master data that builds on other master data, such as bills of material or fixed assets.
- Open items and balances, such as open purchase orders, open receivables, and G/L balances.
The exact objects and their order depend on your release and scope. Treat the layers as a pattern, not a fixed list.
The diagram is an example, not the SAP-delivered sequence. Open purchase orders sit behind both business partners and materials. That is why one missing supplier can block many orders at once.
Finding the real dependencies
Do not rely on memory or on a generic list. Use these sources, in this order:
- The object documentation. SAP describes each migration object, including the objects and settings it needs. Read it for every object in your project.
- The cockpit itself. The project view lists your objects. Many objects show preceding or required objects in their details. What is shown depends on the release and on whether you use the file, staging table, or direct transfer approach, so check your own system.
- Your data. Look at which keys your files refer to. If your purchase order file contains a supplier number, the supplier object is a predecessor in practice, even if you did not plan it that way.
- A test load. A failed test migration shows missing predecessors quickly. Use it to confirm the order, not to discover it for the first time in production.
Turning dependencies into a sequence
For a project with many objects, write the dependencies down and compute the order. A topological sort does this. It returns an order in which every object appears after all its predecessors. It also stops with an error if your dependencies contain a cycle, which means you made a mistake.
The script below uses placeholder object names, not official SAP names. It needs Python 3.9 or later. It prints the load "waves", which are groups of objects that do not depend on each other and can be loaded in the same step.
from graphlib import TopologicalSorter, CycleError
# object -> set of objects that must be loaded first (placeholder names)
dependencies = {
"G/L account": set(),
"Cost center": set(),
"Business partner": set(),
"Material": set(),
"Bill of material": {"Material"},
"G/L balance": {"G/L account"},
"Open purchase order": {"Business partner", "Material", "Cost center"},
"Open receivable": {"Business partner", "G/L account"},
}
try:
sorter = TopologicalSorter(dependencies)
sorter.prepare()
except CycleError as error:
raise SystemExit(f"Circular dependency: {error.args[1]}")
wave = 1
while sorter.is_active():
ready = sorted(sorter.get_ready())
print(f"Wave {wave}: {', '.join(ready)}")
sorter.done(*ready)
wave += 1The first wave contains the four objects with no predecessors. The second wave holds everything that needed only those. This is the shape of a cutover plan: each wave must finish, with errors resolved, before the next starts.
Simulation and dependencies
A simulation run checks the data and the application logic but saves nothing. This has a consequence for ordering. If you simulate open purchase orders before the suppliers have been migrated for real, the simulation reports that the suppliers do not exist. The data may be fine. The predecessor is simply not in the system yet.
For this reason the practical rhythm is: prepare and validate all objects, then work wave by wave. Within each wave you simulate, correct, and migrate. Only then do you move to the next wave.
Partial failures and dependent objects
Real loads rarely succeed completely. Suppose 3 of 5,000 suppliers fail. The 4,997 that succeed are in the system, and the 3 are not. Every purchase order that refers to one of the 3 will fail in the next wave.
Handle this in a fixed way:
- Before releasing a dependent wave, review the error list of the predecessor wave.
- Correct the failed predecessor records and load them again.
- Only then load the dependent object.
If you skip step 1, you get a second set of errors that hides the original cause. Fix the cause in the predecessor and the dependent errors disappear. The reading and correction of messages is covered in a later chapter.
Generated numbers and references
Some objects get their key from the target system, for example through an internal number range. Others take the key from your source data. Where the target assigns the number, dependent data still has to point to the right record. Check each object's documentation and the mapping information in the cockpit for how references are resolved. Settle this before test cycles, because changing the numbering approach later affects every dependent file.
Common mistakes
- Treating configuration as migration. Missing company codes or plants cause errors in many objects at once.
- Planning by object name only. Two objects can look independent and still share data, such as a customer and a supplier linked to the same business partner.
- Loading in parallel without a dependency check. Running independent objects together is fine. Running dependent ones together is not.
- Reloading a predecessor after the dependent object. Repair records in the predecessor and rerun the dependent records that failed because of it.
- Hard-coding the sequence in one person's head. Document the order in the project so test cycles and the final cutover use the same one.
What to carry forward
Write the sequence as waves, record it in your project plan, and use it in every test cycle. It becomes the backbone of the cutover plan, with the timing and the error review gates added on top.
Exercise
You simulate the "open purchase order" object and get many errors saying the supplier does not exist. Your supplier file is correct and the suppliers have not been migrated yet. What is the most likely cause, and what do you do?
Show answer
The simulation saves no data, so the suppliers do not exist in the target system. The errors come from sequence, not from the purchase order data. Migrate the supplier (business partner) object and the other predecessors first, resolve their errors, and then simulate the purchase orders again.
Exercise
Add the object "Open invoice" to the Python script, with dependencies on "Business partner" and "Open purchase order". In which wave does it appear?
Show answer
Add the entry "Open invoice": {"Business partner", "Open purchase order"} to the dependencies dictionary. "Open purchase order" is in wave 2, so "Open invoice" is in wave 3.
Exercise
Name the four kinds of dependencies in this chapter and say which one the load order cannot fix.
Show answer
Configuration, object to object, value mapping, and shared data. Load order cannot fix a configuration dependency. A missing plant or company code must be created in the target system's Customizing before the migration.