Fixes issue 22674. Fixes issue 22691. ORA-01403 in M_Inout_Post
authorMikel Irurita <mikel.irurita@openbravo.com>
Fri, 28 Dec 2012 10:33:01 +0100
changeset 19198 552342cfa929
parent 19110 26a81bd13b91
child 19199 8f2c7c6d1899
Fixes issue 22674. Fixes issue 22691. ORA-01403 in M_Inout_Post
src-db/database/model/functions/M_INOUT_POST.xml
--- a/src-db/database/model/functions/M_INOUT_POST.xml	Mon Dec 24 14:06:41 2012 +0000
+++ b/src-db/database/model/functions/M_INOUT_POST.xml	Fri Dec 28 10:33:01 2012 +0100
@@ -522,19 +522,24 @@
                   AND sl.M_InOut_ID=Cur_InOut.M_InOut_ID
                 )
               LOOP
-              
-								SELECT M_MATCHPO_ID
-								INTO v_MatchPO_ID
+                
+                SELECT count(*) INTO v_count
 								FROM M_MATCHPO
 								WHERE C_ORDERLINE_ID = Cur_SLines.C_OrderLine_ID
-								  AND M_INOUTLINE_ID = Cur_SLines.M_InOutLine_ID;             
+								  AND M_INOUTLINE_ID = Cur_SLines.M_InOutLine_ID;            
 
 								v_Qty:=Cur_SLines.MovementQty;
                 	--IF (ABS(Cur_SLines.MovementQty) > ABS(Cur_SLines.QtyOrdered)) THEN
                 	-- v_Qty := Cur_SLines.QtyOrdered;
                 	--END IF;
 
-								IF (v_MatchPO_ID IS NULL) THEN
+								IF (v_count <> 0) THEN                
+								  SELECT max(M_MATCHPO_ID)
+								  INTO v_MatchPO_ID
+                  FROM M_MATCHPO
+								  WHERE C_ORDERLINE_ID = Cur_SLines.C_OrderLine_ID
+								    AND M_INOUTLINE_ID = Cur_SLines.M_InOutLine_ID; 
+                  
                 	Ad_Sequence_Next('M_MatchPO', Cur_SLines.AD_Org_ID, v_MatchPO_ID) ;
                 	-- The min qty. Modified by Ismael Ciordia
                 	v_ResultStr:='InsertMatchPO ' || v_MatchPO_ID;