Friday, August 16, 2013

Return PO Q-info ordered qty update problem-investigation


   This article original wrote by my colleague ,but no author specified(Maybe M.winter). it described  the wrong logic of update Q-info record. It will increase the ordered quantity in quality info-record even you are processing return to vendor via return PO, or, if you want create a return PO,but the remain approved quantity is less than the return quantity, system will disallow you create this PO.
    Here is root reason and solution .

Return PO Q-info ordered qty update problem-investigation

Function module: QB_VB_QINF_ORDER_POST

Original Q-info

Return purchase order creation screen

Activate updating debug
T_QINF_TAB-BEST_MG = 1300.

It's standard feature, so user exit may need to be developed or standard program need to be change.

Go-through ME21N relevant user exits:
Exit Name Description
AMPL0001 User sub-screen for additional data on AMPL
LMEDR001 Enhancements to print program
LMELA002 Adopt batch no. from shipping notification when posting a GR
LMELA010 Inbound shipping notification: Transfer item data from IDOC
LMEQR001 User exit for source determination
LMEXF001 Conditions in Purchasing Documents Without Invoice Receipt
LWSUS001 Individual customer source determination in Retail
M06B0001 Role determination for purchase requisition release
M06B0002 Changes to comm. structure for purchase requisition release
M06B0003 Number range and document number
M06B0004 Number range and document number
M06B0005 Changes to comm. structure for overall release of requisn.
M06E0004 Changes to communication structure for release purch. doc.
M06E0005 Role determination for release of purchasing documents
ME590001 Grouping of requsitions for PO split in ME59
MEETA001 Define schedule line type (backlog, immed. req., preview)
MEFLD004 Determine earliest delivery date f. check w. GR (only PO)
MELAB001 Gen. forecast delivery schedules: Transfer schedule implem.
MEQUERY1 Enhancement to Document Overview ME21N/ME51N
MEVME001 WE default quantity calc. and over/ under-delivery tolerance
MM06E001 User exits for EDI inbound and outbound purchasing documents
MM06E003 Number range and document number
MM06E004 Control import data screens in purchase order
MM06E005 Customer fields in purchasing document
MM06E007 Change document for requisitions upon conversion into PO
MM06E008 Monitoring of contr. target value in case of release orders
MM06E009 Relevant texts for "Texts exist" indicator
MM06E010 Field selection for vendor address
MMAL0001 ALE source list distribution: Outbound processing
MMAL0002 ALE source list distribution: Inbound processing
MMAL0003 ALE purchasing info record distribution: Outbound processing
MMAL0004 ALE purchasing info record distribution: Inbound processing
MMDA0001 Default delivery addresses
MMFAB001 User exit for generation of release order
MRFLB001 Control Items for Contract Release Order
TEXT Control Items for Contract Release Order
MM06E011 Activate Pur.req Block
LMEKO001 Extend communications structure KOMK for pricing
LMEKO002 Extend communications structure KOMP for pricing

Function module EXIT_SAPMM06E_013 under user exit MM06E005 is used to Update Customer-Specific Data in Purchasing Document, after the check, it seems that it's not possible to change the field value T_QINF_TAB-BEST_MG directly via user-exit, so may need to change standard program codes.

Check standard program:
Program SAPMM06E; module pool: MM06EFQM

Key codes to determine the Q-info ordered quantity update based on the purchase order information:
Program need to be changed as below:
  LOOP AT lt_qinftab INTO ls_qinftab.
    IF ls_qinftab-menge LT 0.
      MULTIPLY ls_qinftab-menge BY -1.
      l_qm_minus = mmpur_yes.
ELSE.
  If ekpo-retpo <> 'X'.                "add codes for return PO case( "+" qty)
         l_qm_minus = mmpur_no.            
      else.                                    
         L_qm_minus = mmpur_yes.          
      Endif.                                 
ENDIF.
    CALL FUNCTION 'QBCK_QINF_QUANTITY_CHANGE'
         EXPORTING
              i_lifnr    = ls_qinftab-lifnr
              i_matnr    = ls_qinftab-matnr
              i_werk     = ls_qinftab-werks
              i_quantity = ls_qinftab-menge
              i_subtract = l_qm_minus
              i_revlv    = ls_qinftab-revlv
              i_ematnr   = ls_qinftab-ematn
              i_stat17   = ls_qinftab-stat17
         EXCEPTIONS
              no_qinf    = 01.
  ENDLOOP.


Effects after change program codes
Scenario: Return 300PCE back to vendor
Field "l_qm_minus" is initial, standard system doesn't consider return PO case which is identified with "return" indicator in PO, but only consider negative quantity PO case, if the PO order quantity is less than 0, then the Q-info ordered quantity would be decreased. Yet when I tried to create a purchase order with negative order quantity in Q-box, system pop-up error message "Negative values not allowed" (Message class 00; message number: 126). In t-code OMCQ(message definition for IM), cannot see the message number 126.

Now if I change the field "l_qm_minus" with value 'X'.
Save the changes and execute the program to the end.

Execute QI02 to see updated Q-info

Q-info is well-updated.

BUT still have problem with ME21N, please see below:

Original QIR
Try to return 600 PCE to vendor, but system don't allow to do that.

System consider that the return PO order quantity will increase the "ordered quantity" of Q-info, so the calculation is wrong

Set break-point in include MM06EFQM

So for return PO case, we also need to insert codes as below:

           IF qm_mng_new GE 0.
             WRITE qm_mng_new TO qm_mng_new_char UNIT ekpo-meins.
             if ekpo-retpo <> 'X'.
               MESSAGE e882 WITH qm_mng_new_char ekpo-meins.
             endif.
           ELSE.
             qm_mng_new = qm_mng_new * ( -1 ).
             WRITE qm_mng_new TO qm_mng_new_char UNIT ekpo-meins.
             if ekpo-retpo <> 'X'.
               MESSAGE e880 WITH qm_mng_new_char ekpo-meins.
             endif.
           ENDIF

Conclusion:
2 minor changes need to be implemented into include "MM06EFQM". 1st change should suppress the error message E880 & E882 for return PO, the 2nd change should
decrease the ordered quantity of quality info record.

No comments:

Post a Comment