Skip to Content
Technical Articles

S/4 HANA : MSEG or MATDOC Where is my data going?

In S/4 HANA, there is always a confusion about the tables MSEG and MATDOC. This blog is to explain where exactly your data is going and how to understand the link between MSEG and MATDOC tables.

 

For example, in the below case when you check the number of entries of MSEG in SE16N, it shows 55 entries.

 

Where as if you check the same in MATDOC, it shows the same 55 records. So which one is real?

 

 

Lets try a different approach. Lets try to check the correct entries through a database query using transaction DBACOCKPIT which directly queries the database. First check in MATDOC as below.

Perfect!. it shows 55 as expected when you run a straight forward select query from MATDOC at database level.

Lets try to run the same thing for MSEG now and I am sure you are expecting 55 here as well. Right?

Oops!. It shows 0. So it is clear that we don’t have any entries in MSEG in HANA database. It just simply points towards MATDOC internally when you run through SE16N. How is it doing & how do we know that?

This is an important screenshot taken from transaction SE11. Go to Extras menu for table MSEG and you will see these details.

SAP has introduced a concept called ‘Replacement Object’ where a CDS view name is mentioned. Earlier, this was called as Proxy object till 1709 version and it looks like SAP has renamed it as ‘Replacement Object’ to avoid any confusion because of the word ‘Proxy’.

 

For MSEG, NSDM_E_MSEG is shown as replacement object. So when you access MSEG either in SE16N or in your custom program, SAP routes the logic through this CDS view which gets the data from MATDOC. You can see the logic in the below screenshot.

Give CDS View NSDM_E_MSEG in view name in SE11. You will get the below details which gives the DDL definition name and the DDL SQL view name (NSDM_V_MSEG) also.

View NSDM_V_MSEG in SE11 clearly shows that it gets the data from MATDOC.

 

Last part in the DDL definition talks about any custom fields or appended fields and how this is handled in these replacement objects. You need to use Extend view and append the custom fields in Eclipse editor.

Please note that you don’t have the replacement object available for all replaced tables in S/4 HANA. This concept is different for each table and above explained steps are specific to MSEG/MATDOC. Replacement object/Proxy object concept was mainly introduced to avoid confusions/changes in custom programs which deals with MSEG. So if a custom program does a select from MSEG, it will still work similar to what we saw in SE16N screenshot above.

Hope this blog helped to clarify some of the doubts related to MSEG/MATDOC tables.

11 Comments
You must be Logged on to comment or reply to a post.
  • Great blog!!!  Let me tell you it took me more than a couple of hours to figure that one out.

    Another fun trick is doing a where-used on the table for DDL Sources.   That will show you some nice CDS views over the table.  Not all of them have it.  MSEG does not, but NSDM_V_MSEG does have CDS views.  Very cool.  One that I need may already be there.

     

    /
  • Hi Gokul,

    There’s a customer that says he has the S/4HANA but doesn’t have the MATDOC.

    Do you know the SAP Note number, or SAP component release version, that is the minimum version to have this ?

  • Hi Gokul,

     

    The relation you explained between MSEG and Matdoc i understood very clearly through this Blog.

     

    Now the same Concept i applied to MARC. When i go to MARC Table i found a Replacement Object for the same. But when i do a Selct count(*) on Marc it looks like MARC itself has records in HANA DB then why it has a replacement object again.

     

    Could you Please clarify my doubt.

    • Good question Mantri. Sorry. I saw this quite late.

      For MARC, the reason is different. If you check inside the replacement object NSDM_E_MARC, it shows that it selects the data from MARC itself with some extra joins on different tables. The main reason what I see is the way the commodity code (STAWN) is selected in S/4 HANA. Now it is based on few new tables like /SAPSLL/TUNOS & /SAPSLL/MARITC linked with a number scheme usage based on plant/country link. Please go through the CDS view and you will also get the details.

      So the main difference between between MSEG’s replacement object and MARC’s replacement object is that, MSEG is completely replaced by MATDOC entries and in MARC’s case only certain fields like STAWN values are retrieved in a different way and rest of the data is fetched from MARC itself. Hope this clarifies. Thanks.

      Regards,

      Gokul Radhakrishnan