Skip to Content
0
Mar 25, 2006 at 02:37 AM

Problem in RESETing certain fields in ME22 Upon editing : User EXIT FOR PO

58 Views

I am working on an user exit which should reset the order quantity in Me22 if user tries to modify it. Suppose the original qty is 200 KG and user tries to modify it to 100 KG, it should be reset back to 200 KG upon save. I tried user exit EXIT_SAPMM06E_013 and EXIT_SAPMM06E_017. I tried to over write new values of that field with old values. ( Eg. YEKPO-MENGE to XEKPO-MENGE). But still the PO document is saved with XEKPO-MENGE . Is there any other process overwriting it back or is it losing it scope outside my Include ? Here is my code in EXIT_SAPMM06E_013.

Also tried putting YEKET-MENGE to XEKET-MENGE. Still did not work. Then i moved to EXIT_SAPMM06E_017. Tried to copy i_ekpo_old-menge to i_ekpo-menge. Still did not help.

I had similar problem with Sales order too. I figured out that along with YVBAP-KWMENG copy to XVBAP-KWMENG, i had to do YVBEP-CMENG to XVBEP-CMENG and it worked fine.

*----------------------------------------------------------------------
*
*   INCLUDE ZSWI_NOMIT_PO_VALIDATION
*
*----------------------------------------------------------------------
   DATA: i_wa_xekpo  TYPE  uekpo,
         i_wa_yekpo  TYPE  uekpo,
         i_oijnomi TYPE  oijnomi.
 
   DATA: i_wa_yeket  TYPE ueket,
         i_wa_xeket  TYPE eket,
         i_eket      TYPE eket OCCURS 0 .
 
   DATA :i_tabix TYPE sytabix.
 
   CONSTANTS: c_char_i VALUE 'I',
              c_char_e VALUE 'E',
              c_char_f VALUE 'F',
              c_char_p VALUE 'P',
              c_char_v VALUE 'V',
              c_bulk_order(2) VALUE 'ZB',
              c_po_change(4)   VALUE 'ME22',
              c_pon_change(5)  VALUE 'ME22N'.
 
   IF i_ekko-bstyp = c_char_f     AND    " Purchase orders
      i_ekko-bsart = c_bulk_order AND    " Bulk orders
      sy-batch IS INITIAL         AND    " In foreground
      ( sy-tcode   = c_po_change   OR    " PO Change
        sy-tcode   = c_pon_change   ) .   " Enjoy PO Change
 
     
     CLEAR: i_wa_msg .
     REFRESH: i_message .
 
     LOOP AT xekpo INTO i_wa_xekpo .
 
       i_tabix = sy-tabix.
 
       READ TABLE yekpo
            INTO i_wa_yekpo
            WITH KEY ebeln = i_wa_xekpo-ebeln
                     ebelp = i_wa_xekpo-ebelp .
 
       IF sy-subrc EQ 0 .
 
         CLEAR: i_oijnomi .
         SELECT SINGLE * FROM oijnomi
           INTO i_oijnomi
          WHERE docnr  = i_wa_xekpo-ebeln
            AND docitm = i_wa_xekpo-ebelp
            AND docind = c_char_p .
 
         IF sy-subrc EQ 0. " TIED TO A NOMINATION
 
           IF i_wa_xekpo-menge NE i_wa_yekpo-menge .
 
             xekpo-menge = i_wa_yekpo-menge.
 
             MODIFY xekpo FROM xekpo INDEX i_tabix
             TRANSPORTING menge .
 
             READ TABLE yeket INTO i_wa_yeket
                        WITH KEY ebeln = i_wa_xekpo-ebeln
                                 ebelp = i_wa_xekpo-ebelp .
 
             xeket-menge =  i_wa_yeket-menge.
 
             MODIFY xeket FROM xeket INDEX i_tabix
             TRANSPORTING menge .
 
            
           ELSEIF i_wa_xekpo-werks NE i_wa_yekpo-werks .
 
             MODIFY xekpo FROM i_wa_yekpo INDEX i_tabix
             TRANSPORTING werks.
 
            
           ENDIF .
 
         ENDIF .
 
       ENDIF .
 
     ENDLOOP .
 
    ENDIF .