Enhance purchasing reports with new fields
I work as both a functional and technical consultant and have been faced many times with the requirement to add customer fields to purchasing reports like ME28, ME2L or ME2N.
Adding the last purchase price to ME28 is especially frequent, and in the past (to my shame) I’ve made custom changes to RM06EF00. I’ve also searched for the best way to enhance these reports in SCN and have come across many forum posts where a lot of people validated my old ways.
This is the correct (SAP Sponsored) way to do it, and it’s available from EHP4 onwards.
Many purchasing reports share the BADI ME_CHANGE_OUTTAB_CUS, which takes in dynamic parameters according to the calling report.
There is only one method called FILL_OUTTAB, which takes as input parameter the output structure name in IM_STRUCT_NAME, and the real data in CH_OUTTAB.
The first thing is to declare a field-symbol with the correct structure provided in IM_STRUCT_NAME, and create an IF that validates if the structure is the expected one (remember this BADI runs for various reports with various output structures).
This is the specific example for ME28. All that is left is:
- Add the custom code inside the IF, which fills the customer fields in <fs_tabrel>;
- Add the customer fields to the structure in SE11 (in this case MEREP_OUTTAB_PURCHDOC_REL for ME28). Use append structures.
Here is the simple, standard, and clean way to enhance your purchasing reports and at the same time centralize all enhancements in the same BADI. Happy maintenance and upgrades.