User Exit for MIRO Tr.code in SAP QM

Which user exit or BADI should I use to restrict MIRO for Rejected / QI stock?
Requirement:
Presently MIRO is possible immediately after GRN for any item, while we would like to make restriction; till material is under quality test or it got rejected after quality test, MIRO will not be possible.

User Exit for MIRO Tr.code

Following requirements are checked with this user exit.

a) Checks business place & section code; if they are empty then give error message.

b) If GRN is reversed, Invoice verification is not allowed.

c) For quality activated material, Quality result & user decision is not recorded & user is trying to book invoice verification through MIRO then error message will be issued.

d) If Inspection lot is rejected in QM, then the system will issue error message when user books the invoice verification against GRN. 

Attributes of Enhancement Project

Function Builder EXIT_SAPLMRMP_010

*&---------------------------------------------------------------------*
*&  Include           ZXM08U16
*&---------------------------------------------------------------------*

tables : qave, mseg.

DATA: H_RBWT1 TYPE MRM_RBWT OCCURS 0 WITH HEADER LINE,
  MBLNR LIKE MSEG-MBLNR,
  PRUEFLOS LIKE QAMB-PRUEFLOS,
  BWART LIKE MSEG-BWART,
  ZEILE LIKE MSEG-ZEILE,
  COUNT TYPE I VALUE 0,
  LIN TYPE I,
  BSART LIKE EKKO-BSART.

******** checking if business place is empty then give error message
if E_TRBKPV-BUPLA eq space.
  MESSAGE E017(MD) .
endif.

****************************
if E_TRBKPV-SECCO eq space.
  MESSAGE E018(MD) .
endif.
****************************

DESCRIBE TABLE e_tdrseg LINES lin.

LOOP AT e_tdrseg WHERE selkz EQ 'X' AND menge NE 0.
*  SELECT SINGLE bsart FROM ekko INTO bsart WHERE
*ebeln EQ E_TDRSEG-EBELN.

*  IF bsart NE 'ZIMP'.
    SELECT SINGLE bwart INTO bwart FROM mseg
    WHERE mblnr EQ e_tdrseg-lfbnr AND insmk EQ 'X'.
    IF sy-subrc EQ 0.
      IF bwart Eq '102'.
        MESSAGE E014(MD) WITH sy-tabix.
      ENDIF.
      IF bwart EQ '101'.
        SELECT SINGLE zeile FROM mseg INTO zeile
        WHERE mblnr EQ e_tdrseg-mblnr AND matnr EQ e_tdrseg-matnr
        AND erfmg EQ e_tdrseg-menge AND insmk EQ 'X'.
        IF zeile NE 0.
          SELECT prueflos INTO prueflos FROM qamb
          WHERE mblnr EQ e_tdrseg-mblnr AND zeile EQ zeile.
              count = count + 1.

            SELECT SINGLE * FROM qave WHERE prueflos EQ prueflos.
            IF sy-subrc NE 0 AND count GT 0.
              MESSAGE E015(MD) WITH sy-tabix.
            ENDIF.
            IF qave-vcode EQ 'R' OR qave-vcode EQ 'R11'
            OR qave-vcode EQ 'R12'  OR qave-vcode EQ 'R2'
            OR qave-vcode EQ 'R3'.

                MESSAGE E016(MD) WITH sy-tabix.

            ENDIF.
          ENDSELECT.
        ENDIF.
*      ENDIF.
    ENDIF.
 ENDIF.
 CLEAR: ZEILE,MBLNR,COUNT.
ENDLOOP.
 

Message Class :  MD

014 GRN is reversed - Invoice Verification Not Allowed
015 Quality Inspection is not completed - Please Complete QC First
016 GRN is rejected - Invoice Verification Not Allowed
017 Business Place is Empty - Check Your Entry
018 Section Code is Empty - Check Your Entry

SAP QM

Read Also
Collective Results Recording in SAP

SAP QM Reference Books:
SAP Quality Management Configuration, Interview Questions and Certification Books

Back to:
SAP QM (Quality Management) Hints and Tips

Return to :-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.