SAP BLOG How to add custom fields to SAP S/4HANA data migration cockpit with data migration modeller. Example with material master.

SAP Blog

Kayıtlı Üye
Katılım
22 Ara 2017
Mesajlar
1,925
Tepki puanı
7
Puanları
6

Purpose


During last months I posted two blogs referring to the migration of master data (business partners) and transactional data (stock) using S/4HANA data migration cockpit. In both cases I used the standard template provided by the migration tool.



– Load customers with data migration cockpit:




– Load inventory balance with data migration cockpit




This time I am going to show how to add custom fields to a master data object like materials and how to proceed so we can load this extra data with the data migration cockpit.

The Migration object modeler (transaction LTMOM) is used to create your own customer-specific migration objects or add SAP standard objects that are not yet included in the migration cockpit. LTMOM can also be used to adjust the SAP standard migration objects delivered with the cockpit by adding custom fields.



Summary of steps to add custom fields to material master




1. Add custom fields to table MARA using an append (transaction SE11)

2. Enhance BAPI structures to include new custom fields (transaction SE11).

3. Assign field group to the new fields (transaction OMSR)

4. Adjust source structure for material migration object (transaction LTMOM)

5. Map new fields to the Extension structures for material (transaction LTMOM)

  • Add custom code to assign the values of new custom fields to extension structures (transaction LTMOM)
  • Add structure mapping for extension structures (transaction LTMOM).

6. Save and generate the migration object

7. Download adjusted template with data migration cockpit (transaction LTMC)

8. Migrate your data with data migration cockpit using new file structure that includes custom fields (transaction LTMC)





Enhance table MARA and BAPI structures


With transaction SE11 we can add new fields to table MARA (and eventually to MARC, …) creating one append. I add 3 fields used in the client previous ECC6 version.

LTMOM_06.jpg


Going to transaction LTMOM (data migration modeller), if I double-click on the Target structure I can see the the BAPI used for the data load for materials.

LTMOM_06b-scaled.jpg


We need to pass the SAP standard delivered structure to upload the customer-defined material master fields (BAPI_TE_E1MARA, BAPI_TE_E1MARAX), which should be enhanced in the same way as MARA table as shown below:

LTMOM_11.jpg


LTMOM_12.jpg


In case we would have added custom fields to table MARC then we would need to do same process for structures BAPI_TE_E1MARC, BAPI_TE_E1MARCX.



Assign field group to the new fields


Another step is to assign field selection group to the new fields. Please check it out in T-code OMSR. Otherwise fields data will not be transferred to database.

LTMOM_13.jpg


This will be used for all material types.

LTMOM_14.jpg






Adjust source structure for material migration object (transaction LTMOM)


To make changes to the object we use transaction LTMOM, selecting the object we are going to use for the data migration (pressing F4 we find all projects and objects).

LTMOM_01.jpg


Press F4 and select the object for materials in my project, in this particular case “Material”:

LTMOM_02.jpg






Then we can display/change the function module used by LTMC as also add code, map structures, etc. These are main options in the menu:

LTMOM_34.jpg


Adjust source structure of Migration Objects. Add fields listed below to source structure S_MARA.

LTMOM_07-scaled.jpg




If we had added fields to MARC table we would need to do the same for structure S_MARC.





Add custom code to assign the values of new custom fields to extension structures (transaction LTMOM)


In order to assign the values of custom fields to the extension structures it is necessary to add some custom code.

To know the target structures names we can click in each of them.

LTMOM_16.jpg


LTMOM_27-scaled.jpg




In the field mapping we can see where to create code to add conversion logic.

LTMOM_19-scaled.jpg




To know which structures, variables and functions to use in the coding, let’s have a look at the target work areas available in the program generated by LTMC.

LTMOM_29.jpg


And source areas:

LTMOM_30.jpg




Now I proceed to add the code for the conversion rules. Double click in BOR_S_MARA in field mapping:

LTMOM_24.jpg


Here it is some pre-existing code, which can be enhanced manually.

LTMOM_35.jpg




Add the following code from the point indicated above.

Kod:
********************************************************
* NEW CODE FOR Z FIELDS in MARA
********************************************************

DATA: lv_e1mara TYPE  bapi_te_e1mara,
lv_e1marax TYPE bapi_te_e1marax.

*-----------------------------------------------------------------
* assign values to structure T28_EXTENSIONIN
*-----------------------------------------------------------------

* check Z fields are filled with value
IF _wa_s_mara-zzmanuf IS NOT INITIAL
OR _wa_s_mara-zzmanuf_nr IS NOT INITIAL
OR _wa_s_mara-zzoldmat IS NOT INITIAL.
CLEAR: _wa_t28_extensionin,
lv_e1mara.

