2009 May 27 10:27 AM
Hi,
We have a requirement where we need to give a warning message when an invoice document is parked in case if it is a One time vendor and bank details are missing. It should be an error message if user is trying to save it as completed or posting the document. We have already found a BADI INVOICE_UPDATE method CHANGE_AT_SAVE for giving error / warning message but we also want the same to be appeared in the popup coming when we press Messages button in MIR4 screen same way as standard messages are shown. I know that there is a table T_ERRPROT which need to be populated in order to show the messages in the popup window but could not find any appropriate user exit or badi to populate this table. Any suggestion or solutions are welcomed.
Thanks and Regards,
Jaideep,
2009 May 27 11:50 AM
Hi,
Check this FM
DISPLAY MESSAGE TROUGH CALL FUNCTION:-
CALL FUNCTION 'MB_EDIT_MESSAGE'
EXPORTING
T1 = MR21HEAD-WERKS
T2 = MBEW-BWTAR
T3 = 'does not exist in table'
T4 = 'MBEW'
* T5 = ' '
* T6 = ' '
* T7 =
* T8 = ' '
* NOULINE = ' '
IMPORTING
MESSAGE = message_text.
message id 'CKPRCH' type 'I' number '064' with message_text.
Message class: u2018CKRPCHu2019
Message number: 064
Message : Entry &1 &2 &3 &4 (check entry)
Regards,
Nikhil.
2009 May 27 11:03 AM
2009 May 27 11:41 AM
Hi,
I know this fm but my question is how can we populate t_errprot parameter with our own error messages alongwith the one which system populates.
KR Jaideep,
2009 May 27 11:47 AM
Hi,
you can populate t_errprot thus:
DATA: gt_errtab TYPE TABLE OF mrm_errprot,
gs_errtab TYPE mrm_errprot.
CLEAR gs_errtab.
gs_errtab-msgty = 'E'.
gs_errtab-msgid = 'ZXX'.
gs_errtab-msgno = '030'.
gs_errtab-source = 'Q'.
APPEND gs_errtab TO gt_errtab.
CALL FUNCTION 'MRM_PROT_FILL'
TABLES
t_errprot = gt_errtab.
Best regards.
2009 May 27 11:50 AM
Hi,
Check this FM
DISPLAY MESSAGE TROUGH CALL FUNCTION:-
CALL FUNCTION 'MB_EDIT_MESSAGE'
EXPORTING
T1 = MR21HEAD-WERKS
T2 = MBEW-BWTAR
T3 = 'does not exist in table'
T4 = 'MBEW'
* T5 = ' '
* T6 = ' '
* T7 =
* T8 = ' '
* NOULINE = ' '
IMPORTING
MESSAGE = message_text.
message id 'CKPRCH' type 'I' number '064' with message_text.
Message class: u2018CKRPCHu2019
Message number: 064
Message : Entry &1 &2 &3 &4 (check entry)
Regards,
Nikhil.
2009 May 27 12:59 PM
Hi,
Thanks alot for your replies. Now the error message is coming in the popup. But when I post the document then it gets posted. I want the document to be in parked status and not posted in case there are any error messages in the document.
KR Jaideep,
2009 May 27 1:46 PM
Hi,
1.- Implement badi MRM_HEADER_CHECK
2.- in this badi do:
*----------------------------------------------------------------------*
* If there is any error do not allow 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 'BU'. "POST
* This is optional: you can either search for a particular message or
* do not allow any error message
* Here search for the message triggered in badi INVOICE UPDATE
READ TABLE gt_errtab INTO gs_errtab WITH KEY msgty = 'E'
msgid = 'ZXX' msgno = '030'.
IF sy-subrc = 0.
CLEAR <fs_okqx>.
MESSAGE s030(zxx). "While errors exist document will not be posted
ENDIF.
ENDCASE.
ENDIF.
ENDIF.
Best regards.
Edited by: Pablo Casamayor on May 27, 2009 3:05 PM
2009 Jun 02 4:11 PM
Hi Pablo,
I am still having issues with the posting of document. When I am trying to post the document without bank details from transaction MIRO then system do not allow me to post the document as expected.
If I park the document and then open it using MIR4 and post it directly then system allow the posting of document even if the bank details are missing for one time vendor.
Please find the code below.
<< Please only post the relevant portions of the code >>
Edited by: Rob Burbank on Jun 2, 2009 11:25 AM
2009 Jun 02 5:37 PM
Hi,
in badi HEADERDATA_CHECK you have available as input parameter I_RBKPV.
do something like:
*----------------------------------------------------------------------*
* If there is any error do not allow 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>[].
DATA: c_okqx(17) TYPE c VALUE '(SAPLMR1M)OK-CODE'.
FIELD-SYMBOLS: <fs_okqx> TYPE ANY.
ASSIGN (c_okqx) TO <fs_okqx>.
IF NOT gt_errtab[] IS INITIAL.
READ TABLE gt_errtab INTO gs_errtab WITH KEY msgty = 'E'.
IF sy-subrc = 0.
CASE <fs_okqx>.
WHEN 'BU'. "POST
* This is optional: you can either search for a particular message or
* do not allow any error message
* Here search for the message triggered in badi INVOICE UPDATE
READ TABLE gt_errtab INTO gs_errtab WITH KEY msgty = 'E'
msgid = 'ZXX' msgno = '030'.
IF sy-subrc = 0.
CLEAR <fs_okqx>.
MESSAGE s030(zxx). "While errors exist document will not be posted
ENDIF.
ENDCASE.
ENDIF.
ELSE. "THIS IS THE NEW PART
IF i_rbkpv-YOURBANKFIELD IS INITIAL. "This is the New part
CASE <fs_okqx>.
WHEN 'BU'. "POST
CLEAR <fs_okqx>.
MESSAGE s031(zxx). "Please fill in bank details
ENDCASE.
ENDIF.
ENDIF.
Best regards.
Edited by: Pablo Casamayor on Jun 2, 2009 6:39 PM