Sub topic 10
Validating the Data
What this chapter assumes
This chapter assumes you have already created a migration project and selected migration objects. It also assumes you have prepared source data, either as template files, staging table content, or a direct-transfer selection. You should be able to read a CSV file and know the difference between a key field and a mandatory field.
What validation does
Validation is the step in the migration cockpit that checks your source data before anything is written to the system. The cockpit reads the data for a migration object and tests it against the rules of that object. It then reports every problem as a message.
Validation does not create business records. Nothing is posted and no master data is created. You can therefore repeat it as often as you like. The goal is to find and fix problems while they are cheap to fix.
Validation is also different from the two steps that follow it:
- Value conversion (next chapter) replaces legacy values with target values.
- Simulation runs the real import logic, but does not save the results.
Validation comes first because the later steps depend on data that is already well formed.
Where validation sits in the project flow
The cockpit guides you through a fixed sequence for each migration object. The sequence is: prepare the data, validate it, convert values, simulate, and execute. Errors found at any stage send you back to the data, not forward.
Treat the loop in the diagram as normal. A first validation run on real legacy data rarely comes back clean.
What the checks cover
The exact rules depend on the migration object, but they fall into a few families.
| Check family | What it looks for | Typical example |
|---|---|---|
| Structure | The data matches the object's structures and fields | A column is missing or renamed in a template |
| Mandatory fields | Required fields have a value | A business partner has no role |
| Format and type | Values fit the field's data type and format | A date entered as text, a number with letters |
| Length | Values fit the target field length | A name of 45 characters in a 40-character field |
| Key consistency | Keys are unique and related records belong together | The same customer ID appears twice, or an item has no header |
| Value validity | Values are allowed in the target configuration | A country or currency code that does not exist |
The last family overlaps with value mapping. Some invalid values cannot be fixed in the file. They need a conversion rule, which you will define in the next chapter. When a message says a value does not exist in the target, ask first whether the value should be mapped instead of edited.
How validation differs by transfer approach
The checks are the same in principle, but where you fix the data differs.
- File upload. You correct the template file and upload it again. The cockpit does not change your file.
- Staging tables. You correct the rows in the staging table, or reload the table from the source. The cockpit reads whatever the table contains at the moment you validate.
- Direct transfer. The data comes from a source SAP system, so you correct it there, or adjust the selection, and transfer again.
In all three cases, a fix at the source has to be repeated for every later test cycle. If you only patch the data in the cockpit environment, the same error will return in the next cycle and in the productive run. Prefer fixes that are scripted or recorded.
Pre-checking a file before you upload it
Some problems are cheap to find with a small script, before the cockpit reads the file. Duplicate keys and over-long values are two common examples. The script below reads a CSV extract, counts key occurrences, and reports values that exceed a length limit. The file and field names are placeholders, not SAP template fields. Replace them with those from your own extract.
import csv
from collections import Counter
def precheck(path, key_field, max_lengths):
"""Return a list of problems found in a source CSV before upload."""
problems = []
keys = Counter()
with open(path, newline="", encoding="utf-8") as f:
for line_no, row in enumerate(csv.DictReader(f), start=2):
keys[row[key_field]] += 1
for field, limit in max_lengths.items():
if len(row[field]) > limit:
problems.append(f"line {line_no}: {field} is longer than {limit} characters")
problems += [f"duplicate key {k}" for k, n in keys.items() if n > 1]
return problems
for problem in precheck("customers.csv", "CustomerId", {"Name": 40}):
print(problem)A few points about this script:
- Line numbers start at 2 because line 1 is the header row.
- The
max_lengthsdictionary maps a field name to its limit, so you can add more fields without changing the function. - It is a pre-check, not a replacement. The cockpit applies the authoritative rules, and it knows limits and mandatory fields that your script does not.
Reading the validation result
After a validation run, each migration object instance shows a status and a count of messages. Messages carry a severity, and the severity decides what you must do.
- Error. The record cannot be migrated as it is. You must fix the data, or convert the value, and validate again.
- Warning. The record can continue, but something may not be what you intended. Read each warning type once and decide whether it is acceptable.
- Information. The cockpit reports something without requiring action.
Each message identifies the record and the field, with text that explains the rule that failed. Work through messages in groups, not one by one. A single wrong convention in the legacy system, such as dates in a local format, can produce thousands of identical messages. Fix the cause once.
Chapter 14 covers message handling in detail. For now, the working rule is: no errors left before you move on.
Common errors and what they usually mean
- Everything fails with a structure message. The template was edited (a column was moved, renamed, or deleted), or an old version of the template was used. Download the template again from the project and copy your data into it.
- Leading zeros disappear. A spreadsheet application converted a code such as
00012345to a number. Format those columns as text before pasting data, or work in CSV with a tool that does not guess types. - Dates and decimals fail. The legacy extract uses a different date format or decimal separator than the template expects. Normalize the format in the extract step.
- Special characters are garbled. The file was saved in the wrong encoding. Save as UTF-8 when the template calls for it.
- A child record fails because its parent is missing. The parent object was not loaded, or the key differs between the files. This is a dependency problem, covered in the chapter on load order.
- Validation passes, but the simulation fails. The data is well formed, but the import logic found a conflict, such as a missing customizing entry in the target system. This is the reason both steps exist.
A practical routine
- Run your own pre-check on the extract for duplicate keys, lengths, and encoding.
- Upload or load the data and run validation for one object.
- Group the messages and fix causes at the source.
- Decide which remaining errors are mapping problems and note them for value conversion.
- Repeat until no errors remain, and record the fixes so they can be applied to the next test cycle.
Keep a short log of each recurring error and its fix. The log makes later test migrations faster. It also becomes input for the cutover plan.
Exercise
A validation run reports 4,000 errors with the same text: the country value "UK" does not exist in the target system. A colleague proposes editing the file to replace every "UK" with "GB". What would you consider before doing that, and what is the alternative?
Show answer
First check whether the same legacy value appears in other files or objects, and whether the extract will be reloaded in later test cycles and in the productive run. Edits made by hand in one file would have to be repeated each time, and other objects would still contain "UK". The better option is usually a value mapping (conversion rule) that maps "UK" to "GB", applied consistently during the Convert Values step. Fixing the extract logic at the source is also valid if it is scripted and repeatable. After either fix, validate again to confirm the errors are gone.
Exercise
Your pre-check script finds no problems, but the cockpit's validation reports errors. Does this mean the script is wrong? Explain.
Show answer
No. The script only tests a few rules, here duplicate keys and one length limit. The cockpit applies the full rule set of the migration object, including mandatory fields, formats, structure, and value validity against the target system. A clean pre-check shows only that the problems it tests for are absent. The cockpit's messages remain the authoritative result.