Skip to Content
author's profile photo Former Member
Former Member

Error message in BaDi


Hello,

I am using BADi : ZME_PROCESS_PO_CUST~POST, to check if PO creater and PO release(ME29N) person are going to be same. ITs working correctly - but i am not able to throw the error message. Tried various options from SDN, nothing works.

When debugging - it goes to message - but the message is not getting displayed and PR is getting released.

DATA: lv_ernam TYPE ekko-ernam.
IF sy-tcode = 'ME29N'.
SELECT SINGLE ernam INTO lv_ernam FROM ekko
WHERE ebeln = im_ebeln.
IF lv_ernam = sy-uname.
* MESSAGE e000(0k) WITH 'User is not authorized to Release Purchase Order'.
* MESSAGE w000(00) with 'User is not authorized to Release Purchase Order' DISPLAY LIKE 'E'.
* MESSAGE E118(ZMES)." display like 'E'.
* MESSAGE ID 'ZMES' TYPE 'E' NUMBER '118' WITH 'User is not authorized to Release Purchase Order'.
MESSAGE e398(00) WITH ' User is not authorized to Release Purchase Order' .
mmpur_message_forced 'E' 'ME' '118'


ENDIF.

Thanks

Senthil

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • author's profile photo Former Member
    Former Member
    Posted on May 13, 2014 at 01:48 PM

    Hi Senthil,

    don't make validations in POST method, you have CHECK method available for it.

    you can present your message and you can set the error flag like this:

    IF lv_ernam = sy-uname.

    ch_failed = abap_true.

    MESSAGE e398(00) WITH ' User is not authorized to Release Purchase Order' .

    ENDIF.

    You also have parameters:

    IM_HOLD

    IM_PARK

    that allow you to know if user is posting document or not.

    that's it, don't use macro mmpur_message_forced!

    regards,

    Edgar Soares

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi all,


      This works.


      DATA: l_released TYPE mmpur_bool,

      ls_data TYPE mepoheader,

      lr_header TYPE REF TO cl_po_header_handle_mm.

      IF sy-tcode = 'ME29N'.

      lr_header ?= im_header.

      CALL METHOD lr_header->if_release_state_mm~is_released

      RECEIVING

      re_released = l_released.

      IF l_released IS INITIAL.

      CALL METHOD lr_header->get_data

      IMPORTING

      ex_data = ls_data

      EXCEPTIONS

      failure = 1

      OTHERS = 2.

      IF sy-subrc = 0.

      IF sy-uname NE ls_data-ernam.

      ch_failed = abap_true.

      mmpur_message_forced 'E' 'ME' '118' '' '' '' ''.

      ENDIF.

      ENDIF.

      ENDIF.

      ENDIF.

  • Posted on May 14, 2014 at 07:31 AM

    Dear Senthil,

    Use 'Message id 'ZMSGS' type 'E' number 'I999' with 'Invalid Order No'.' and here ZMSGS is the message class where you define the 999 or any number message text.


    I thiink we cannot use Message Id in Post method, you can use Check method, where you can use
    mmpur_message_forced 'E' 'ME' '303' text-002 'Enter Account Assingment category = I' '' ''. to display your message as in grid.


    Many Thanks / Himanshu Gupta

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 13, 2014 at 12:15 PM

    Hi Senthil,

    Please try below code with include.

    INCLUDE mm_messages_mac.

    DATA: lv_ernam TYPE ekko-ernam.
    IF sy-tcode = 'ME29N'.
    SELECT SINGLE ernam INTO lv_ernam FROM ekko
    WHERE ebeln = im_ebeln.
    IF lv_ernam = sy-uname.

    mmpur_message_forced 'E' 'ME' '118' '' '' '' ''.


    ENDIF.

    Regards,

    Prasenjit

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 13, 2014 at 12:15 PM

    Hi Senthil -

    1. Use the method - CHECK.

    2. Please include the macro -

    INCLUDE mm_messages_mac.

    3. To raise the errror, please use following syntax.

    mmpur_message 'E' < message class>
    <message no>
    < parameter 1>'

    < parameter 2>

    < parameter 3>

    < parameter 4>.

    Hope it helps you.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 13, 2014 at 01:12 PM

    Hi Senthil,

    Can you try like this -

    MESSAGE s398(00) WITH ' User is not authorized to Release Purchase Order'

    DISLPLAY LIKE 'E'.

    Cheers,

    Varun Sahu

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 13, 2014 at 01:16 PM

    Hi Senthil,

    After message use LEAVE LIST-PROCESSING or you can also try LEAVE TO CURRENT TRANSACTION. I am sure it will work.

    For example:

    IF lv_ernam = sy-uname.
    MESSAGE e398(00) WITH ' User is not authorized to Release Purchase Order' .
    mmpur_message_forced 'E' 'ME' '118'

    LEAVE LIST-PROCESSING.
    ENDIF.

    Regards,

    Jyoti Singh

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 13, 2014 at 01:47 PM

    Three corrections to apply to your code

    • Use macro mmpur_message_forced (as Prasenjit Mishra already wrote)
    • Don't read from database, but use im_header->get_data( ) to get current header information and im_header->get_persistent_data( ) to get information from database before transaction execution.
    • Don't use method POST (executed too late, always read BAdI documentation) but rather use method CHECK

    Regards,

    Raymond

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 15, 2014 at 08:57 AM

    This message was moderated.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.