Skip to Content
Technical Articles

Achieve Automatic Customizing for Reference Master Data in MDG

Introduction

Reference Master Data is a type of Master Data in SAP, which is mainly used as a Look-up data or value help during creation of other operational master data such as Material Master, Business Partner, etc.

Check this Blog from Markus which talks in detail about how to govern the Reference Master Data.

In this blog, we are not going to talk about how to create governance for Reference Master data, but only about how to achieve Automatic Customizing for Reference Master Data using MDG Data Replication Framework.

Problem

In a distributed SAP Environment, MDG is usually put in a  Hub system, where you govern your data centrally and distribute the data to the required target ERP System. In case of Reference Master data, which is usually a Customizing entry in the target ERP system, i.e., you need the Reference Master data to be available in the T* tables of your respective ERP transaction system, so that it is convenient to consume the centrally created Reference Master data in your transaction process.

Now, the question is

What is the easy way to achieve this?

How can i follow a standard approach to implement this scenario?

Solution

Reference Master data can be automatically distributed to any Target ERP System as a Customizing entry, i.e., using the SAP Standard BC Set approach. After approval from MDG, the Reference Master data is created in target system and gets locked under a Customizing Transport Request.

You can also decide to maintain only the Mandatory attributes for a given Customizing table. Later, the same entry can be enhanced manually in the target system with all required information, before the release of the BC set transport. In case you have filled the complete customizing attributes in MDG, then you can also automatically release the Transport in the target system during the replication.

In this blog, we will see in detail about how to configure MDG Data Replication Framework to achieve this automatic customizing.

Step-by-Step

Below are the high level steps to achieve automatic customizing

 

Creation of New Outbound Implementation

A new outbound implementation has to be created with the Communication channel as ‘4 Replication via RFC’. Standard delivered Implementation class ‘CL_MDG_OIF_DRF_OUTBOUND_IMPL’  can be used

 

Also provide the Business Object type which you have originally created for the Data Model / Entity, provide the Filter Object if required.

Creation of New Outbound Interface Model

A new outbound Interface Model should be created. During the Interface Model creation, the Function Module code will get auto generated which will contain the code to create the Automatic transport request along with the customizing entry as BC Set in the target system.

Map the required fields for which the structures should be generated. Please note, this structure will be used during the SMT Mapping at the later stage. So, please select all the required fields which you want during the Customizing entry creation.

 

Creation of New Target structure for SMT Mapping

A new inbound structure for the SMT Mapping configuration has to be created. This structure can be of same type of the Table / View of the Standard Customizing T* table. For example, if the target standard customizing table is V_T001, then you can create a Y or Z structure with the include of V_T001.

Creation of New SMT Mapping

Create a new SMT mapping to map the Source Structure which is generated through the outbound interface model and the target structure which is created above.

 

Create a new mapping step and provide the source and the target structure

Create a new Field Mapping transformation and map the required fields from source structure to the target structure

Update the view V_MDG_RD_MAPPING

A new entry in the  view V_MDG_RD_MAPPING should be created as below. The Table name is the Table type structure created in the outbound interface model, Object is the standard customizing table/view and the SMT mapping to Active area is the new SMT Mapping Created above.

Assignment of outbound implementation to Replication Model

The newly created outbound implementation should be attached to the replication model. Provide the Target system for the outbound implementation in the replication model configuration. Please ensure an Active RFC Connection to the target system exists.

 

Sample Code for the Function Module

FUNCTION zn_companycode.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(IT_BUKRS) TYPE  ZNT_BURKS
*"     VALUE(IV_RFC_DEST) TYPE  RFCDEST
*"  EXPORTING
*"     VALUE(ET_MESSAGE) TYPE  BAPIRET2_T
*"     VALUE(E_RC) TYPE  SY-SUBRC
*"  EXCEPTIONS
*"      SYSTEM_FAILURE
*"      COMMUNICATION_FAILURE
*"----------------------------------------------------------------------
*"----------------------------------------------------------------------

**This is a generated FM by OIF.
**Please do not change the signature of the FM.
**By default it calls the same FM with an RFC desitination assuming
**that the FM with the same name would exist in the receiver system.
**You can reimplement the FM by commenting out the call to the FM
**with your respective inbound FM based on the destination.

*"--------------------------------------------------------------------

  DATA: lo_container TYPE REF TO if_bcfg_config_container,
   ls_mapping TYPE if_bcfg_config_container=>ty_s_mapping_info,
   lt_langu TYPE if_bcfg_config_container=>ty_t_languages,
   lt_mapping TYPE if_bcfg_config_container=>ty_t_mapping_info,
   ls_mdg_rd_mapping TYPE mdg_rd_mapping,
   ls_header TYPE ttypename,
   lv_order TYPE trkorr.

