Data model extension for Attribute in Material(Reuse)

 

Overview

·       Let’s take an example of material master data.

·       We have one transactional system and one MDG system.

·       From transactional side we got the requirement like they need to make default one vendor with one material master data.

·       For this we need to extent the MARA table of transaction system.

·       Now the material will pass from the MDG system because it is a single source of truth. Then we need to extend the MDG system active table which is MARA only as well as we need to extend the MM standard data model with extending the UI application.

·       If suppose both the system is connected with IDOC then we need to extend the IDOC segment as well.

·       In Target system we need to implement one BADI so that custom filed value gets stored into the MATA table.





Different Use Cases Scenarios

  1. Extending Data Model with Custom Attribute in Standard Entity. (Existing standard tables)
  2. Extending Data Model with Custom Entity. (New Custom Table)
  3. Extending Data model with Custom Attributes in Flex mode. (No Active tables involved)
  4. Extending Data Model with Custom Entity in Flex model. (No Active tables involved)


1.    Extending Data Model with Custom Attribute in Standard Entity

Scenario:

Want to Extend MARA with default Vendor field ‘ZSUPPLIER’.

Step need to follow in both layer: -

MDG

S4/ECC

Extension of MM data model

Extend MARA with ZSupplier

Staging structure automatically will get updated

API Structure

SMT Mapping

SPRO Configuration (Only in MM)

Enhance UI application

 

·       There are two structure will generate in MDG while activating Data model

·       1. Staging structure 2. API structure

·       Staging structure will be inside MDG Layer and API structure will be inside S4 or ECC layer.

·       After activation of CR first the data will get store into Staging structure then it will pass data to API structure using Access class and then then data will get move to Active tables.

·       In read query the process is opposite. Fist the data will get read from MARA table to API structure. Then from API structure to Staging structure using Access class. Then from Staging structure it will display on UI.

·       While extending MARA table we need to extend the API structure as well.

SMT Mapping

·       In Staging structure, we will have fields for example MATNR, MBRSH, MTART, ZSUPPLIER.

·       In API structure also, we will have same fields.

·       In SMT mapping will map the attributes of Staging structure to API structure and vice versa.

·       For standard attributes the mapping is done already.

·       We need to maintain the mapping for our custom attributes.

·       The attributes can have different names in both structure so we need to map them.

S4/ECC Side Steps

1.1.1 Appending MARA table with Custom Attribute

 

SE11 -> MARA -> Append Structure or Include.

·       We have appended MARA table with new field ‘ZVENDOR’.

1.1.2 Append API Structures with new field

How to find API Structures

·       For MM its easy because in MM API structure have common naming convention.

·       We have 3 structure to extend which is

·       1. MDG_BS_MAT_S_MARA

·       2. MDG_BS_MAT_S_MARA_X

·       3.  MDG_BS_MAT_S_MARA_UI: To set UI field Properties (Read only, mandatory, Hidden).

·       For Every MM Data model entity, we have this common naming pattern so we can search with ‘MDG_BS_MAT_S_*’ in F4 help and can find the API structures for all MDG entities.

·       For BP and Other Data model we can find the API structure in SMT Tool.

 

 

·       After appending field in MARA table automatically the field gets add into structure ‘MDG_BS_MAT_S_MARA’.

 

·       Now we need to add field into other 2 structures.

 

Purpose of X structure (MDG_BS_MAT_S_MARA_X)

·       After Activation of Change Request, Method ‘SAVE’ of access class with get trigger and in that method, it will have some API to create material in system.

·       In this method inside Save method again there will be some API.

·       In ‘CALL_MMD’ there is API which will create material and here there will be API structure declared which get fills from staging API’s at runtime.

·       For Change Scenario we need to set the ‘X’ parameter. Let’s take an example have Material group field so that field will be in X structure.

1.1.3 SPRO Configuration (Only for MM data model)

·       SPRO -> Logistic General -> Material Master -> Field Selection -> Assign field to field selection group.

·       Right side we have Selection group. This Selection group has some attributes.

·       We need to include our custom field into one of this selection group.

·       In this selection group we can group the UI properties as respective some values or transaction.

·       Here we can see for ‘FERT’ value of material type, SAP have set some UI properties. Same like this for all the values and transaction we can see the properties set.

·       To include our custom field, copy this standard set and change the name of attribute.

·       Save the changes.

·       We can see our field gets added into selection group.

·       If we want to set our own UI properties for custom field, then we need to create our own selection group and add our field into that group. Here if we change the UI properties in standard selection group then it will change for other fields also included in that group.

MDG Side Steps

1.2.1 Extension of MM data model

·       In MDGIMG -> Data model -> Edit data model -> Select Data model MM -> Go to entity ‘MATERIAL’ -> Attributes -> Adding custom attribute.

Naming convention:

o   For Custom Entity: Z* or Y*

o   For Custom Attribute in Standard Entity: ZZ or YY

·       If we don’t follow these naming conventions then it will activate without any error but while SAP upgrading system, we can lose these customizations as SAP will treat it as standard Objects.

