2013 Dec 11 12:34 PM
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
2013 Dec 11 12:49 PM
2013 Dec 11 12:45 PM
2013 Dec 11 12:49 PM
In case you want to issue it only on save then you can put a check of sy-ucomm
Nabheet
2013 Dec 11 12:49 PM
2013 Dec 12 9:05 AM
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
2013 Dec 12 9:10 AM
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.
2013 Dec 12 9:13 AM
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
2013 Dec 12 9:17 AM
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
2013 Dec 12 9:18 AM
just declare the flag as
static:lv_flag type c. it will store the value
2013 Dec 12 9:24 AM
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?
2013 Dec 12 9:26 AM
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.
2013 Dec 12 9:30 AM
nabheet
i tried using this statement , it gives error as static statement may not be used in instance methods!
2013 Dec 12 9:35 AM
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
2013 Dec 12 9:36 AM
ooops i forgot:)
there are two ways now.
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
2013 Dec 12 9:37 AM
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
2013 Dec 12 9:42 AM
ooops i forgot:)
there are two ways now.
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
2013 Dec 12 10:29 AM
Thanks for your help nabheet i used import/export to soleve this.