Use Case: Extending standard transaction with screen fields in S4HANA
Specific Example: In this document, I would show the steps needed to enhance the data model to enable addition of custom fields in the standard MIGO transaction in S4 HANA.
Some background before jumping in the modelling.
With the advent of S4HANA, the data model has changed for many business objects. Same is the case with Material Documents (which is the case study for this blog). A new table ‘MATDOC’ has been introduced which stores the combined results of MKPF and MSEG tables. Any write operation persists the results in MATDOC table only. Also, these tables have been enhanced with proxy objects (aka CDS views) namely NSDM_E_MKPF and NSDM_E_MSEG. They are primarily used during data retrieval. Also, any enhancement in these tables needs to consider the proxy objects as well.
In traditional ECC (non S4HANA) days, we used only below options of enhancing any standard table(wherever allowed)
- Option 1 – Use the provided CI include and add custom fields
- Option 2 – Create a new append structure with custom fields
Same could be followed in S4HANA paradigm as well. Following Option 1 will lead to the addition of the custom fields in all the places where the CI include is used. This in turn forces us to enhance all the associated proxy objects or CDS views as well. This is good in case the custom fields are needed in all views and at all levels. But, if it’s a non-reusable then Option 2 is the quick and easy way to do it.
Here, I will demo option 2 where I will enhance the MSEG table with custom fields.
There are 3 steps in options 2.
a. Enhance MSEG table for BAPI or BADI processing.
b. Enhance the MATDOC table for persisting the data.
c. Enhance the associated CDS view on MSEG to be able to retrieve the stored data.
a. We can add an append structure in MSEG as below
b. We can locate the suitable place in MATDOC where custom field can be added. We need to read the description of all includes and see fields in them to identify the suitable place.
c. In this step, we need to identify the proxy object. After that we need to extend that proxy object with custom fields.
PS: This blog is on similar lines to Joachim’s blog @ https://blogs.sap.com/2016/07/11/appending-tables-in-s4hana-easy-mbew/
Feedback is much appreciated.
I am new in S4 hana as an abaper. I have created a zee append structure in matdoc table to stored data of a custom field on MIGO screen. and i am using badi migo_mb_badi . In this badi. i am passing value in goitem-zzfield ... but i dont see any value in matdoc table which has this zee field as an apppend field .
Pls help ..
As mentioned above , you need to enhance at three levels. After that in your BADI implementation you need to go to method - IF_EX_MB_MIGO_BADI~POST_DOCUMENT and put logic which will take care of saving the passed values.
Thanks Ankit, really helpfull!