Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
gokul_radhakrishnan3
Active Participant
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.
18 Comments
mmcisme1
Active Contributor
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.



 
gokul_radhakrishnan3
Active Participant
Thanks Michelle and thanks for sharing.
Former Member
Nice blog thanks
former_member182465
Active Participant
0 Kudos
Nice Finding Gokul and thanks for sharing it...
0 Kudos
very good blog.
arthur_alvesteixeira
Active Participant
0 Kudos
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 ?
Sandeep_Reddy
Explorer
0 Kudos
Good Blog.
PawelPawlak
Explorer
0 Kudos
Nice clarification, thank you gokul.radhakrishnan
0 Kudos
Worth reading it. Thank you 🙂
mantrishekar
Active Participant
0 Kudos
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.
gokul_radhakrishnan3
Active Participant
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
carlostol
Explorer
Hello,

Is there a way to update extension fields in MSEG en S/4HANA 1809 and higher?

I have implemented MB_MIGO_BADI that allows you to put a custom tab on MIGO and we use that to update some APPEND fields in MSEG. That used to work fine in our ECC 6.0 but now I'm struggling with that simple requirement in S/4HANA.

I tried several BADIS such as MB_DOCUMENT_BADI, MB_DOCUMENT_BADI but those still have the same limitations that in ECC when handling MSEG APPEND fields so I tried a direct UPDATE on MSEG on UPDATE TASK or BACKGROUND JOB but it doesn't work as in ECC.

I realized that a SQL UPDATE to MSEG on ABAP program cannot be done in S/4HANA as it always return sy-subrc = 4 also with SE16N.

So, what is the right way for updating MSEG APPEND fields in S/4HANA?

Regards,

Carlos
Hi Carlos,

I have a similar requirement to update extension fields in MSEG/ MATDOC table in 1909 system. I tried using MB_DOCUMENT_BADI but it doesn't seem to work.

Could you please let me know if you have a solution to do the same?

Regards,

Kavya
gokul_radhakrishnan3
Active Participant
0 Kudos
Hi Kavya/Carlos,

Did you check OSS note.2270451? I think probably that will help.

https://launchpad.support.sap.com/#/notes/2270451

You may need to update V_MKPF_UPDATE or V_MSEG_UPDATE as well I guess with the custom fields to get this done.

Regards,

Gokul Radhakrishnan
gokul_radhakrishnan3
Active Participant
0 Kudos
Hi Kavya/Carlos,

Did you check OSS note.2270451? I think probably that will help. Please check the below note.

https://launchpad.support.sap.com/#/notes/2270451

You may need to update V_MKPF_UPDATE or V_MSEG_UPDATE as well I guess with the custom fields to get this done.

Regards,

Gokul Radhakrishnan
viva_kd
Explorer
0 Kudos
My Functional Said, MSEG data not matching with requirenmnt, so go for MATDOC, as now i hv no expertise in HANA / CDS , so can i Use MATDOC in replacement of MSEG table, as we do in ECC with  SQl Query??
roshini18
Explorer
0 Kudos
Yes you can use MATDOC table
Kashish_Rajpal
Explorer
0 Kudos
Hi gokul.radhakrishnan ,

Nice blog and got the concept for this replacement object.

I have a question here that let's say we need to move historical data to HANA and want number range to be same then shall we update the MATDOC tables and automatically MSEG will hold the same data or how the sync between these two tables takes place ?

 

Regards,

Kashish
Labels in this area