* Step to Create the Transport request number in the target system.

  CALL METHOD cl_mdg_ref_data_api=>create_transport
    EXPORTING
      iv_user     = sy-uname
      iv_rfc_dest = iv_rfc_dest
    IMPORTING
      ev_order    = lv_order.

  ls_header = 'ZNT_BURKS' .
  ls_mdg_rd_mapping = cl_mdg_ref_data_api=>read_refdat_config(
  iv_tabletype = ls_header ).
  MOVE-CORRESPONDING ls_mdg_rd_mapping TO ls_mapping.
  CLEAR: ls_mapping-tablename, lt_mapping.
  APPEND ls_mapping TO lt_mapping.
  INSERT 'E' INTO TABLE lt_langu.
  IF sy-langu NE 'E'.
    INSERT sy-langu INTO TABLE lt_langu.
  ENDIF.
  CALL METHOD cl_mdg_ref_data_api=>create_container
    EXPORTING
      iv_rfc_dest  = iv_rfc_dest
      it_langu     = lt_langu
      it_mapping   = lt_mapping
    IMPORTING
      eo_container = lo_container.
* Read data from remote system to check whether 
* the data already there, to avoid overwritting
  data lt_data type STANDARD TABLE OF t001.
  data lt_options type STANDARD TABLE OF RFC_DB_OPT.
  data ls_options type rfc_db_opt.
* build where clause for the remote select
  FIELD-SYMBOLS: <ls_burks> like line of it_bukrs.
  LOOP AT it_bukrs ASSIGNING <ls_burks>.
    CONCATENATE  'BUKRS EQ '''
               <ls_burks>-bukrs '''' space
          INTO ls_options.
    APPEND ls_options TO lt_options.
  ENDLOOP.

* Source code to read data from target system
  CALL FUNCTION 'RFC_READ_TABLE' DESTINATION  iv_rfc_dest
    EXPORTING
      query_table                = 'T001'
*     DELIMITER                  = ' '
*     NO_DATA                    = ' '
*     ROWSKIPS                   = 0
*     ROWCOUNT                   = 0
    TABLES
      options                    = lt_options
*      fields                     = fields
      data                       = lt_data
   EXCEPTIONS
     TABLE_NOT_AVAILABLE        = 1
     TABLE_WITHOUT_DATA         = 2
     OPTION_NOT_VALID           = 3
     FIELD_NOT_VALID            = 4
     NOT_AUTHORIZED             = 5
     DATA_BUFFER_EXCEEDED       = 6
     OTHERS                     = 7
            .
  IF sy-subrc <> 0.
   E_RC = sy-subrc.
  ENDIF.

* Source code to generate the BCset and add it to the Transport
  CALL METHOD cl_mdg_ref_data_api=>add_lines_generic
    EXPORTING
      it_lines      = it_bukrs
      iv_objectname = ls_mapping-objectname
      io_container  = lo_container
      iv_order      = lv_order
      iv_mapping    = ls_mdg_rd_mapping-mapping.

  COMMIT WORK.

* Source code to release the Transport request number. 
* Please be cautious to uncomment only if you know that all the 
* attributes are filled in the customizing. 
* Otherwise, you cannot use the same Transport.

*  CALL METHOD cl_mdg_ref_data_api=>release_transport
*    EXPORTING
*      iv_order    = lv_order
*      iv_rfc_dest = iv_rfc_dest.

ENDFUNCTION.

Critical Authorizations for the User

The Replication usually happens in the background, so the same RFC user which is used in the RFC Destination, is generally taken as a user in target system for creation of the BC Set transport. But, if you want to change the user for the Transport request, please input the right user name in the below source code of the FM generated above.

 CALL METHOD cl_mdg_ref_data_api=>create_transport
    EXPORTING
*      iv_user     = sy-uname
      iv_user     = < replace the actual user id from target system >
      iv_rfc_dest = iv_rfc_dest
    IMPORTING
      ev_order    = lv_order.

 

Please ensure the user in the target system is having basic authorization for creation of BCSet and Transport Request.

S_TRANSPRT – Used to secure the functions that change transport requests and tasks

S_CTS_ADMI – Used to secure the administration functions in the CTS

S_BCSETS – Used to Secure the function that create / change the BCSet

*Source :  SAP Help Portal

Conclusion

Once the final approval is provided for the Reference Master data in the MDG System, a Replication is triggered from MDG to the respective ERP system, which is connected through the RFC destination. In the Target system, a Transport request is created with the required Customizing entry updated in the respective T* table.

A sample Transport is provide below, where the T001 (Company Code) is created

 

*All the images shown here are own images and taken from an Sandbox SAP system. Any resemblance to other systems are not intentional.

Regards

Senthilkumar Moorthy.

4 Comments
You must be Logged on to comment or reply to a post.