Hi all
I have a question about the PO message .
In PO badi IF_EX_ME_PROCESS_PO_CUST~PROCESS_HEADER
I want to delete custom error message but not delete SAP standard error message .
And now my solution is
LOOP AT TL_MEPOITEM INTO WL_MEPOITEM
WHERE LOEKZ IS INITIAL.
MMPUR_BUSINESS_OBJ_ID WL_MEPOITEM-ID. " get the object ID
MMPUR_REMOVE_MSG_BY_CONTEXT WL_MEPOITEM-ID 5. " delete the error message
ENDLOOP.
......................................
IF Custion error
MMPUR_BUSINESS_OBJ_ID WL_MEPOHEADER-ID.
MMPUR_MESSAGE_FORCED 'E' 'Zxxxxxx '999' VG_MESSAGE
endif.
But now the macro "MMPUR_REMOVE_MSG_BY_CONTEXT " delete the custom and SAP standard message togethor.
My question how can I just delete custom messge but not delete the SAP standard message.
Hi, thanks for you, I hope so.
Anyone can help me to answer this question, thanks~~
Hi
Don't semd the custom message: I mean if you don't need custom message why you trigger it?
Max
Hi my mean is :
when PO has custom message, it will display in PO screen, when it be corrected, by the [MMPUR_REMOVE_MSG_BY_CONTEXT] in BADI , the custom message will be deleted and not display in PO screen. but then the [MMPUR_REMOVE_MSG_BY_CONTEXT] in BADI delete the SAP standard message at the same time.
I want to know whether the [MMPUR_REMOVE_MSG_BY_CONTEXT] can delete custom message only but not delete the SAP standard message.
SAP will usually send multiple messages, a kind of hierarchical messages, where the most detailed is the last.
In many cases, if this last message is solved all other error message will disappear as well.
Could you please provide an example, then I may be able to tell you if it is okay that the other messages disappear.
I would as well expect that SAP is doing its checks again and just issue this message pop-up if you still have error situations.
Hi thanks for your replay.
For the question, like the following example.
1. When i create a PO , in the invoice tab, the ERS has been checked but the TAX code is empty ,then standard SAP error [In case of evaluated receipt settlement, please enter tax code] occurs.
2. At the same time , another custom error message occurs. by the following program, we can send the custom to error box in PO screen.
MMPUR_BUSINESS_OBJ_ID WL_MEPOHEADER-ID.
MMPUR_MESSAGE_FORCED 'E' 'Zxxxxxx '999' VG_MESSAGE
3. When user correct the PO custom error , then the following code can delete the custom message.but the following code also delete the SAP standard error message
MMPUR_BUSINESS_OBJ_ID WL_MEPOITEM-ID. " get the object ID
MMPUR_REMOVE_MSG_BY_CONTEXT WL_MEPOITEM-ID 5. " delete the error message
4. I want to know whether the program can only delete custom error message ,do not delete the SAP standard message.
Hi anybody can help me ~~~`
Hi
I've tried to check the abap code of those macro and it seems the classes used here haven't a method to delete a single message.
Max
Hi Zhong,
The Macros should not have been used. You should have used the method Invalidate() to raise your custom messages.
The below code snippet is an example. - This is used in Item processing, its the same for header too. So in place of Im_item you would use im_header.
IF lwa_item-eindt LT lwa_header-bedat AND lwa_item-loekz IS INITIAL."no Deletion set. im_item->invalidate( ). WRITE lwa_header-bedat TO l_hdate MM/DD/YYYY. WRITE lwa_item-eindt TO l_idate MM/DD/YYYY. MESSAGE e027(zmm) WITH l_idate l_hdate lwa_item-ebelp . ENDIF.
So this ensures that the SAP system automatically deletes the custom messages whenever they are fixed .
I hope this helps.
Thanks,
Venkat.
Message was edited by: Venkat Gowrishankar
Ok,
I made a mistake in my statement. You should infact use the Macro's to post the message. But still, you have to call the invalidate() method , if you want your messages to be deleted. Below is my adjusted code. The code checks if an Items's delivery date is lesser than the document header date and throws and error. Once the user enters the correct date, the error is removed.
TYPE-POOLS: mmmfd. INCLUDE mm_messages_mac. DATA : lwa_item TYPE mepoitem, lwa_header TYPE mepoheader, l_hdate TYPE char10, l_idate TYPE char10, lr_header TYPE REF TO if_purchase_order_mm. lr_header ?= im_item->get_header( ). lwa_header = lr_header->get_data( ). lwa_item = im_item->get_data( ). IF lwa_item-eindt LT lwa_header-bedat AND lwa_item-loekz IS INITIAL."no Deletion set. im_item->invalidate( ). WRITE lwa_header-bedat TO l_hdate MM/DD/YYYY. WRITE lwa_item-eindt TO l_idate MM/DD/YYYY. mmpur_metafield mmmfd_item_number. mmpur_message_forced 'E' 'ZMM' '027' l_idate l_hdate lwa_item-ebelp ''. ENDIF.
Here is the documentation on Error Handlng within the BADI.
If you wish to do this when implementing your own checks, use the following
macros:
- mmpur_metafield
This macro links the metafield with the message
generated with the subsequent macro mmpur_message_forced (see below). A list of
the known metafields can be found in the type group MMMFD. This also contains
some definitions for customer enhancements (MMMFD_CUST_01 to
MMMFD_CUST_10).
Metafields also have an important function in error handling. They establish
the connection between a message and the business content.
Example
You can control the positioning of the cursor during the
processing of messages.
- mmpur_message_forced
You use this macro to generate the actual
message. The message is linked to the known business object (e.g. document
header, document item) and the previously specified metafield. The macro
requires exactly sevem parameters: message category (I,W,E), message class,
message number and the four message parameters. (See also the ABAP message
statement).
Further notes
- The above-mentioned macros are defined in the program MM_MESSAGES_MAC.
Please include this program in your own application.
- Never issue messages in BAdI ME_GUI_PO_CUST! This is the task of the
business logic and must therefore be done via the BAdI
ME_PROCESS_PO_CUST.
- Never use the ABAP statement MESSAGE in the BAdI ME_PROCESS_PO_CUST.
Please use the macro mmpur_message_forced only. This macro only writes a message
in the message collector.
If you wish to mark the business object as invalid
in order to prevent posting, you must additionally use the INVALIDATE ( ) method
of the relevant interface. In this connection, see also the code example in the
PROCESS_ITEM method of the BAdI ME_PROCESS_PO_CUST.
I Hope this helps.
Have a look at example class CL_EXM_IM_ME_PROCESS_PO_CUST and specifically method process_item( ) for error handling.
Once again, I am sorry for the misleading information in my prev. post.
Thanks,
Venkat.
Message was edited by: Venkat Gowrishankar
Dear Venkat Gowrishankar
Thanks for your reply. I tested your method, it works well for custom error message which caused by SAP standard field in PO. but can't work for custom error message whick caused by custom field.( field name ZXXXXX).
my code is:
if zxxxxx = 'x'.
MMPUR_BUSINESS_OBJ_ID WL_MEPOITEMS-ID.
WL_ITEMS-ITEM->invalidate( ).
mmpur_metafield mmmfd_item_number.
MMPUR_MESSAGE_FORCED 'E' 'Z0001' '004' '' '' '' ''.
endif.
how can i make custom field have same action with SAP standard field.
Hi Zhong,
Could you please answer these questions.
1. Is the valdiation at the item or header level?.
2. Once there is an error, do you need to highlight the custom field where the error had occured? or highlighting a Std SAP field such as item number?.
If you need to highlight a custom field, then there are few more sequence of steps, you may have to implement BADI 'ME_GUI_PO_CUST' where you do the mapping between the custom field and the corresponding meta field. This would ensure that the custom field is highlighted whenever there is an issue.
Could you please try removing these macros ' MMPUR_BUSINESS_OBJ_ID WL_MEPOITEMS-ID. ' and 'mmpur_metafield mmmfd_item_number' from your code and let me know if the issue still persists.
If possible attach a few screenshots.
Thanks,
Venkat.
Thanks for your reply, now my code is :
IF WL_MEPOHEADER-ZZ0001 = 'X'.
TL_ITEM = IM_HEADER->GET_ITEMS( ).
LOOP AT TL_ITEM INTO WL_ITEMS.
WL_MEPOITEMS = WL_ITEMS-ITEM->GET_DATA( ).
IF ( WL_MEPOITEMS-MEPRF = '5' OR
WL_MEPOITEMS-MEPRF = '2' )
WL_MEPOITEMS-LOEKZ IS INITIAL.
WL_ITEMS-ITEM->invalidate( ).
MMPUR_MESSAGE_FORCED 'E' 'Z0001' '001' '' '' '' ''.
ENDIF.
ENDLOOP.
ENDIF.
and the fied ZZ0001 is a custom field in PO header and MEPRF is std field in item.
Now, according the code, when there is error msg [ 'E' 'Z0001' '001' '' '' '' ''.]
when I correct the error in item field MEPRF, then the error msg be removed automatically,
but when i correct the error in item filed zz0001(custom field in PO header), the error msg be removed automatically, but a error msg 'Purchase order still contains fautly items' still display , can't be removed.
Maybe i need a code just like WL_Header-Header->invalidate( ). , but i don't know how to write it.
Hi Zhong,
I think you may need to implement the BADI ME_GUI_PO_CUST and especially the method SUBSCRIBE. Does not seem to be complicated, you need to pass some basic details such as the screen number, header or item and so on. Have a look at the example class CL_EXM_IM_ME_GUI_PO_CUST . I hope this solves the issue. Here is the documentation on the SUBSCRIBE method, it seems that this method will enable your sub screen to be a part of transaction processing.
Publisch Customer's Own Screens
Functionality
The SUBSCRIBE method of the Business Add-In ME_GUI_PO_CUST enables you to
make your own screens known to the transaction control facility.
Parameters
The following parameters are available:
- IM_APPLICATION - Application
Note
Since this enhancement is currently only available for the Enjoy purchase order, the value of the parameter IM_APPLICATION is always 'PO'.
- IM_ELEMENT - Screen area
Possible values for this parameter are
'HEADER' for the PO header and 'ITEM' for the item details.
- RE_SUBSCRIBERS
You must populate this table in your
implementation.
Each entry in this table stands for a customer's own
subscreen:
- RE_SUBSCRIBERS-NAME - Name of subscreen
This name is used by other
methods to uniquely identify a subscreen.
- RE_SUBSCRIBERS-DYNPRO - Dynpro (screen) number
- RE_SUBSCRIBERS-PROGRAM - Main program in which the dynpro
lies
- RE_SUBSCRIBERS-STRUCT_NAME - DDIC structure of dynpro output
area
- RE_SUBSCRIBERS-LABEL - Tabstrip label
- RE_SUBSCRIBERS-POSITION - Item within the tabstrip
- RE_SUBSCRIBERS-HEIGHT - Size of subscreen
Notes
Under no circumstances make any changes to the database within this method
Hope this helps,
Thanks,
Venkat.
Message was edited by: Venkat Gowrishankar
I have checked the code, and I have implement the BADI ME_GUI_PO_CUST,SUBSCRIBE for all field.
and the error message 'Purchase order still contains fautly items' still display.
did you have other advices..... thank you very much.