Skip to Content
0
Former Member
Jul 30, 2009 at 08:15 PM

Split line item - Sales Order

351 Views

Hi ,

I need to split a line item into 2 line based on qty.

Say Customer orders material A for 100 Qty. I need to split this into 2 line items for pricing requirements (client requirement).

So, I MV45AFZZ Program, in user exit, userexit_save_document_prepare.

I am adding other line item by adding folowing code. in debug I am seeing that XVBAP is appeneded with new line item, but I am getting a system error at later point and forcing me to exit for sales order creation screen. order is never saved.

Please help me, I guess i am missing some important..


 IF XVBAP-MATNR = 'XXXX'  AND
     XVBAP-KWMENG GT 100.

    DESCRIBE TABLE XVBAP LINES W_LINES.
    W_POSNR = XVBAP-POSNR + 00010.
    
    w_adj_qty = xvbap-kwmeng - 100.
    
    READ TABLE XVBAP WITH KEY MATNR = 'XXXX'.
    XVBAP-KWMENG = 80. 
    MODIFY XVBAP.
    
    

    MOVE-CORRESPONDING XVBAP TO I_VBAP_TEMP.
    MOVE W_POSNR TO I_VBAP_TEMP-POSNR.
    MOVE kwmeng  TO w_adj_qty.
    APPEND I_VBAP_TEMP TO XVBAP.
    
    vbap = xvbap.
   perform preisfindung_gesamt using 'C'.
   ENDIF.