Sub topic 15
Adapting objects with the migration object modeler
This chapter assumes you know what a migration object is, how a migration project selects objects, and how value mapping works. It also assumes you can read a source structure and its field list. The chapter covers when the migration object modeler is the right tool, what it can change, how to change objects safely, and what to retest afterwards.
What the modeler is
The migration object modeler is a developer-oriented tool for changing migration objects. SAP delivers predefined objects such as business partner, material, and G/L account. Each object defines three things:
- Source structures, which describe the shape of the data you supply.
- Target structures, which describe what the S/4HANA load program expects.
- Rules, which describe how source fields become target fields.
In an on-premise or private cloud system you normally open the modeler with transaction LTMOM. In a public cloud edition, extensibility is more restricted and some changes are not available. Check the documentation for your release before you plan work around the modeler.
The modeler is not part of a normal data load. Most projects never touch it. Consultants who use it run it in a development system, not in the productive system.
When to use it, and when not to
Reach for the modeler last. A modified object is something your team must maintain through upgrades. Try cheaper options first.
| Situation | First choice | Use the modeler? |
|---|---|---|
| Legacy codes differ from S/4HANA codes | Value mapping | No |
| Legacy extract has duplicates or long values | Fix the source data | No |
| A needed field is missing from the template | Check whether a later release or another object covers it | Possibly |
| You need a custom field in the template | Add the field to the source structure and map it | Yes |
| A field should always get a constant value | Fixed-value rule | Yes, or a project-level default if offered |
| A field must be derived from several source fields | Field rule with custom logic | Yes |
| You want to hide unused fields to simplify templates | Remove them from the source structure | Yes |
The decision flow below shows the order to try these options in.
What you can change
The modeler works on the structure of an object and on its rules.
Source structures and fields
The source structure controls the columns in your templates and the tables in your staging area. You can usually do the following:
- Add a field, for example a legacy customer number that you want to carry along.
- Remove a field you never fill, so templates become shorter.
- Change the order or grouping of fields where the object allows it.
Every change to the source structure changes the template. A file created from the old template no longer matches the object. Download a fresh template after each change, and tell everyone who prepares data.
Target structures and mapping
Each target field receives its value from a rule. Typical rule types are:
- Direct move: copy a source field into the target field.
- Fixed value: always write the same constant.
- Value mapping: look the source value up in a mapping table. This is the same mechanism you used in the value mapping chapter, and the modeler is where the rule for a given field is defined.
- Custom logic: derive a value with code, for example by combining two fields or stripping a prefix.
Assigning a rule to a field is the most common modeler task. A mapping table is only offered for a field when the rule for that field is of the mapping type, so adding a new mappable field starts here.
Custom code
Custom logic is written in ABAP and attached to a field rule or to a processing step. Keep it short and deterministic. Code that reads other tables or calls external services makes simulations slow and results hard to reproduce. The exact points where code can be attached depend on the release, so look at the existing delivered rules in the same object to see the pattern before you write your own.
Working safely
Changes to a delivered object can be overwritten or conflict when SAP updates its content. The following habits reduce the risk.
- Work in a development system. Never change objects in production.
- Copy first where the tool allows it. A copy of the delivered object leaves the original available for comparison and for rollback.
- Make one change at a time and test it before the next. Several changes together make failures hard to trace.
- Document every change: field, reason, rule, author, date. A short table in your project wiki is enough.
- Transport the change with the normal transport route. Do not recreate it by hand in the quality system.
- Compare after SAP updates. After an upgrade or a content update, check whether the delivered object now covers your change, and remove your change if it does.
Regenerate and retest
After you change an object, the runtime artifacts that the cockpit executes must be regenerated. Until you regenerate, the cockpit keeps running the previous version, so a change can look as if it had no effect. The usual loop is:
- Change the structure or rule.
- Check the object for consistency errors, which the modeler reports.
- Generate the runtime object.
- Download a new template, or refresh the staging tables.
- Load a small test file.
- Run validation and a simulation, then read the messages.
Use a test file that covers the cases your change touches. If you added a derived field, include rows that make the derivation succeed, fail, and return an empty value. A change that works on a perfect sample row says little about real legacy data.
Messages that name your new field point back to the modeler. Messages about an unchanged field usually point to source data. Use that split when you triage errors, as covered in the chapter on reading messages.
Common failures
- The template column order no longer matches the file. The object was changed but the old template was reused. Download the template again.
- A change has no effect. The runtime object was not regenerated, or the project still uses an earlier version of the object. Regenerate and check which version the project picked up.
- A mapping table is missing for a new field. The field rule is not of the mapping type. Change the rule type, then regenerate.
- The change exists in development but not in quality. The transport was not released, or it was imported in the wrong order. Check the transport log.
- Simulation passes but the migration run fails. Custom code behaves differently on larger volumes, or it depends on data that exists only in development. Test with a realistic volume in a quality system.
A short worked example
Suppose your legacy system stores a customer's old number, and the business wants it written into a text field on the S/4HANA business partner so that service staff can still search for it.
- Confirm that no template field already takes the value.
- In the modeler, in development, add a field
LEGACY_IDto the source structure of the business partner object. - Assign a direct-move rule from
LEGACY_IDto the target text field. - Run the consistency check, then generate the runtime object.
- Download the new template. Fill
LEGACY_IDfor three test partners, one of them with a blank value. - Validate and simulate, and confirm that the value appears on the two filled records and that the blank one does not raise an error.
- Record the change, then transport it.
The whole change is one field and one rule. That is the target size for a modeler change. If the plan grows into many fields and a lot of custom code, consider whether a separate pre-processing step on the legacy side would be simpler to maintain.
Exercise
A team adds a derived field to a delivered migration object in the development system and regenerates it. Testers report that their existing data files now fail to load. What is the most likely cause, and what should the team do?
Show answer
The change altered the source structure, so the old template no longer matches the object. The team should have the testers download the new template, move their data into it, and reload. In future, the team should announce each modeler change together with the updated template.
Exercise
Legacy payment terms use codes such as "N30" and "N60", but S/4HANA uses different codes. Should you change the migration object in the modeler? Explain.
Show answer
No. This is a code difference, so value mapping solves it without touching the object. Use the modeler only if the object has no mappable field for payment terms, and then only to give that field a mapping-type rule.