‎2009 Sep 14 11:12 AM
Hi,
in MIRO i will use badi: MRM_HEADER_CHECK.
i implementedt it and use in method: IF_EX_MRM_HEADER_CHECK~HEADERDATA_CHECK
this code:
DATA: GT_ERRPROT TYPE TABLE OF MRM_ERRPROT,
GS_ERRPROT TYPE MRM_ERRPROT.
*
APPEND GS_ERRPROT TO GT_ERRPROT.
*
IF NOT I_RBKPV-LIFNR IS INITIAL
AND I_RBKPV-LANDL <> 'DE'
AND I_RBKPV-LZBKZ IS INITIAL.
*
CLEAR GS_ERRPROT.
GS_ERRPROT-MSGTY = 'E'.
GS_ERRPROT-MSGID = 'ZZ'.
GS_ERRPROT-MSGNO = '010'.
GS_ERRPROT-MSGV1 =
'ERROR in LZB'.
*
CALL FUNCTION 'MRM_PROT_FILL'
TABLES
T_ERRPROT = GT_ERRPROT.
*
ENDIF.
*
In MIRO i get the message wich i need, but the user is able to save (post) in MIRO.
How can i avoid saving when i generate the above message?
thanks.
Regards, Dieter
‎2009 Sep 14 11:40 AM
Hi,
check this:
*----------------------------------------------------------------------*
* If there is any error do not allow saving, posting, ....
*----------------------------------------------------------------------*
DATA: gt_errtab TYPE TABLE OF mrm_errprot,
gs_errtab TYPE mrm_errprot.
CONSTANTS: c_errprot(23) TYPE c VALUE '(SAPLMRMF)TAB_ERRPROT[]'.
FIELD-SYMBOLS: <fs_errprotj_dt> TYPE table.
ASSIGN (c_errprot) TO <fs_errprotj_dt>.
REFRESH gt_errtab[].
gt_errtab[] = <fs_errprotj_dt>[].
IF NOT gt_errtab[] IS INITIAL.
READ TABLE gt_errtab INTO gs_errtab WITH KEY msgty = 'E'.
IF sy-subrc = 0.
DATA: c_okqx(17) TYPE c VALUE '(SAPLMR1M)OK-CODE'.
FIELD-SYMBOLS: <fs_okqx> TYPE ANY.
ASSIGN (c_okqx) TO <fs_okqx>.
CASE <fs_okqx>.
WHEN 'COMP' OR 'BU'. "Saving as complete/Post
READ TABLE gt_errtab INTO gs_errtab WITH KEY msgty = 'E'
msgid = 'ZZ' msgno = '010'.
IF sy-subrc = 0.
* delete the ok-code.
CLEAR <fs_okqx>.
MESSAGE s0XX(zxx). "Invoice still has error messages
ENDIF.
ENDCASE.
ENDIF.
ENDIF.
Something more: in your code you should clear the message if the condition is not met (that is, the user has done something in the transaction to correct the condition producing the message).
DATA: GT_ERRPROT TYPE TABLE OF MRM_ERRPROT,
GS_ERRPROT TYPE MRM_ERRPROT.
*
APPEND GS_ERRPROT TO GT_ERRPROT.
*
IF NOT I_RBKPV-LIFNR IS INITIAL
AND I_RBKPV-LANDL 'DE'
AND I_RBKPV-LZBKZ IS INITIAL.
*
CLEAR GS_ERRPROT.
GS_ERRPROT-MSGTY = 'E'.
GS_ERRPROT-MSGID = 'ZZ'.
GS_ERRPROT-MSGNO = '010'.
GS_ERRPROT-MSGV1 =
'ERROR in LZB'.
*
CALL FUNCTION 'MRM_PROT_FILL'
TABLES
T_ERRPROT = GT_ERRPROT.
ELSE.
* This is the code added
FIELD-SYMBOLS: <fs_errprot> TYPE table.
ASSIGN (c_errprot) TO <fs_errprot>.
REFRESH gt_errtab[].
gt_errtab[] = <fs_errprot>[].
LOOP AT gt_errtab INTO gs_errtab
WHERE msgty = 'E'
AND msgid = 'ZXX'
AND msgno = '010'.
DELETE gt_errtab INDEX sy-tabix.
ENDLOOP.
<fs_errprot>[] = gt_errtab[].
*
ENDIF.
Best regards.
Edited by: Pablo Casamayor on Sep 14, 2009 12:55 PM
‎2009 Sep 14 1:38 PM
Hi Pablo,
thanks for your answer. I do it in this way:
DATA: GT_ERRPROT TYPE TABLE OF MRM_ERRPROT,
GS_ERRPROT TYPE MRM_ERRPROT.
*
DATA: I_OKCODE(17) TYPE C VALUE '(SAPLMR1M)OK-CODE'.
FIELD-SYMBOLS: <FS_OKCODE> TYPE ANY.
ASSIGN (I_OKCODE) TO <FS_OKCODE>.
*
IF NOT I_RBKPV-LIFNR IS INITIAL
AND I_RBKPV-LANDL <> 'DE'
AND I_RBKPV-LZBKZ IS INITIAL.
*
CLEAR GS_ERRPROT.
GS_ERRPROT-MSGTY = 'E'.
GS_ERRPROT-MSGID = 'ZZ'.
GS_ERRPROT-MSGNO = '010'.
GS_ERRPROT-MSGV1 =
'Ausl. Lieferanten erfordern ein LZB-Kennzeichen'.
*
APPEND GS_ERRPROT TO GT_ERRPROT.
*
CALL FUNCTION 'MRM_PROT_FILL'
TABLES
T_ERRPROT = GT_ERRPROT.
*
CASE <FS_OKCODE>.
WHEN 'BU' OR 'PB' OR 'COMP'. "Buchen oder Simulieren
CLEAR <FS_OKCODE>.
MESSAGE S010(ZZ) WITH 'Es sind noch Fehler in der Buchung'.
ENDCASE.
*
ENDIF.
Do you think, that i can also use BADI: INVOICE_UPDATE, it's a newer BADI.
Regards, Dieter
‎2009 Sep 14 1:45 PM
Hi,
yes you can use badi INVOICE_UPDATE as well.
Just bear in mind that INVOICE_UPDATE will be triggered before MRM_HEADER_CHECK.
I´ve used INVOICE_UPDATE to send a message and MRM_HEADER_CHECK to receive it and act accordingly (usually if the message was found i cleared the ok-code and stopped the flow of the program until the error was fixed).
In a few words:
INVOICE_UPDATE -> just send the message here
MRM_HEADER_CHECK -> look for the message and if it is found do something (e.g. clear ok-code)
Best regards.
Edited by: Pablo Casamayor on Sep 14, 2009 2:46 PM
‎2009 Nov 23 8:22 AM