PERFORM _rule_move_op
USING   _wa_t28_extensionin-_parentrecno
_wa_s_mara-_recno.

PERFORM _rule_move_op
USING  _wa_t28_extensionin-material
_wa_s_mara-matnr.

PERFORM _rule_move_op
USING  _wa_t28_extensionin-structure
'BAPI_TE_E1MARA'.

lv_e1mara-material = _wa_s_mara-matnr.
lv_e1mara-zzmanuf = _wa_s_mara-zzmanuf.
lv_e1mara-zzmanuf_nr = _wa_s_mara-zzmanuf_nr.
lv_e1mara-zzoldmat = _wa_s_mara-zzoldmat.

PERFORM _rule_move_op
USING   _wa_t28_extensionin-valuepart1
lv_e1mara.

* Pseudocode to assign values and add entry in internal table IT_t28_extensionin.

mwb:r_data_write( [t28_extensionin]
[_wa_t28_extensionin]   ).

*-------------------------------------------------------------------
* assign values to structure T29_EXTENSIONINX
*-------------------------------------------------------------------
CLEAR _wa_t29_extensioninx.
PERFORM _rule_move_op
USING _wa_t29_extensioninx-_parentrecno
_wa_s_mara-_recno.

PERFORM _rule_move_op
USING   _wa_t29_extensioninx-material
_wa_s_mara-matnr.

PERFORM _rule_move_op
USING   _wa_t29_extensioninx-structure
'BAPI_TE_E1MARAX'.

lv_e1marax-material = _wa_s_mara-matnr.
IF _wa_s_mara-zzmanuf NE space.
MOVE 'X' TO lv_e1marax-zzmanuf.
ENDIF.
IF _wa_s_mara-zzmanuf_nr NE space.
MOVE 'X' TO lv_e1marax-zzmanuf_nr.
ENDIF.
IF _wa_s_mara-zzoldmat NE space.
MOVE 'X' TO lv_e1marax-zzoldmat.
ENDIF.

MOVE lv_e1marax TO _wa_t29_extensioninx-valuepart1.

* Pseudocode to assign values and add entry in internal table IT_t29_extensioninx

mwb:r_data_write(
[t29_extensioninx]
[_wa_t29_extensioninx] ).

ENDIF.

As info, we can see how the code for function “_rule_move_op” looks like. This is generated with the program being an standard LTMC function.

LTMOM_26-1.jpg


Here we have the other function used “mwb:r_data_write”, using a pseudocode that is automatically replaced during the program generation.

LTMOM_25-1.jpg






Add structure mapping for extension structures.


In this step I assign the source structure S_MARA to target extension structures, specifying the mapping type.

Here for T28_EXTENSIONIN. Just need to double click in this structure to add the mapping rule.

There are different mapping types. It can be 1:1, that would mean that for each line of S_MARA there will be one line for T28_EXTENSIONIN. As this only happens when the custom fields are filled, we will use mapping type “split” with target 0 in case fields are empty.

LTMOM_17-scaled.jpg


And the same for the T29_EXTENSIONINX.

LTMOM_31.jpg




Save and generate project.


Now I can save and generate the migration object.

LTMOM_09.jpg


it takes some time to generate the function module with the new code and changes.

LTMOM_08.jpg




Download adjusted template with data migration cockpit (transaction LTMC)


It is possible to download the load template with the corresponding button in LTMOM or directly in LTMC (please see my other blogs with instructions).

In the new template it is possible to see the custom added fields.

LTMOM_23.jpg






Migrate your data with data migration cockpit using new file structure that includes custom fields (transaction LTMC)


Now I can fill the load file with the needed data, including the 3 custom fields that are now available.

LTMOM_32-scaled.jpg




Once all load steps are done we can see the new materials created with the custom fields filled in table MARA using transaction SE16N:

LTMOM_33-scaled.jpg




Simulate import/data conversion in LTMOM


Data migration modeller offers a tool to simulate the import of the file we will load with LTMC. To access to it click on the “simulate” button in the menu.

LTMOM_22.jpg




It is possible to debug the function module while converting the data as also see the records before and after the conversion.

LTMOM_21.jpg


Unfortunately, the log is not as detailed as it used to be with LSMW.



Summary


Data migration modeler is the tool to enhance the current LTMC objects, which all are based in function modules that can be modified. With LTMOM you can do almost as much as with LSMW, in which we had instructions like skip_record, skip_transaction, … As inconvenience against LSMW, LTMC has not a clear log display after reading and conversion.

Okumaya devam et...
 
Üst