src-db/database/model/functions/MA_WORKEFFORT_VALIDATE.xml
changeset 14983 fcf3ccf492f3
parent 9072 79e55dfc8af0
child 15001 a7a8ccfb1923
equal deleted inserted replaced
14982:0efd2107a1a5 14983:fcf3ccf492f3
    14 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
    14 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
    15 * License for the specific  language  governing  rights  and  limitations
    15 * License for the specific  language  governing  rights  and  limitations
    16 * under the License.
    16 * under the License.
    17 * The Original Code is Openbravo ERP.
    17 * The Original Code is Openbravo ERP.
    18 * The Initial Developer of the Original Code is Openbravo SLU
    18 * The Initial Developer of the Original Code is Openbravo SLU
    19 * All portions are Copyright (C) 2001-2010 Openbravo SLU
    19 * All portions are Copyright (C) 2001-2011 Openbravo SLU
    20 * All Rights Reserved.
    20 * All Rights Reserved.
    21 * Contributor(s):  ______________________________________.
    21 * Contributor(s):  ______________________________________.
    22 ************************************************************************/
    22 ************************************************************************/
    23   -- Logistice
    23   -- Logistice
    24   v_ResultStr VARCHAR2(2000):='';
    24   v_ResultStr VARCHAR2(2000):='';
    65     v_isacctle AD_OrgType.IsAcctLegalEntity%TYPE;
    65     v_isacctle AD_OrgType.IsAcctLegalEntity%TYPE;
    66     v_org_bule_id AD_Org.AD_Org_ID%TYPE;
    66     v_org_bule_id AD_Org.AD_Org_ID%TYPE;
    67     v_AD_Org_ID VARCHAR2(32);
    67     v_AD_Org_ID VARCHAR2(32);
    68     v_prodline NUMBER;
    68     v_prodline NUMBER;
    69     v_line NUMBER;
    69     v_line NUMBER;
       
    70     v_AD_Pinstance_ID VARCHAR2(32);
    70   BEGIN
    71   BEGIN
    71     -- Process Parameters
    72     -- Process Parameters
    72     IF(p_PInstance_ID IS NOT NULL) THEN
    73     IF(p_PInstance_ID IS NOT NULL) THEN
    73       --  Update AD_PInstance
    74       --  Update AD_PInstance
    74       DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || p_PInstance_ID) ;
    75       DBMS_OUTPUT.PUT_LINE('Updating PInstance - Processing ' || p_PInstance_ID) ;
   326       v_ResultStr:='Updating workrequirement';
   327       v_ResultStr:='Updating workrequirement';
   327       FOR Cur_ProductionPlan IN
   328       FOR Cur_ProductionPlan IN
   328         (SELECT *  FROM M_PRODUCTIONPLAN pp  WHERE pp.M_PRODUCTION_ID=v_Record_ID)
   329         (SELECT *  FROM M_PRODUCTIONPLAN pp  WHERE pp.M_PRODUCTION_ID=v_Record_ID)
   329       LOOP
   330       LOOP
   330         UPDATE MA_WRPHASE
   331         UPDATE MA_WRPHASE
   331           SET DONEQUANTITY=DONEQUANTITY + Cur_ProductionPlan.PRODUCTIONQTY
   332           SET DONEQUANTITY=DONEQUANTITY + Cur_ProductionPlan.PRODUCTIONQTY, RUNTIME=Cur_ProductionPlan.RUNTIME
   332         WHERE MA_WRPhase_ID=Cur_ProductionPlan.MA_WRPHASE_ID;
   333         WHERE MA_WRPhase_ID=Cur_ProductionPlan.MA_WRPHASE_ID;
       
   334         -- Close Phase if its marked
       
   335 	IF (Cur_ProductionPlan.CLOSEPHASE='Y') THEN
       
   336 	  v_AD_Pinstance_ID := GET_UUID();
       
   337 	  INSERT INTO AD_PINSTANCE 
       
   338 	  (AD_PINSTANCE_ID, AD_PROCESS_ID, RECORD_ID, ISACTIVE, 
       
   339 	  AD_USER_ID, AD_CLIENT_ID, AD_ORG_ID, CREATED, CREATEDBY,
       
   340 	  UPDATED, UPDATEDBY)
       
   341 	  VALUES
       
   342 	  (v_AD_Pinstance_ID,'800118',Cur_ProductionPlan.MA_WRPHASE_ID,'Y',
       
   343 	  v_User_ID, v_Client_ID, v_Org_ID, now(), v_User_ID,
       
   344 	  now(), v_User_ID
       
   345 	  );
       
   346 	  MA_WRPHASE_CLOSE(v_AD_Pinstance_ID);
       
   347 	END IF;
   333       END LOOP;
   348       END LOOP;
   334       -- Indicate that we are done
   349       -- Indicate that we are done
   335       UPDATE M_PRODUCTION
   350       UPDATE M_PRODUCTION
   336         SET Processed='Y',
   351         SET Processed='Y',
   337         updated=now(),
   352         updated=now(),
   338         updatedby=v_User_ID
   353         updatedby=v_User_ID
   339       WHERE M_Production_ID=v_Record_ID;
   354       WHERE M_Production_ID=v_Record_ID;    
   340     END IF; --FINISH_PROCESS
   355     END IF; --FINISH_PROCESS
   341     IF(NOT FINISH_PROCESS) THEN
   356     IF(NOT FINISH_PROCESS) THEN
   342       v_ResultStr:='Updating used toolsets';
   357       v_ResultStr:='Updating used toolsets';
   343       FOR Cur_Toolset IN
   358       FOR Cur_Toolset IN
   344         (SELECT MA_TOOLSETUSED.*
   359         (SELECT MA_TOOLSETUSED.*