How to create customer screen on ME21N/ME22N/ME23N Item Level using BadI
This is manual how to use the BadIs ME_GUI_PO_CUST and ME_PROCESS_PO_CUST to create a cusstomer screen on item level in ME21/22/23n. And how to fill this screen with a customer field.
Needed Badis:
- ME_GUI_PO_CUST (classical)
- ME_PROCESS_PO_CUST (enhancement spot)
Helpful information and sample code in example implementation class CL_EXM_IM_ME_GUI_PO_CUST and CL_EXM_IM_ME_PROCESS_PO_CUST. In both examples all needed information is metioned, but not always easy to find!
SAP Notes: 1910516
Step by step:
1. Append CI_EKPODB with your customer field
2. Create with SE11 a table with the following fields
a. MANDT
b. EBELN
c. EBEKO
d. Your customer field:
3. Create with SE11 a structure with the following fields
a. Your customer field
4. Create with screen painter (SE51) a screen with the new field
a. Program should be either your already existing function pool for MM exits or create a copy of the SAP example SAPLMEPOBADIEX
b. Attributes
c. Element List (referring to your structure fields)!
d. Flow Logic
i. Important to add the two modules event_pbo and module_pai!
5. Change the function pool for global data in the top include
a. Tables: your structure of step 3
b. Internal tables both referring to your table of step 2
c. Include lmeviewsf01 (otherwise you will get a dump!!)
6. Create the following function modules in the same function pool you used in the layout!
a. Y_MM_MEPOBADI_GET_DATA as copy of example code MEPOBADIEX_GET_DATA
i. Import Parameter
1. IM_EBELN type EBELN
2. IM_EBELP type EBELP
ii. Export parameter
1. EX_DATA type your table of step 2
iii. Source code completely identically to MEPOBADIEX_GET_DATA
b. Function module Y_MM_MEPOBADI_PUSH as copy of MEPOBADIEX_PUSH
i. Import Parameter
1. IM_DYNP_DATA type your structure of step 3
ii. Source code: fill your structure with the import parameter
c. Function module Y_MM_MEPOBADI_POP as copy of MEPOBADIEX_POP
i. Export Parameter
1. EX_DYNP_DATA type your structure of step 3
ii. Source code: fill export parameter with your structure
d. Y_MM_MEPOBADI_SET_DATA as copy of example code MEPOBADIEX_SET_DATA
i. Import Parameter:
1. IM_DATA type your table of step 2
2. IM_PHYSICAL_DELETE_REQUEST type MMPUR_BOOL
ii. Source code:
1. Important to change the in line your customer field:
* update existing data
<data>-yyrevisionstand = im_data-yyrevisionstand.
7. BADI (SE18)
a. ME_GUI_PO_CUST
i. Go to Menu --> Implementation --> Overview and choose your implementation
ii. If there is no implementation you have to create one (search in scn how to do)
b. Change Class Interface YCL_IM_MM_ME_GUI_PO_CUST
i. Attribute:
1. SUBSCREEN1 / Level: Constant / Visibility: Public / Type: MEPO_NAME / Initial Value ‘ITEMSCREEN1’
2. DYNP_DATA_PBO / Level Instance Attribute / Visibility Private / Associated Type your structure of step 3
3. DYNP_DATA_PAI / Level Instance Attribute / Visibility Private / Associated Type your structure of step 3
c. Method:
i. SUBSCRIBER: enter copy of source code of CL_EXM_IM_ME_GUI_PO_CUST~SUBSCRIBE
1. Method SUBSRIBE it mandatory to show your own tab.
2. According to Note 1910516 it is not possible to show more than one customer tab (one in header, one in position). I did not test if this is still true
Important:
ls_subscriber-name = defined attribute
ls_subscriber-dynpro = dynpro number of your SE51 screen of step 4
ls_subscriber-program = function pool of your SE51 screen of step 4
ls_subscriber-struct_name = your structure of step 3
ls_subscriber-label = either direct text of via text definition of your class
ls_subscriber-position = position of the tab in the position details. According to Note 1910516 it should be between 30 and 50 to avoid problems with existing screens.
ii. MAP_DYNPRO_FIELDS: : enter copy of source code of CL_EXM_IM_ME_GUI_PO_CUST~MAP_DYNPRO_FIELDS
1. Change source code by entering your field in the when case in line 56
2. Important: mapping one of the following customer fields in Line 58
iii. TRANSPORT_FROM_MODEL enter copy of source code of CL_EXM_IM_ME_GUI_PO_CUST~TRANSPORT_FROM_MODEL
1. Important: Change function module to your module of step 6a
iv. TRANSPORT_TO_DYNP enter copy of source code of CL_EXM_IM_ME_GUI_PO_CUST~TRANSPORT_TO_DYNP
1. Change function module to your module of step 6b
v. TRANSPORT_FROM_DYNP enter copy of source code of CL_EXM_IM_ME_GUI_PO_CUST~TRANSPORT_FROM_DYNP
1. Change function module with your module of step 6c
vi. TRANSPORT_TO_MODEL enter copy of source code of CL_EXM_IM_ME_GUI_PO_CUST~TRANSPORT_TO_MODEL
1. Delete lines for standard fields (line20 – 32 of the example coding are not necessary for custom fields)
2. Change “if case” of line 64 to your own field
3. Change function module of line 66 to your module of step 6a
4. Change line 73 to your own field
5. Change function module of line 74 to your module of step 6d
6. Enter line 78 (move changed value to local structure)
7. Enter call of method set_data
8. BADI Enhancement Spot ME_PROCESS_PO_CUST
Have a look into CL_EXM_IM_ME_PROCESS_PO_CUST to get sample coding
Important: you can call only one Enhancement Implementation, if there is already an active implementation you have to either use this or deactivate it!
a. Method IF_EX_ME_PROCESS_PO_CUST~FIELDSELECTION_ITEM
i. Necessary to display your customer field (compare to Note 1910516)
1. Enter the following coding:
Important: Change line 45 to your customer field used in Method MAP_DYNPRO_FIELDS
b. Method IF_EX_ME_PROCESS_PO_CUST~PROCESS_ITEM
i. Necessary to pre-fill you customer field with e.g values from material master
ii. Enter e.g. some lines like below:
iii. Important is to use the following lines to get the entered data
call method im_item->get_data
receiving
re_data = lwa_mepoitem.
iv. And after your select to use the following lines to set your selected data
call method im_item->set_data
exporting
im_data = lwa_mepoitem.
If you just followed all steps and also put all function modules into the same function pool you should see now your custom tab and field in the item details:
Problems:
- Own tab not displayed in ME21N and ME22N but displayed in ME23N
o You forget to code IF_EX_ME_PROCESS_PO_CUST~FIELDSELECTION_ITEM of ME_PROCESS_PO_CUST
o Compare to Note 1910516, you there is not “display” field you will not see the whole tab
- Own field changeable in ME23N
o Mistake in declaration of screen and/or method SUBSRICBE of ME_GUI_PO_CUST
§ Refer in screen to your defined structure
§ Refer in method by ls_subscriber-struct_name to the same structure
- Methods of ME_GUI_PO_CUST not proceeded
o Check your screen definition
§ You need to use both modules (event_pbo and event_pai) to get the method run, they are mandatory
- Dump (PERFORM_NOT_FOUND CX_SY_DYN_CALL_ILLEGAL_FORM ) when choosing the new tab
o You forgot to add the include lmeviewsf01 in the top include of your function module
- System does not react like you expect
o Ensure that all your function modules are in the same function pool