Hi,
I implemented BADI's ME_GUI_PO_CUST and ME_PROCESS_PO_CUST to show a custom tab in the header section of ME21N, ME22N and ME23N.
But after implementing the BADI's, the tab showed up in ME23N, but not in ME21N and ME22N.
So I started looking for a solution in the SDN forum, and I saw that there were a LOT of people with the same problem, but nobody ever posted a solution.
So here is the solution:
So, I added the fields I wanted to show in the structure CI_EKKODB, implemented the BADI ME_GUI_PO_CUST (the methods SUBSCRIBE and MAP_DYNPRO_FIELDS), and the BADI ME_PROCESS_PO_CUST.
After that the tab showed up in ME23N, not in ME21N or ME22N.
So I found an SAP note saying the following:
Question:
I implemented the 'ME_GUI_PO_CUST' Business Add-In to display customer-
specific tab titles in the EnjoySAP purchase order. They are only shown in display mode (ME23N) however, not in create or change. Why?
Solution:
You may have forgotten to assign a field status to the user-defined fields on these tabs. As a result, the system automatically interprets the field status as 'hidden' in create and change modes. However if a tab contains only hidden fields, then the entire tab is set to hidden. In display mode, fields without a field status are automatically set to display. That is why the tab is displayed in this case.
To assign a field status to the user-defined fields, use the methods provided for this purpose in the Business Add-In 'ME_PROCESS_PO_CUST' (compare sample source code in the FIELDSELECTION_ITEM method).
So in my case, I had to add some code to the FIELDSELECTION_HEADER method of the BADI ME_PROCESS_PO_CUST.
This is the code:
method IF_EX_ME_PROCESS_PO_CUST~FIELDSELECTION_HEADER.
DATA: l_persistent TYPE mmpur_bool.
FIELD-SYMBOLS: <fs> LIKE LINE OF ch_fieldselection.
* if the item is already on the database, we disallow to change field badi_bsgru
l_persistent = im_header->is_persistent( ).
* IF l_persistent EQ mmpur_yes.
READ TABLE ch_fieldselection ASSIGNING <fs> WITH TABLE KEY metafield = mmmfd_cust_01.
IF sy-subrc IS INITIAL.
<fs>-fieldstatus = '*'. " Input
ENDIF.
* ENDIF.
endmethod.
But then, I realized that this BADI was never triggered. When I entered one of the transaction codes ME21N, ME22N or ME23N, the code in the fieldselection_header method was never executed.
So I went to transaction SE18, and entered ME_PROCESS_PO_CUST in 'Enhancement Spot' and pushed the button display.
And there in the tab 'Enhancement Implementations', I saw an implementation that was not mine, and that did not show up in the overview of the SE18 'BADI NAME' tab for the same BADI... which to me seems strange.
So as you may know, there can never be more than one active implementation of the BADI ME_PROCESS_PO_CUST.
So I disactivated my implementation and put my code in the existing implementation.
And after that it worked!