Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Error Message Using MRM_HEADER_CHECK

Former Member
0 Likes
4,254

Hello All,

I need some help here in this BAdi to validate a field and issue an error message. Documentation clearly says that you can check header and item fields and issue error messages. But I couldn't get this done as I wanted...

I tried all these...

  • MESSAGE w006(ZFI_MESSAGES) WITH 'ERROR' DISPLAY LIKE 'E' RAISING error.

**********************************************************************

  • MESSAGE s006(ZFI_MESSAGES) WITH 'ERROR' DISPLAY LIKE 'E' RAISING error.

**********************************************************************

  • MESSAGE e006(ZFI_MESSAGES) WITH 'ERROR' RAISING error.

  • MESSAGE e006(ZFI_MESSAGES).

**********************************************************************

  • CALL FUNCTION 'POPUP_TO_CONFIRM'

  • EXPORTING

  • titlebar = 'test pop up'

  • text_question = 'test miro: pls enter material group'

  • text_button_1 = 'YES'

  • text_button_2 = 'NO'

  • IMPORTING

  • answer = lv_answer.

  • IF lv_answer EQ 2.

  • EXIT.

  • ENDIF.

Message Type 'E' is locking the screen, that makes sense, but is there any other way to make this work?

What is the use of EXCEPTION 'ERROR'?. How do I make use of it? Do I need to create another exception class and use it here? Please somebody help me.

Thanks,

Shekar

6 REPLIES 6
Read only

naimesh_patel
Active Contributor
0 Likes
2,819

You can raise the unsuccesful check in the BADI implmentation like:


IF SY-SUBRC EQ 0.
  RAISE ERROR.
ENDIF.

Regards,

Naimesh Patel

Read only

0 Likes
2,819

Thaks Naimesh, but I guess I tried that and that is creating a short dump. any other ideas???

Shekar

Read only

0 Likes
2,819

Ok.. Try setting the SY-SUBRC = 1 when your check fails.

Regards,

Naimesh Patel

Read only

0 Likes
2,819

Hi, I have the same problem.

When my validation is incorrect enter the values of my message in the system variables, and execute "raise error". That shows the message I want. But the implementation of the error fires again header_check and there is an infinite loop.

How returning control to MIRO for the user to correct the error?

Thanks and greetings

Read only

Former Member
0 Likes
2,819

Hi

In my situation I use only MRM_PROT_FILL FM to add messages.

METHOD if_ex_mrm_header_check~headerdata_check.


DATA: lt_errprot       type mrm_tab_errprot,
          ls_errprot      like line of lt_errprot.


......

if i_rbkpv-sgtxt eq space.
       clear ls_errprot.
       ls_errprot-msgty = 'E'.
       ls_errprot-msgid = 'ZSTM'.
       ls_errprot-msgno = '008'.
       ls_errprot-source = ' '. -- This line is important
       append ls_errprot to lt_errprot.
     endif.
     if lines( lt_errprot ) gt 0.
       call function 'MRM_PROT_FILL'
         tables
           t_errprot = lt_errprot.
     endif.

endif.


ENDMETHOD.

After user corrected values, error messages are deleted from list.

Read only

2,819

Hi

Previous variant is not fully correct.

If field "source" is filled with space, standart removes this message before post.

Correct variant is:


   clear lt_errprot[].
   call function 'MRM_PROT_INIT'
            EXPORTING
             i_xall   = space
             i_source = 'Z' -- Clear messages with own type
        EXCEPTIONS
             OTHERS = 0.

if i_rbkpv-sgtxt eq space.
       clear ls_errprot.
       ls_errprot-msgty = 'E'.
       ls_errprot-msgid = 'ZSTM'.
       ls_errprot-msgno = '008'.
       ls_errprot-source = 'Z'. -- Use own type of the message
       append ls_errprot to lt_errprot.
endif.
if lines( lt_errprot ) gt 0.
       call function 'MRM_PROT_FILL'
         tables
           t_errprot = lt_errprot.
endif.