Application Development 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: 

Error message issued using BADI MRM_HEADER_CHECK appears more than once

Former Member
0 Kudos


hi,

I have used the BADI MRM_HEADER_CHECK to display an error/warning message in MIRO t-code.

I am able to issue it but the message appears more more than once (every time it returns to the posting screen). What can be done to avoid it ?

Below is the code -

   * Types for internal table
  TYPES:
    BEGIN OF tp_bankn,
      bankn type lfbk-bankn,
    END OF tp_bankn.

* Internal Tables to hold the data
  DATA:
    it_bankn TYPE TABLE OF tp_bankn.

* variable to keep the count
  DATA:
    lv_count type i.
  refresh it_bankn.
  clear:
    it_bankn,
    lv_count.

** Begin of logic implementation
  If not I_RBKPV-lifnr is INITIAL.

*select a/c details from lfbk table
    SELECT BANKN
      FROM lfbk
      INTO TABLE it_bankn
     WHERE lifnr EQ I_RBKPV-lifnr.
*getting count of bank a/c
    DESCRIBE TABLE it_bankn LINES lv_count.

* When the user has more than one bank a/c
* Pop up will appear with message "More than one bank account exist for the vendor"

    If lv_count GT 1.
      MESSAGE I031(ZF).
    ENDIF.
  ENDIF.
** End of logic implementation

1 ACCEPTED SOLUTION

former_member182371
Active Contributor

Hi,

maybe this thread can help you:

Tcode MIRO with BADI: MRM_HEADER_CHECK

Best regards.

16 REPLIES 16

Former Member
0 Kudos

Hi Rashmi,

You are not supposed to put messages directly in BADI.. There is an exception added...

The correct way is mentioned in the clog below use the code to achieve the same.

Regards

nabheetscn
Active Contributor
0 Kudos

In case you want to issue it only on save then you can put a check of sy-ucomm

Nabheet

former_member182371
Active Contributor

Hi,

maybe this thread can help you:

Tcode MIRO with BADI: MRM_HEADER_CHECK

Best regards.

0 Kudos

Hi Pablo,

Thanks for quick response.

This so;ution does not seem to help.

My requirement is to display the error message if the vendor has more than one account.

Since the vendor number will stay same during posting, the message is displayed everytime the user comes to posting screen. Is there a way by which i can restrict the message to be displayed only one time ?

Thanks,

Rashmi

0 Kudos

Hi,

you could set a flag, e.g.:

    IF lv_count GT 1 AND l_flag IS INITIAL.

       l_flag = 'X'.

      MESSAGE I031(ZF).

    ENDIF.


Best regards.

0 Kudos

Rashmi

You can put a sy-ucomm check as SAVE or BU then only when user will press save then only it wil work else not

Nabheet

0 Kudos

i tried using flags as well, but it intializes the flag every time as first so the if condition is always met!

Is there a way i can store the value in the flag after the message is issued once which is retained after screen change ? i mean some persistant way ? may be by import/export or something ?

Thanks alot for your help here

0 Kudos

just declare the flag as

static:lv_flag type c. it will store the value

0 Kudos

hi nabheet,

Thanks for the reply

Actually the problem is the message needs to be displayed at posting screen before saving.

The requirement is - if the vendor has more than one bank account, display the message so that the user is aware of more than one account and choose the corect one.

So, after the mesage as soon as the user goes to they payment tab to select the account and comes back to the posting screen the message appears again.

so even if i make it to issue at save , same thing will happen at the time of saving!

Is there a we restrict it for displaying the message only once for one vendor?

0 Kudos

yes delcare your variable as static then it wont display again.

as mentioned above.

Statics:lv_flag type c.

if lv_flag is initial.

message

lv_flag = X.

Endif.

0 Kudos

nabheet

i tried using this statement , it gives error as static statement may not be used in instance methods!

0 Kudos

Hi,

could you try with a status message instead of an information message?

or even this:

MESSAGE e031(ZF) WITH 'xxx'

                     RAISING error_with_message.

Best regards.

Message was edited by: Pablo Casamayor

ooops i forgot:)

there are two ways now.

  1. you set lv_flag as 'x'.

        import lv_flag to lv_flag from memory id 'ZABC'.

         if lv_flag is initial.

          message.

          lv_flag = 'X'.

export lv_flag from lv_flag to memory id 'ZABC'.

        endif.

2. in your implemnting class add a static attribute and set it inside you code it will work in same as told ealier.

Nabheet

0 Kudos

Thanks nabheet but statics statement is nt allowed here since it is instannce method.

Please let me knw if any other option is possible.

Thanks & Regards

0 Kudos

ooops i forgot:)

there are two ways now.

  1. you set lv_flag as 'x'.

        import lv_flag to lv_flag from memory id 'ZABC'.

         if lv_flag is initial.

          message.

          lv_flag = 'X'.

export lv_flag from lv_flag to memory id 'ZABC'.

        endif.

2. in your implemnting class add a static attribute and set it inside you code it will work in same as told ealier.

Nabheet

Thanks for your help nabheet i used import/export to soleve this.