Sub topic 11
Converting and mapping values
Legacy systems and S/4HANA rarely use the same codes. Your old system might store the country as Germany, the payment term as NET30, and the plant as P01. The target system expects DE, a configured payment term key, and a plant that exists in its own customizing. The value mapping step translates the first set into the second. This chapter covers how the migration cockpit handles that translation, how to prepare the mapping lists, and what goes wrong most often.
This chapter assumes you have a migration project with at least one migration object, a populated source file or staging table, and a validation run that has already completed. If any of these is missing, go back to the earlier chapters on data preparation and validation first.
Where value mapping fits in the project lifecycle
Validation checks the structure and content of your data. Conversion then replaces source values with target values. Only converted data can be simulated and migrated.
The loop between conversion and the mapping lists is normal. A first conversion run often shows values you did not know existed, and you add them to the mapping and run the step again.
Two kinds of change: fixed values and value mapping
The cockpit changes values in two ways. It helps to keep them apart, because they are maintained in different places.
- Value mapping translates each distinct source value into a target value. It applies to fields where the target system has a check table or customizing, such as country, currency, unit of measure, plant, or company code.
- Fixed values and defaults put the same value into a field for every record, regardless of the source. The object definition decides which fields allow this.
Both appear in the migration object's field mapping. The migration object defines which fields are mappable, and you do not choose this per project. If a field you expected to map is not offered, the object does not support mapping for it. Changing that is the job of the migration object modeler, which a later chapter covers.
What a mapping task contains
For each field that needs mapping, the cockpit builds a mapping task. It collects the distinct source values found in your data and asks you to assign a target value to each one.
| Source value | Records using it | Target value | Status |
|---|---|---|---|
| Germany | 1,204 | DE | Mapped |
| Deutschland | 37 | DE | Mapped |
| UK | 212 | GB | Mapped |
| Holland | 9 | (empty) | Unmapped |
Several source values can point to the same target value. This is how you merge spelling variants, as with Germany and Deutschland above. The reverse does not work. One source value has exactly one target value, so if P01 must become two different plants depending on the record, mapping cannot do it. You would have to split the source data or use a different source field.
The count of records per value is useful. A value used by 9 records out of 10,000 is often a typo or an old code, and it is usually better to correct it in the source than to keep a mapping entry for it.
Working through mapping tasks
The steps below describe the usual flow in the Migrate Your Data app. Labels vary a little between releases, so check the buttons in your system.
- Run the conversion step. The cockpit reads the data and lists the mapping tasks that apply to your object.
- Open a mapping task and review the source values.
- Enter target values, or download the list, fill it in a spreadsheet, and upload it again. The spreadsheet route is faster for lists of more than a few dozen values.
- Save, then run the conversion again so the new mappings are applied to the data.
- Check the step result for remaining unmapped values or messages.
Target values must be valid in the target system. The cockpit usually checks them against the check table, so an entry such as UK for a country is rejected or reported, because the ISO code is GB. Check the key and not the description. For languages, units of measure, and currencies, use the internal and ISO keys that the target system defines, and verify them with the functional consultant who owns the customizing.
Preparing the list outside the cockpit
You can build the first draft of a mapping list from your own extract. The script below counts the distinct values in one column and writes a sheet with a proposed target where you already know one.
import csv
from collections import Counter
def distinct_values(path, field):
"""Count how often each value occurs in one column of a source CSV."""
with open(path, newline="", encoding="utf-8") as f:
return Counter(row[field].strip() for row in csv.DictReader(f))
def write_mapping_sheet(counts, known, out_path):
"""Write source value, record count, and a target value if one is known."""
with open(out_path, "w", newline="", encoding="utf-8") as f:
writer = csv.writer(f)
writer.writerow(["SourceValue", "Records", "TargetValue"])
for value, n in sorted(counts.items(), key=lambda item: -item[1]):
writer.writerow([value, n, known.get(value, "")])
known_countries = {"Germany": "DE", "Deutschland": "DE", "UK": "GB"}
counts = distinct_values("customers.csv", "Country")
write_mapping_sheet(counts, known_countries, "country_mapping.csv")
print(f"{len(counts)} distinct values written to country_mapping.csv")Rows with an empty TargetValue are the ones you still have to decide. Keep this sheet under version control. You will need it again for every test cycle.
Common errors and how to avoid them
Unmapped values. A source value with no target value blocks the step or produces an error message for each affected record, depending on the object and field. The fix is to complete the mapping and rerun conversion, not to edit the data after the fact.
Whitespace and case differences. de, DE, and DE look the same to a reader but are different source values. Trim and normalize the source before upload, or the mapping list will contain near-duplicates.
Mapping a value that does not exist in the target. The target plant, company code, or payment term must be configured in the target system before you map to it. If the customizing is missing, the failure shows up later, often in the simulation, as a message about an unknown key. Treat missing customizing as a dependency, in the same way the object sequence chapter treats missing master data.
Mappings out of date after a data change. If you upload a new source file after mapping, new distinct values may appear. Rerun validation and conversion, and review the mapping tasks again instead of assuming the old list still covers everything.
Wrong target for a default. When you apply one default value to many records, such as one tax classification, you apply it to every record. Confirm with the business owner that no group of records needs a different value.
Mapping and the rest of the process
Mapping is cheap to change before simulation and costly to change after migration. Once records are created in the target system, a wrong plant or payment term has to be corrected through the application, not by rerunning the migration. This is why the plan puts conversion before simulation. The simulation uses the converted data and tests it against the target system's checks without saving anything, which makes it the best place to catch a bad mapping.
For a repeatable process, treat the mapping lists as part of the data, with an owner, a version, and a review before each test cycle. When a mapping needs logic, for example "use plant A for company 1000 and plant B for company 2000", mapping lists are the wrong tool. Handle it in the source data preparation or with an adaptation in the migration object modeler.
Exercise
Your source file contains the country values Germany, Deutschland, DE, and de. A colleague suggests creating four mapping entries, each pointing to DE. What is a better approach, and which mapping rule makes the four entries possible at all?
Show answer
Normalize the source first. Trim whitespace and fix the case, and replace obvious variants such as Deutschland in the extract, so the list has fewer entries to maintain. The four entries are possible because several source values may map to the same target value. The reverse is not allowed: one source value can have only one target value.
Exercise
The conversion step reports that 9 records use the source value Holland, which has no target value. List two valid ways to resolve this and say what you must do afterwards.
Show answer
Either enter NL as the target value for Holland in the mapping task, or correct the value to Netherlands (or the code NL) in the source and upload the data again. In both cases, rerun the conversion step so the change is applied, and check that no unmapped values remain before you start the simulation.