·       After modifying Data model, we need to adjust staging structures. So that all the CR which was created before data model extension will get adjusted with new modification in data model.

1.2.2 Adjusting Staging Area

·       To do that, go to SM38 and Run the Report ‘USMD_ADJUST_STAGING’ -> Provide Data model name and Execute.

·       We need to carry these activities for all the Data models.

·       In each system we need to do this activity manually after transporting requests (Development, Quality, Production).

·       Alternative to run this report we can use this button.

1.2.3. Staging Structure Generation

·       In Old version we need to generate structure manually so that our new field should get added into staging structure.

·       To do that go to MDGIMG -> Data Model -> Generate Data model specific structure

·       In new version of MDG, system will take care of generating these structures after activation of data model.

·       We just need to cross verify if our custom field got added in these structures or not.

·       If its not added then we need to manually generate the structure.

1.2.4 SMT Mapping

·       Now we have Staging Structure ‘/MDGMM/_S_MM_PP_MATERIAL’ and we have API Structure ‘MDG_BS_MAT_S_MARA’.

·       To map the fields from these two structures we use SMT mapping.

·       For Every Entity we will have 2 SMT mappings.

·       MDGIMG -> Data model -> Generate Data model specific structure -> Mapping.

·       So, there are 2 mapping for MATERIAL Entity first is ‘MDG_BS_MAT_MAP_2STA’ and another is ‘MDG_BS_MAT_MAP_2PP’.

·       First one will be used while Read, Update, Query operation. Whenever we will try to open existing data. So, the source structure will be ‘MDG_BS_MAT_S_MARA’ and target structure will be ‘/MDGMM/_S_MM_PP_MATERIAL’.

·       The Mapping ‘MDG_BS_MAT_MAP_2PP’ used while Save Operation. In this, the Source will be ‘/MDGMM/_S_MM_PP_MATERIAL’ and target will be ‘MDG_BS_MAT_S_MARA’.

·       2PP means Primary Persistence which is nothing but the active area.

Mapping to Active Area: Create/Update/Delete

·       Copy mapping and go to MDGIMG -> Data model -> Create and Edit Mapping -> Create and Edit Mapping.

·       Click on Mapping -> Open -> Give mapping name

·       Now open Entity which we need to extend.

·       Click on Details button.

·       Go to Transformation Tab.

·       Click on Edit button.

·       Click on radio button Field Mapping

·       Go down where we can find the attributes from Source structure and Target Structure.

·       This Order is the standard one ‘00001’. So, we don’t change anything here.

·       For our custom mapping we need to create our own Order.

 

 

·       To create new Order in SMT mapping click on Add button and Select Transformation Type as ‘Field Mapping’.

·       Now we will map our custom attribute under this custom Order ‘00003’.

·       Now search for custom attribute in both Structure and select them and Click on Map button.

·       After mapping we can see the checkbox got ticked and the new structure is visible.

·       Save the changes.

Mapping from Active Area: Read/Query/Update

·       Same Steps we need to follow which we did for Mapping to Active area.

·       Go to SMT mapping Edit -> Open mapping -> Select Entity type -> Details -> Transformations -> Edit -> Add new Transformation -> Give type ‘Field Mapping’ -> Under this transformation, search for our custom attribute in both Source Structure and Target structure -> Click on MAP -> Save. 

Transformation Types:

Field Mapping:

·       Used to move values form source field to target field. It is just like move statement.

Complex Transformation:

·       Before moving values from one field to another field we need to do some operation like combining 2 fields and move that into some other field.

·       To add values, we need to write some processing logic.

·       Here it will have Class and Method where we can implement some logic.

·       In this method the Input parameter will be field from Source and Output parameter will be field from Target structure.

1.2.5 UI Enhancement

·       We can enhance standard UI application using 2 methods.

1.       Enhancement

2.       Customization

·       Open any CR. Right click on the Corresponding UIBB which belongs to the entity which we enhanced. Go to application configuration.

·       Open the OVP configuration

·       Go to main page from Navigation

·       Open Basic Data UIBB

·       After opening that UIBB on Left side Repositories section our field should be visible.

·       In Case field is not there then follow below process

·       MDGIMG -> Central Governance for Material -> Clear UI Metadata Buffers.

·       This report will clear the cache memory.

·       After this open CR once again and follow same steps.

·       Now we can see the field is visible in Repository Section of UI.

·       Now to add our custom field into UI screen either we can use Customizing or Enhancement.

·       As we have our enhancement we will be using over here.

·       Go to enhancement.

·       We have added our field under UI Section GTIN/EAN.

·       Save the changes.

 

Testing

·       Create New CR

·       Enter Mandatory fields and Submit CR

·       Now to activate CR directly without processing workflow.

·       SWO1 -> Enter Object type BUS2250 -> Test -> Enter CR number -> Execute method ACTIVATE_2.

·       Now our CR got activated and the material number got generated.

·       Go to Mara table and check the ZVENDOR field.


 

 

Comments

Popular posts from this blog

SAP MDG Process Modelling

MDG Derivation (BADI)

MDG Validation (Using BADI)