It think that some of you involved in MM or PP had already a request or need to add some fields to MB51 or to call it directly with ALV grid instead of old style view. I also had such request and it contained both needs - additional fields and direct display of ALV grid. So I started to dig and debug to see what is possible to do and these possibilities I found:
  1. Copy program RM07DOCS (MB51) to Z-one and to the changes there - but I don't like such solutions so I didn't want to do that way
     
  2. Create own program which selects data from MKPF and MSEG and display it like MB51 do - but this would be to time consuming to prepare same logic like in MB51 and in case of any changes in oryginal transaction I would need to adjust program again
     
  3. Do implicit enhancement in RM07DOCS to add missing fields to the field catalog and then fill them during the call of MB51 - this would solve the first part of the request but users will have to do additional two clicks to go to ALV grid which as you may know already is sometimes to much :) Nevertheless if someone of you would like to go this way then you should do two implicit enhancements in RM07DOCS:

    In the first one you should add missing fields to the structure "list"


    Then in the second step you should add enhancement at the end of the form process_list and fill your own fields in table list[] with data.


    If you'll do your coding here then your data should be displayed on the screen.
     
  4. Do implicit enhancement in RM07DOCS to export results of MB51 to memory and read it in external program - and this path I've chosen because it gave me possibility to do pre-selection before calling MB51, I've received completly formated results from MB51 and I can add all possible events to grid for new and existing columns.
 
In the next parts I will describe how exactly I've done this but to be able to use MB51 optimized I recommend firstly to apply following OSS Notes:
  • 1516684 MKPF fields added to MSEG - Performance optimization
  • 1550000 MB51: Redesign of selection for performance optimization
  • 1558298 MB5B: Redesign of selection to optimize performance
  • 1567602 DB dependent steps to support the redesign of MB51
  • 1598760 FAQ: MSEG Enhancement & Redesign MB51/MB5B
After implementation you'll have some additional fields from MKPF directly in MSEG table which connected with additional index on MSEG and proper configuration in configuration table MMIM_REP_CUST will give you really big difference on the speed of MB51.