Professional Documents
Culture Documents
Example Words or characters quoted from the screen. These include field names, screen titles,
pushbuttons labels, menu names, menu paths, and menu options.
Textual cross-references to other documents.
EXAMPLE Technical names of system objects. These include report names, program names,
transaction codes, table names, and key concepts of a programming language when they
are surrounded by body text, for example, SELECT and INCLUDE.
Example Output on the screen. This includes file and directory names and their paths, messages,
names of variables and parameters, source text, and names of installation, upgrade and
database tools.
Example Exact user entry. These are words or characters that you enter in the system exactly as
they appear in the documentation.
<Example> Variable user entry. Angle brackets indicate that you replace these words and characters
with appropriate entries to make entries in the system.
1 Introduction ................................................................................................................................... 5
1.1 Overview .......................................................................................................................................... 5
1.1 Overview
The SAP S/4HANA migration cockpit uses function modules (internal SAP programs) that facilitate the transfer
of data to the SAP S/4HANA system. These function modules populate the SAP S/4HANA database with data.
In the SAP S/4HANA migration object modeler (transaction LTMOM), under Target Structures, you can view the
function modules that facilitate the transfer of data to the SAP S/4HANA system. Each function module transfers
data from a source structure by means of the relevant target structures to the SAP S/4HANA system database.
Note
A target structure does not always represent the SAP S/4HANA database structure. It rather represents
a specific business view of the database structure rather than the real database structure.
For migration objects delivered by SAP, SAP determines how the data in the source structure is accessed, and
how it is mapped to the relevant target structure by using predefined function modules. If required, you can create
your own function modules to facilitate the transfer of data to the SAP S/4HANA system. This guide outlines
important considerations for creating your own function modules.
2.1 Overview
Depending on your business requirement, you may want to create your own function modules to facilitate the
transfer of data to the SAP S/4HANA system.
The following sections outline important considerations for creating your own function modules.
The function module must not execute the COMMIT WORK command. The SAP S/4HANA migration cockpit
handles the COMMIT control.
The function module must use the ABAP Dictionary structure BAPIRET2 as a structure to return messages to the
SAP S/4HANA migration object modeler. In addition, note the following additional information regarding error
handling:
• SAP S/4HANA migration cockpit collects the error messages in its own application log by storing the
following information: message class, message number, and message variables. The message text is not
stored.
• No exceptions should be used. Instead all error, warning, and abort messages should be reported back to the
calling program in the standardized parameter Return.
• The function module must not cause the program to terminate. An abort message (message type A) should
be switched to an error message (message type E) to avoid that the program terminates.
Note that if the above points are not handled by the function module, you can create a wrapper to handle the error
messages. For example, the function module DMC_MIG_MAT_BOM acts as wrapper for function module
CSAP_MAT_BOM_MAINTAIN which handles the application log messages (starting at line 145).
The function module should provide a test run flag so that it can be run in test mode to simulate the creation of
data in the target system. Alternatively, you can create a wrapper to provide a test run flag so that the program
can be run in test mode. For an example, see DMC_MIG_ACC_DOCUMENT_POST where different SAP function
modules (BAPI_ACC_DOCUMENT_CHECK, BAPI_ACC_DOCUMENT_POST) are called depending on whether the
function module runs in test mode or not.
Note that if the function module is called in test mode, ensure that the internal buffers are refreshed in order to
prevent buffer overflows and performance issues when calling the function module in a loop. You can also use a
wrapper to clear the buffers. For an example, see DMC_MIG_BANK.
We recommend that function modules return new IDs from data creation. This information is required by the SAP
S/4HANA migration cockpit in order to map the new internal key fields to the legacy key fields for dependent
objects. For example, if your function module will renumber internal material numbers, the newly created internal
number should be returned in the return message.
Regarding consistency checks, write-enabled methods must make all the necessary consistency checks to ensure
that the modified or newly created instance is consistent. For example, for all line items, the related header entry
must also be in the file.
All necessary plausibility checks (for example are all mandatory fields filled, do the values use the correct format,
and so on) must be done by the function module. Alternatively, you can create a wrapper to add plausibility
checks. For an example, see function module BAPI_ACC_DOCUMENT_CHECK for plausibility checks for an account
document.
Regarding improving performance, note that the function module can process multiple instances at once (an
instance is a set of one or more records that have a defined relationship and that represent a business object type
such as Sales Order). This can be advantageous for objects that have a large amount of data.
Material Number: NA