Introduction
In this blog, we’ll explore a common scenario when working with LTMOM (Legacy Transfer Migration Object Modeler) in SAP, particularly when you encounter a custom field that doesn’t exist in the target structure. This can be a challenge, especially when you need to enhance the BAPI (Business Application Programming Interface) to accommodate the new field. We’ll walk through the steps of adding the custom field to the target structure, updating the BAPI accordingly, and implementing the necessary logic to handle the field in the transfer process.
By the end of this blog, you’ll have a clear understanding of how to extend your LTMOM configuration to support these custom fields seamlessly.
Understanding the Problem
Imagine you are tasked with transferring data from a legacy system to SAP. The legacy system has a custom field that’s critical for business operations, but this field doesn’t exist in the target structure in SAP. Without the custom field in the target structure, the data cannot be transferred correctly, and the business process may be impacted.
This is where LTMOM comes into play: it maps the data from the legacy system to the target SAP structure. But, if a custom field is missing in the target structure, it will be impossible to map it directly.
In this blog, we will look at how to enhance the target structure and update the BAPI so that it can handle the custom field for the project systems
Please note this blog is based on the project systems only.
Project system and DMC load
The migration of Project Header and Project Definition records from the legacy SAP ECC system to the new SAP S/4HANA environment will be a critical step.
This migration process requires a systematic and structured approach to ensure that all project-related data is accurately transferred and aligned with the new system’s requirements. The goal is to seamlessly upload the Project Header and Project Definition records into the SAP S/4HANA environment, enabling continuity in tracking and managing capital acquisition activities.
In the context of data migration to SAP S/4HANA, LTMC (Legacy Transfer Migration Cockpit) serves as the primary loading mechanism. 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 designed to support the migration of various data objects, such as Project Headers, Project Definitions, and other master data, ensuring consistency and accuracy during the transfer.
However, while the standard DMC templates are highly effective for common data objects, they may need to be customized or extended to accommodate unique business requirements or custom fields. For example, if your legacy system includes custom fields that are critical for business processes, the standard template must be enhanced to include these fields.
Below is a screenshot of the standard DMC (Data Migration Cockpit) template, which is used for loading data into SAP using the LTMC:
Steps to Enhance BAPI
– we are working with the Project System object.
Fig_1: There are a total of 52 custom fields to be appended. For simplicity, only 5 of these fields are illustrated in the figure.
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_EXTENSION IN , Double click on the structure mapping and set splits
Fig_5: Set splits, which bring split field mapping inside field mapping (below next fig)
Fig_6: Field mapping needs custom Event based Rule and Field mapping rules as detailed below which works on the internal table defined in 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 def) in Parameter value also give the description for each fields
Fig_8: Below code for this rule built as per Function module documentation on filling 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 fields
Fig_10: Give the parameter and parameter value as defined
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(actual limit is total of Project & rule names = 40)
Fig_11: Go back and click on the icon to regenerate the object with the custom changes in order to include the custom fields in the DMC source template.
Fig_12: The DMC source template for the project system, including the custom fields And the DMC load.
Fig_12: The SAP table containing custom fields data.
Our references:
Adding custom fields to SAP HANA – Example material master
IntroductionIn this blog, we’ll explore a common scenario when working with LTMOM (Legacy Transfer Migration Object Modeler) in SAP, particularly when you encounter a custom field that doesn’t exist in the target structure. This can be a challenge, especially when you need to enhance the BAPI (Business Application Programming Interface) to accommodate the new field. We’ll walk through the steps of adding the custom field to the target structure, updating the BAPI accordingly, and implementing the necessary logic to handle the field in the transfer process.By the end of this blog, you’ll have a clear understanding of how to extend your LTMOM configuration to support these custom fields seamlessly.Understanding the ProblemImagine you are tasked with transferring data from a legacy system to SAP. The legacy system has a custom field that’s critical for business operations, but this field doesn’t exist in the target structure in SAP. Without the custom field in the target structure, the data cannot be transferred correctly, and the business process may be impacted.This is where LTMOM comes into play: it maps the data from the legacy system to the target SAP structure. But, if a custom field is missing in the target structure, it will be impossible to map it directly.In this blog, we will look at how to enhance the target structure and update the BAPI so that it can handle the custom field for the project systemsPlease note this blog is based on the project systems only.Project system and DMC loadThe migration of Project Header and Project Definition records from the legacy SAP ECC system to the new SAP S/4HANA environment will be a critical step.This migration process requires a systematic and structured approach to ensure that all project-related data is accurately transferred and aligned with the new system’s requirements. The goal is to seamlessly upload the Project Header and Project Definition records into the SAP S/4HANA environment, enabling continuity in tracking and managing capital acquisition activities.In the context of data migration to SAP S/4HANA, LTMC (Legacy Transfer Migration Cockpit) serves as the primary loading mechanism. 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 designed to support the migration of various data objects, such as Project Headers, Project Definitions, and other master data, ensuring consistency and accuracy during the transfer.However, while the standard DMC templates are highly effective for common data objects, they may need to be customized or extended to accommodate unique business requirements or custom fields. For example, if your legacy system includes custom fields that are critical for business processes, the standard template must be enhanced to include these fields.Below is a screenshot of the standard DMC (Data Migration Cockpit) template, which is used for loading data into SAP using the LTMC:Steps to Enhance BAPI – we are working with the Project System object.Fig_1: There are a total of 52 custom fields to be appended. For simplicity, only 5 of these fields are illustrated in the figure.Fig_2: Go to transaction LTMOM (data migration modeler)Fig_3: Add the custom fields to the Source structureFig_4: Map the source structure to the R_EXTENSION IN , Double click on the structure mapping and set splitsFig_5: Set splits, which bring split field mapping inside field mapping (below next fig) Fig_6: Field mapping needs custom Event based Rule and Field mapping rules as detailed below which works on the internal table defined in global dataFig_7: Global dataFig_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 def) in Parameter value also give the description for each fieldsFig_8: Below code for this rule built as per Function module documentation on filling 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 fieldsFig_10: Give the parameter and parameter value as definedBelow is the code used for map fields of BAPIPAREXDATA(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(actual limit is total of Project & rule names = 40)Fig_11: Go back and click on the icon to regenerate the object with the custom changes in order to include the custom fields in the DMC source template.Fig_12: The DMC source template for the project system, including the custom fields And the DMC load.Fig_12: The SAP table containing custom fields data. Our references: Adding custom fields to SAP HANA – Example material master Read More Technology Blog Posts by Members articles
#SAP
#SAPTechnologyblog