2010 Sep 28 10:02 AM
Hi Experts,
please give me guidance in how to fine tune this code. Its very confusing to do.
* get shipment control record
SELECT SINGLE * FROM ztable
INTO wa_ztablel
WHERE tknum = i_tknum.
wa_ztable-tot_qty_move = 0.
*** Error - Shipment Not Found
**************************************************************
*** GET DELIVERIES FOR SHIPMENT
**************************************************************
SELECT * FROM vttp
INTO TABLE lt_vttp
WHERE tknum = i_tknum.
LOOP AT lt_vttp INTO lwa_vttp.
MOVE-CORRESPONDING lwa_vttp TO lwa_deliv.
APPEND lwa_deliv TO lt_deliv.
ENDLOOP.
SORT lt_deliv.
DELETE ADJACENT DUPLICATES FROM lt_deliv.
*************************************************************
*** Read Delivery Table for all Shipment Items
*************************************************************
SELECT * INTO TABLE lt_likp
FROM likp
FOR ALL ENTRIES IN lt_deliv
WHERE vbeln = lt_deliv-vbeln.
* Loop Deliveries Looking for Need to Create TO's
LOOP AT lt_likp INTO lwa_likp.
CLEAR: lv_tanum,
lt_lips[],
lwa_lips,
lt_delit[].
SELECT * INTO TABLE lt_lips
FROM lips
WHERE vbeln = lwa_likp-vbeln.
*** LINE ITEM LOOPING FOR DELIVERY
LOOP AT lt_lips INTO lwa_lips.
IF lwa_lips-mtart = 'YSRV'. "Skip Service Only Items
CONTINUE.
ENDIF.
********************************************************************
*** Examine Sales Document Item Status Table
********************************************************************
SELECT SINGLE * INTO lwa_vbup
FROM vbup
WHERE vbeln = lwa_likp-vbeln AND
posnr = lwa_lips-posnr.
********************************************************************
*** Look only at TO's that are inprocess
********************************************************************
IF lwa_vbup-kosta = 'A'. "TO Not Started
CONTINUE.
ENDIF.
********************************************************************
*** Examine Transfer Orders Using Sales Document Flow Table
********************************************************************
CLEAR lt_vbfa[].
SELECT * INTO TABLE lt_vbfa
FROM vbfa
WHERE vbelv = lwa_likp-vbeln
AND posnv = lwa_lips-posnr
AND lgnum = lwa_likp-lgnum
AND vbtyp_n = 'Q' "Transfer Orders
AND vbtyp_v = 'J'. "Deliveries
*******************************************************************
*** LOOP EXISTING TRANSFER ORDERS
*******************************************************************
LOOP AT lt_vbfa INTO lwa_vbfa.
CLEAR lt_ltap[].
SELECT * INTO TABLE lt_ltap
FROM ltap
WHERE tanum = lwa_vbfa-vbeln
AND tapos = lwa_vbfa-posnn
AND lgnum = lwa_vbfa-lgnum.
*******************************************************************
*** LOOP TRANSFER ORDER ITEMS
*******************************************************************
LOOP AT lt_ltap INTO lwa_ltap.
IF lwa_ltap-pquit = 'X'. "Confirmed
*** Update Move Qty for Shipment
*** If Destination is Delivery Dynamic Bin, add to total
IF lwa_ltap-nlpla = lwa_likp-vbeln.
wa_ztable-tot_qty_move =
wa_ztable-tot_qty_move + lwa_ltap-vista.
*** If Source is Delivery, subtract from total
ELSE.
wa_ztable-tot_qty_move =
wa_ztable-tot_qty_move - lwa_ltap-vista.
ENDIF.
ENDIF.
ENDLOOP. "Loop To Items
ENDLOOP. "Loop TO's
ENDLOOP. "Line Items for this Delivery
ENDLOOP.
2010 Sep 28 2:43 PM
Moderator message - Please see before posting - post locked Rob