03-05-2007 8:41 AM
Hi,
I have implements the user-exit <b>EXIT_SAPMM06E_012</b> to validate the Purchase order. The following is an extraction of the code:
*========================== VALIDATE PO ITEMS
LOOP AT tekpo.
* Validate Material group for all non Material purchases
IF tekpo-matnr IS INITIAL.
* I01 Validate Material group active
*----------------------------------------------------------------------*
CLEAR: t023t.
SELECT SINGLE * FROM t023t WHERE matkl = tekpo-matkl
AND spras = sy-langu.
IF NOT sy-subrc = 0.
IF NOT tekpo-id IS INITIAL.
mmpur_business_obj_id tekpo-id.
mmpur_metafield mmmfd_mat_grp.
ENDIF.
*E The material group & does not exist
mmpur_message_forced 'E' 'MM' '086' tekpo-matkl '' '' ''.
w_e_error = 'X'.
ELSEIF t023t-wgbez = 'DO NOT USE'.
IF NOT tekpo-id IS INITIAL.
mmpur_business_obj_id tekpo-id.
mmpur_metafield mmmfd_mat_grp.
ENDIF.
*E Material group & is inactive. DO NOT USE
mmpur_message_forced 'E' 'Z_MM06E005' '001'
tekpo-matkl '' '' ''.
w_e_error = 'X'.
ENDIF.
The statements <b>mmpur_business_obj_id</b> and <b>mmpur_metafield</b> correctly group the error messages per Item number and allow you to edit the field directly from the Messages while the mmpur_message_forced populate the Messages screen.
Now I am implementing the same validation for the Purchase requisition using user exit <b>EXIT_SAPLMEREQ_010</b>. According to OSS Note 310154 the export parameter should be used for all errors.
<i><u>OSS Note 310154</u> - Do not output the messages yourself but use the corresponding export parameter of the function exit to store all your messages there.
This parameter is transferred back to the standard program which carries out the message output.</i>
This does populate the Messages screen, but the messages are all displayed as Header messages and not with regards to the relevant Item.
Since the macros <b>mmpur_business_obj_id</b> and <b>mmpur_metafield</b> does not exist in the user exit, how do I go about to report the error messages correctly in the messages screen. Please refer to the below example coding that I used.
DEFINE m_message.
wa_message-type = &1.
wa_message-id = &2.
wa_message-number = &3.
wa_message-message_v1 = &4.
wa_message-message_v2 = &5.
wa_message-message_v3 = &6.
wa_message-message_v4 = &7.
append wa_message to ex_messages.
END-OF-DEFINITION.
* I01 Validate Purchase group active
*----------------------------------------------------------------------*
CLEAR: t024.
SELECT SINGLE * FROM t024 WHERE ekgrp = wa_eban-ekgrp.
IF NOT sy-subrc = 0.
*E Purchasing group & not defined (please check your input)
m_message 'E' 'ME' '011' wa_eban-ekgrp '' '' ''.
w_e_error = 'X'.
ELSEIF t024-eknam = 'DO NOT USE'.
*E Purchasing group & is inactive. DO NOT USE
m_message 'E' 'Z_MM06E005' '000' wa_eban-ekgrp '' '' ''.
w_e_error = 'X'.
ENDIF.
Thanks and best regards,
Jacques Botha
07-06-2011 11:19 PM
Hello Jacques,
I am facing the same problem of doing some custom checks on fields in ME52/53N.
I managed to implement the user exit EXIT_SAPLMEREQ_010 in order to do the checks however the new requirement is to position the cursor on the error field selected when the edit button is pressed in the messages pop-up window. I haven't yet managed to accomplish this.
Is there any possibility to set the cursor on the field that caused the error?
Maybe there is a set of macros that allow this as there is for the exit EXIT_SAPMM06E_012
Any help will be highly appreciated.
Thank you,
Stefan
07-07-2011 6:29 AM
hello,
you should implement ME_PROCESS_REQ BADI and use CHECK method.
INCLUDE mm_messages_mac." mandatory for message maintenance
and if check fails - add
mmpur_message 'E' 'ME' '303' 'text1' 'text2' 'text3' 'text4'.
ch_failed = mmpur_yes.
br,
dez_
07-07-2011 12:33 PM
Hello,
I've tried your approach. However, the cursor still does no position on the error fields when I select the error message from the messages popup and select "Edit".
Bellow the code used:
METHOD if_ex_me_process_req_cust~check.
INCLUDE mm_messages_mac.
DATA : lt_item TYPE mmpur_requisition_items,
ls_item TYPE mmpur_requisition_item,
lo_ref TYPE REF TO if_purchase_requisition_item,
ls_items TYPE mereq_item.
IF sy-tcode = 'ME51N' OR sy-tcode = 'ME52N' OR sy-tcode = 'ME53N'.
* Retreving Item details
CALL METHOD im_header->get_items
RECEIVING
re_items = lt_item.
LOOP AT lt_item INTO ls_item.
lo_ref = ls_item-item.
CALL METHOD lo_ref->get_data
RECEIVING
re_data = ls_items.
IF ls_items-idnlf CS 'test'.
mmpur_message 'E' 'ME' '303' 'text1' 'text2' 'text3' 'text4'.
ch_failed = mmpur_yes.
ENDIF.
ENDLOOP.
ENDIF.
As you can see whenever field IDNLF has the value 'test' a message is triggered. How can I relate this message to a specific field and more important to an item?
Thank you in advance for any help,
Stefan