Adding Custom Fields in S/4HANA Using BAPI Extensions in LTMOM
CREDITS: MANOJ SASIDHARAN CREATED BY: ANGEL ARICATT
In this blog, we'll address a common challenge encountered when using LTMOM (Legacy Transfer Migration Object Modeler) in SAP in the standard target structure. When such fields are needed, extending the BAPI (Business Application Programming Interface) becomes essential to ensure smooth data migration. We’ll walk through the complete process: adding the custom field to the target structure, updating the BAPI, and implementing the necessary logic to incorporate the field into the transfer process.
By the end of this blog, you'll have a clear understanding of how to effectively extend your LTMOM configuration to support custom fields and ensure a seamless data transfer experience.
Understanding the Problem
Let’s consider a scenario where you’re responsible for migrating data from a legacy system to SAP. The source system has a custom field that’s critical for business operations, but this field doesn’t exist in the target structure in SAP. Without this field in the target structure, the data cannot be accurately transferred, potentially disrupting key business processes.
This is where LTMOM comes into play. LTMOM helps map data from the legacy system to the corresponding structures in target SAP system. However, if the custom field is missing from the target structure, you won’t be able to map it directly, and the migration process will fail to capture the complete data set.
In this blog, we will focus specifically on Project Systems and walk through the process of enhancing the target structure and updating the corresponding BAPI to support custom field handling during data migration.
Note: This guide is applicable only for Project Systems.
Migrating Project Header and Project Definition Records
The migration of Project Header and Project Definition records from the legacy SAP ECC system to the new SAP S/4HANA environment is a critical step. A systematic and structured approach is essential to ensure that all project-related data is accurately transferred and aligned with the new system’s requirements. The primary goal is to seamlessly upload the Project Header and Project Definition records into SAP S/4HANA, enabling uninterrupted tracking and management of capital acquisition activities.
In the context of SAP S/4HANA data migration, LTMC (Legacy Transfer Migration Cockpit) serves as the central tool for loading data. LTMC simplifies the migration process by providing a user-friendly interface and predefined workflows for transferring data from legacy systems to SAP.
To facilitate this process, SAP offers standard DMC (Data Migration Cockpit) templates. These templates are pre-configured to support the migration of various data objects, such as Project Headers, Project Definitions, and other master data, ensuring consistency and accuracy throughout the migration.
While the standard DMC templates are highly effective for common data objects, they may require customization to meet specific business needs. For example, if your legacy system includes custom fields that are not available in the standard templates, but are vital for business operations, those templates must be enhanced accordingly.
Below is a screenshot of the standard DMC template used in conjunction with LTMC to load data into SAP S/4HANA:
Steps to Enhance BAPI
In this scenario, we are working with the Project System object, specifically focusing on extending it to accommodate custom fields required during migration.
Fig. 1: The project involves a total of 52 custom fields to be appended to the structure. For demonstration purposes, the figure illustrates only 5 of these fields.
Fig. 2: Go to transaction LTMOM (data migration modeler)
Fig. 3: Add the custom fields to the source structure
Fig. 4: Map the source structure to the R_EXTENSIONIN, Double-click on the structure mapping and configure the split settings.
Fig. 5: Configure the splits, which include the split field mapping within the field mapping (as shown in the below figure).
Fig. 6: The field mapping requires a custom event-based rule and field mapping rules, as detailed below, which works on the internal table defined in the global data.
Fig. 7: Global data
Fig. 7: Custom Event Rule (for Start of Record Event)
Add the custom field to the input parameter and include these fields, along with the main structure (S-project definition) in parameter value. Also provide descriptions for each field.
Fig. 8: Code for Custom Event Rule, built according to the function module documentation for populating the EXTENSIONIN parameter of BAPI_BUS2001_CREATE.
DATA lr_ci_proj_bapi_ext TYPE REF TO bapi_project_definition_ext.
DATA lo_bapi_mapping TYPE REF TO if_cfd_bapi_mapping.
DATA ls_ci_proj TYPE ci_proj.
CASE _split_no.
WHEN '0001'.
CLEAR gt_bapiparex.
lo_bapi_mapping = cl_cfd_bapi_mapping=>get_instance( ).
CREATE DATA lr_ci_proj_bapi_ext.
lr_ci_proj_bapi_ext->key = project_defn.
lr_ci_proj_bapi_ext->data-zzlev_code = zzlev_code.
lr_ci_proj_bapi_ext->data-zzscode_1 = zzscode_1.
“---REPEAT SIMILAR LINES FOR ALL CUSTOM FIELDS HERE
lr_ci_proj_bapi_ext->data-zzfinstdt = zzfinstdt.
TRY.
lo_bapi_mapping->map_to_bapiparex_single(
EXPORTING ir_source_structure = lr_ci_proj_bapi_ext
CHANGING ct_bapiparex = gt_bapiparex[] ).
CATCH cx_cfd_bapi_mapping.
ENDTRY.
IF gt_bapiparex IS INITIAL.
skip_record.
ENDIF.
WHEN OTHERS.
IF lines( gt_bapiparex ) < _split_no.
skip_record.
ENDIF.
ENDCASE.
Fig. 9: Custom field mapping rule used for mapping each split field.
Fig. 10: Define the parameter and its corresponding parameter value as specified.
Below is the code used for map fields of BAPIPAREX.
DATA(lv_tabix) = CONV sytabix( row ).
IF lv_tabix <= lines( gt_bapiparex ).
READ TABLE gt_bapiparex INTO DATA(ls_bapiparex) INDEX lv_tabix.
IF sy-subrc = 0.
ASSIGN COMPONENT fieldname OF STRUCTURE ls_bapiparex
TO FIELD-SYMBOL(<fs_bapi_parex>).
IF sy-subrc EQ 0.
fieldvalue = <fs_bapi_parex>.
ENDIF.
ENDIF.
ENDIF.
Note: Limit length of custom rules to 20 characters (the actual limit is 40 characters, which is the combined total length of the Project and Rule names).
Fig. 11: Return to the previous screen and click on the icon to regenerate the object with the custom changes. This will ensure that the custom fields are included in the DMC source template.
Fig. 12: The DMC source template for the Project System, including the custom fields, and the corresponding DMC load.
Fig. 12: The SAP table containing custom fields data.
Our references:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
9 | |
9 | |
8 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 |