18 Replies Latest reply: Sep 23, 2013 2:57 PM by Raymond Giuseppi RSS

How to delete custom error message but not delete SAP standard error message in PO badi IF_EX_ME_PROCESS_PO_CUST

Zhong Jie
Currently Being Moderated

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.

  • Re: How to delete custom error message but not delete SAP standard error message in PO badi IF_EX_ME_PROCESS_PO_CUST
    Jürgen L
    Currently Being Moderated

    I think ABAPer can help better in programming issues than application specialists in MM.

     

    discussion moved to

    ABAP Development

    • Re: How to delete custom error message but not delete SAP standard error message in PO badi IF_EX_ME_PROCESS_PO_CUST
      max bianchi
      Currently Being Moderated

      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

    • Re: How to delete custom error message but not delete SAP standard error message in PO badi IF_EX_ME_PROCESS_PO_CUST
      Venkat Gowrishankar
      Currently Being Moderated

      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

      • Re: How to delete custom error message but not delete SAP standard error message in PO badi IF_EX_ME_PROCESS_PO_CUST
        Venkat Gowrishankar
        Currently Being Moderated

        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

        • Re: How to delete custom error message but not delete SAP standard error message in PO badi IF_EX_ME_PROCESS_PO_CUST
          Zhong Jie
          Currently Being Moderated

          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.

          • Re: How to delete custom error message but not delete SAP standard error message in PO badi IF_EX_ME_PROCESS_PO_CUST
            Venkat Gowrishankar
            Currently Being Moderated

            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.

            • Re: How to delete custom error message but not delete SAP standard error message in PO badi IF_EX_ME_PROCESS_PO_CUST
              Zhong Jie
              Currently Being Moderated

              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.

              • Re: How to delete custom error message but not delete SAP standard error message in PO badi IF_EX_ME_PROCESS_PO_CUST
                Venkat Gowrishankar
                Currently Being Moderated

                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

                • Re: How to delete custom error message but not delete SAP standard error message in PO badi IF_EX_ME_PROCESS_PO_CUST
                  Zhong Jie
                  Currently Being Moderated

                  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.

                  • Re: How to delete custom error message but not delete SAP standard error message in PO badi IF_EX_ME_PROCESS_PO_CUST
                    Yaj Olrac
                    Currently Being Moderated

                    hi Zhong and Venkat,

                     

                             This question might be too late since this dicussion is last year but if ever you still will be able to read this or to whoever may have read this, i'm facing the same problem (probably worse). I have implemented ME_GUI_PO_CUST in item level and fields are working fine up to saving into table. my problem is i'm issuing multiple messages in  one line item(material). i'm able to issue error messages and remove them when i'm using just one line item, but when it comes to 2 line items or more, i'm encountering an abap dump in remove method of cl_message_handler_mm.

                     

                    to issue a message, here's my code:

                     

                    CLEAR lv_msg_dummy.

                               MESSAGE e072(zz) WITH 'Please provide file path for TA Doc No.' INTO lv_msg_dummy.

                               mmpur_message_forced sy-msgty sy-msgid sy-msgno

                                                    sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

                     

                               lv_invalid_flag = 'X'.

                     

                     

                    to remove a message, here's my code:

                     

                    CALL METHOD cl_message_handler_mm=>get_handler

                             IMPORTING

                               ex_handler = r_msg_handler_mm.

                     

                    *    r_msg_handler_mm = cl_message_handler_mm=>get_handler( ).

                     

                           CALL METHOD r_msg_handler_mm->getlist

                             IMPORTING

                               ex_events = gt_event_list

                               ex_evnt   = gt_event.

                     

                    LOOP AT gt_event_list INTO gs_event_list WHERE signature CS 'providefilepath'.

                               CLEAR r_event.

                               r_event = gs_event_list-event_obj.

                               CALL METHOD r_msg_handler_mm->remove

                                 EXPORTING

                                   im_event_obj = r_event.

                    ENDLOOP.

                     

                    now is there any other way to remove msg in item level so i will not encounter a dump when i'm using 2 materials or more in creating a PO?

  • Re: How to delete custom error message but not delete SAP standard error message in PO badi IF_EX_ME_PROCESS_PO_CUST
    Raymond Giuseppi
    Currently Being Moderated

    A proposal for your request :

    In your implementation, force the "context" of messages at start of methods, then remove messages of this context

     

    Code at start of methods like IF_EX_ME_PROCESS_PO_CUST~PROCESS_ITEM or PROCESS_HEADER

    * item
    mmpur_context mmcnt_context_badi.
    ls_item = im_item->get_data( ).
    IF NOT ls_item-id IS INITIAL AND im_item->is_valid( ) EQ mmpur_yes.
      mmpur_remove_msg_by_context ls_item-id mmcnt_context_badi.
    ENDIF.
    * header
    mmpur_context mmcnt_context_badi.
    ls_header = im_header->get_data( ).
    IF NOT ls_header-id IS INITIAL AND im_header->is_valid( ) EQ mmpur_yes.
      mmpur_remove_msg_by_context ls_header-id mmcnt_context_badi.
    ENDIF.

     

    Regards,

    Raymond

Actions