Commit ed11e308 authored by cpatil's avatar cpatil

modify and created for available to promise


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97288 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 94f13599
......@@ -6,10 +6,11 @@ import java.util.Map;
import java.util.Set;
//import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
//import java.sql.Timestamp;
import java.text.SimpleDateFormat;
class ADPElement
class ADPElement implements Cloneable
{
private String itemCode;
private String siteCode;
......@@ -57,6 +58,7 @@ class ADPElement
private double batchQty = 0;
private double purcRate = 0;
private double qtStk = 0;//Added by chandrashekar 0n 11-08-14
private double ordDemand = 0;
......@@ -98,8 +100,27 @@ class ADPElement
private String bomCodeParent="";
private HashMap bomSet = null;
private ArrayList<String> orderList=new ArrayList<String>();
private double soDemand=0;
private double grossWeight = 0;
private String altitemPerc;
public void setAltitemPerc(String altitemPerc)
{
this.altitemPerc=altitemPerc;
}
public String getAltitemPerc()
{
return this.altitemPerc;
}
public ArrayList<String> getOrderList()
{
return this.orderList;
}
public void setOrderList(ArrayList<String> orderList)
{
this.orderList=orderList;
}
public void setbomSet(HashMap bomCode) //aded by cpatil on 09/06/14
{
......@@ -247,19 +268,65 @@ class ADPElement
public double getQtStk() {
return qtStk;
}
public void setSoDemand(double soDemand) {
this.soDemand = soDemand;
}
public double getSoDemand() {
return soDemand;
}
public void setQtStk(double qtStk) {
this.qtStk = qtStk;
}
//changed method arguments by sabyasachi 29-03-2011
public void setDemand(java.sql.Timestamp dueDate, double demand, String saleOrder, String lineNo)
public void setDemand(java.sql.Timestamp dueDate, double demand, String saleOrder, String itemCode) throws ITMException, Exception
//public void setDemand(java.sql.Timestamp dueDate, double demand)
{
System.out.println("Calling setDemand() for saleOrder["+saleOrder+"]lineNo["+lineNo+"]this.refId["+this.refId+"]");
System.out.println("Calling setDemand() for saleOrder["+saleOrder+"]itemCode["+itemCode+"]this.refId["+this.refId+"]");
this.demand += demand;
//this.saleOrder = saleOrder;//Uncommented by manoj dtd 25/12/2014
//this.lineNo = lineNo;//Uncommented by manoj dtd 25/12/2014
System.out.println("this.refId---"+this.refId);
System.out.println("saleOrder---"+saleOrder);
System.out.println("demand---["+demand+"]");
//Commented by manoj dtd 25/12/2014
String dueDateStr="";
genericUtility = GenericUtility.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
if( dueDate != null)
{
dueDateStr = sdf.format(dueDate);
System.out.println("@@@@@ dueDateStr["+dueDateStr+"]");
}
if(saleOrder!=null && saleOrder.trim().length()>0)
{
if(this.refId==null ||this.refId.trim().length()==0)
this.refId=saleOrder+"@"+itemCode+"@"+demand+"@"+dueDateStr;
else
this.refId+="~"+saleOrder+"@"+itemCode+"@"+demand+"@"+dueDateStr;
}
//updateTimeMrp(dueDate, demand, 0, 0, 0,saleOrder,lineNo);
updateTimeMrp(dueDate, demand, 0, 0, 0);
}
public void setDemand(java.sql.Timestamp dueDate, double demand, String saleOrder, String lineNo,boolean isDetailReq)
//public void setDemand(java.sql.Timestamp dueDate, double demand)
{
System.out.println("Calling setDemand() for saleOrder["+saleOrder+"]lineNo["+lineNo+"]this.refId["+this.refId+"]");
if(isDetailReq)
{
this.demand+= demand;
this.ordDemand=demand;
}
//this.saleOrder = saleOrder;
//this.lineNo = lineNo;
System.out.println("this.refId---"+this.refId);
System.out.println("saleOrder---"+saleOrder);
System.out.println("demand---["+demand+"]");
if(saleOrder!=null && saleOrder.trim().length()>0)
{
if(this.refId==null ||this.refId.trim().length()==0)
......@@ -273,6 +340,8 @@ class ADPElement
//updateTimeMrp(dueDate, demand, 0, 0, 0,saleOrder,lineNo);
updateTimeMrp(dueDate, demand, 0, 0, 0);
}
//changed method arguments by sabyasachi 29-03-2011 end
public double getDemand()
{
......@@ -679,6 +748,16 @@ class ADPElement
}
//added by cpatil on 03/05/14 end
public void setGrossWeight(double grossWeight)
{
this.grossWeight = grossWeight;
}
public double getGrossWeight()
{
return this.grossWeight;
}
//private void updateTimeMrp(java.sql.Timestamp dueDate, double demand, double supply, double stockQty, double othSupply, String saleOrder, String lineNo)
private void updateTimeMrp(java.sql.Timestamp dueDate, double demand, double supply, double stockQty, double othSupply)
{
......@@ -698,6 +777,7 @@ class ADPElement
{
timeMRP = (TimeMRP)timeMRPArr.get(ctr);
//if (timeMRP.getDueDate() != null && timeMRP.getSaleOrder().equals(saleOrder) && timeMRP.getLineNo().equals(lineNo))
System.out.println("772--timeMRP.getDueDate()["+timeMRP.getDueDate()+"]");
if (timeMRP.getDueDate() != null)
{
if (timeMRP.getDueDate().equals(dueDate))
......@@ -715,6 +795,7 @@ class ADPElement
timeMRP.setDueDate(dueDate);
//added by sabyasachi 29.03.2011
//timeMRP.setDemand(demand,saleOrder,lineNo);
System.out.println("@@@@@@@@@@@ timeMRP -1 setdemand["+demand+"]");
timeMRP.setDemand(demand);
//end added by sabyasachi 29.03.2011
timeMRP.setSupply(supply);
......@@ -804,6 +885,10 @@ class ADPElement
errString = e.getMessage();
}
}
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
private void updateIndependentDemand(java.sql.Timestamp dueDate, double demand)
{
String errString = "";
......
This diff is collapsed.
......@@ -28,7 +28,7 @@ public class MrpWizPrsSaveBean
{
public String preSaveForm(String xmlString1 , String chgUser , String chgTerm )throws ITMException
public String preSaveForm(String xmlString1 , String chgUser , String chgTerm , String sorderList )throws ITMException
{
Document dom = null;
System.out.println("@@@@@@@@@---------MrpWizPrsSaveBean EJB called...");
......@@ -38,12 +38,12 @@ public class MrpWizPrsSaveBean
{
System.out.println("@@@@@@@xmlString1["+xmlString1+"]@@@@@@@");
System.out.println("@@@@@@ in bean chgUser["+chgUser+"]::chgTerm["+chgTerm+"]");
System.out.println("@@@@@@ in bean chgUser["+chgUser+"]::chgTerm["+chgTerm+"]sorderList["+sorderList+"]");
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
dom = GenericUtility.getInstance().parseString(xmlString1);
executepreSaveForm(dom,chgUser,chgTerm);
executepreSaveForm(dom,chgUser,chgTerm, sorderList);
}
}
catch(Exception e)
......@@ -55,7 +55,7 @@ public class MrpWizPrsSaveBean
return "";
}
private String executepreSaveForm(Document dom , String chgUser , String chgTerm )throws ITMException
private String executepreSaveForm(Document dom , String chgUser , String chgTerm , String sorderList)throws ITMException
{
PreparedStatement pstmt = null, pstmt1 = null, pstmt2 = null;
String sql = "", itemCode = "", effDate = "", itemSer = "", sql1="", sql2="";
......@@ -114,65 +114,170 @@ public class MrpWizPrsSaveBean
// if( detail4Node != null && detail4Node.getNodeValue() != null )
{
if("sale_order".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
saleOrder = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
saleOrder= "";
}
}
if("line_no".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
lineNo = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
lineNo= "";
}
}
if("site_code".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
siteCode = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
siteCode= "";
}
}
if("item_code".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
itemCode = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
itemCode= "";
}
}
if("lot_no".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
lotNo = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
lotNo= "";
}
}
if("lot_sl".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
lotSl = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
lotSl= "";
}
}
if("loc_code".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
locCode = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
locCode= "";
}
}
if("tran_ser".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
tranSer = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
tranSer= "";
}
}
if("running_supply".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
runningSupplyStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
runningSupplyStr= "0";
}
}
if("qty_reqd".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
qtyReqdStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
qtyReqdStr= "0";
}
}
if("alloc_qty".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
allocQtyStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
allocQtyStr= "0";
}
}
if("supply".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
supplyStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
supplyStr= "";
}
}
if("available_supply".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
availableSupplyStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
availableSupplyStr= "";
}
}
if("supp_sour".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
suppSour = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
suppSour= "";
}
}
if("parent_item".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
parentItem = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
parentItem= "";
}
}
if("prev_item_worder".equalsIgnoreCase( detail4Node.getNodeName()))
{
......@@ -206,6 +311,7 @@ public class MrpWizPrsSaveBean
String itemCodeHdr="";
remarks = "From mrp process";
sql1=" select item_code from sorddet where sale_order = ? and trim(line_no) = ? "; //added trim() for line no on 07/08/14 by cpatil
pstmt1=conn.prepareStatement(sql1);
pstmt1.setString(1,saleOrder);
......@@ -224,7 +330,6 @@ public class MrpWizPrsSaveBean
{
runningSupply = runningSupplyStr==null?0:Double.parseDouble(runningSupplyStr);
}
if( qtyReqdStr.trim().length() > 0)
{
qtyReqd = qtyReqdStr==null?0:Double.parseDouble(qtyReqdStr);
......@@ -234,9 +339,9 @@ public class MrpWizPrsSaveBean
allocQty = allocQtyStr==null?0:Double.parseDouble(allocQtyStr);
}
System.out.println("itemCodeHdr["+itemCodeHdr+"]==itemCode["+itemCode+"]");
System.out.println("itemCodeHdr["+itemCodeHdr+"]==itemCode["+itemCode+"]parentItem["+parentItem+"]saleOrder["+saleOrder+"]");
if(itemCodeHdr.equalsIgnoreCase(itemCode))
if( ( itemCodeHdr.equalsIgnoreCase(itemCode) || itemCodeHdr.equalsIgnoreCase(parentItem) ) && saleOrder != null && saleOrder.trim().length() > 0 )
{
InvAllocTrace invallocTrace = new InvAllocTrace();
......@@ -267,6 +372,10 @@ public class MrpWizPrsSaveBean
{
String tranType = "AUT";
if( lineNo == null || lineNo.trim().length() == 0 )
{
lineNo = "1";
}
tranId = generateTranId( "w_inv_allocate",siteCode, conn );
sql = " insert into inv_allocate ( TRAN_ID,TRAN_DATE,TRAN_TYPE,WORK_ORDER,SITE_CODE,ITEM_CODE," +
......@@ -358,6 +467,7 @@ public class MrpWizPrsSaveBean
}
}
/*
if ( errString == null || errString.trim().length() == 0 )
{
......@@ -371,6 +481,7 @@ public class MrpWizPrsSaveBean
System.out.println("@@@@@ cnt ["+cnt2+"]::: sorder ["+saleOrder+"] alloc_flag [ Y ] updated sucessfully");
}
*/
}
......@@ -569,6 +680,37 @@ public class MrpWizPrsSaveBean
*/
}
// for sorder updation
if ( ( errString == null || errString.trim().length() == 0 ) && sorderList != null )
{
System.out.println("@@@@@@@@@@@ sorderList["+sorderList+"]");
String sorderArray[]=sorderList.split("@");
System.out.println("@@@@@ sorderArray.length["+sorderArray.length+"]");
for(int i=0;i<sorderArray.length;i++)
{
String tempSO=sorderArray[i];
System.out.println("@@@@@::: sorder ["+tempSO+"] updated next i["+i+"]....");
sql2 = " update sorder set alloc_flag = 'Y' where sale_order = ? ";
System.out.println("sql2 :"+sql2 );
pstmt2 = conn.prepareStatement(sql2);
pstmt2.setString(1,tempSO);
int cnt2 = pstmt2.executeUpdate();
pstmt2.close();
pstmt2 = null;
System.out.println("@@@@@ cnt ["+cnt2+"]::: sorder ["+tempSO+"] alloc_flag [ Y ] updated sucessfully");
}
}
//end
// end insertion logic
}//try end
catch (SQLException sqx)
......
......@@ -20,4 +20,5 @@ public interface RunMRPWizLocal extends ValidatorLocal
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String getBomCodeList( String itemCode , String siteCode, String dbID) throws RemoteException,ITMException;
public String getOthersDetails( String othersDetails , String currentSOrder ) throws RemoteException,ITMException;
}
......@@ -20,4 +20,5 @@ public interface RunMRPWizRemote extends ValidatorRemote
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String getBomCodeList( String itemCode ,String siteCode, String dbID) throws RemoteException,ITMException;
public String getOthersDetails( String othersDetails , String currentSOrder ) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.mfg;
import ibase.utility.*;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.mfg.RequirementICRemote;
import ibase.webitm.utility.*;
import javax.servlet.http.*;
import java.io.*;
import javax.naming.InitialContext;
public class RunMrpOthersDetails
{
private ibase.utility.UserInfoBean userInfo = null;
private HttpSession sessionCtx = null;
ITMWizardStatefulRemote itmWizardRemote = null;
private String objName = "";
private String user_lang ="en";
private String user_country = "US";
public RunMrpOthersDetails ( String objName, HttpSession sessionCtx ) throws ITMException
{
try
{
this.objName = objName;
this.sessionCtx = sessionCtx;
this.userInfo = ( ibase.utility.UserInfoBean ) this.sessionCtx.getAttribute("USER_INFO");
this.user_lang = this.userInfo.getUserLanguage();
this.user_country = this.userInfo.getUserCountry();
if( this.itmWizardRemote == null )
{
InitialContext ctx = new InitialContext( new AppConnectParm().getProperty() );
this.itmWizardRemote = (ibase.webitm.ejb.ITMWizardStatefulRemote)ctx.lookup("ibase/ITMWizardStatefulEJB/remote");
this.itmWizardRemote.setUserInfo( this.userInfo );
this.itmWizardRemote.loadFormsMetaData( this.objName, "1", this.objName+"21", this.userInfo.getEmpCode(), this.userInfo.getProfileId() );
}
}
catch (ITMException itme)
{
itmWizardRemote.remove();
itmWizardRemote = null;
throw itme;
}
catch (Exception e)
{
itmWizardRemote.remove();
itmWizardRemote = null;
throw new ITMException(e);
}
}
public RunMrpOthersDetails () throws ITMException
{
}
//get item code pop help
public String getOthersDetails( String othersDetails , String currentSorder) throws ITMException
{
String OthersDetailsData = "";
RunMRPWizRemote runMRPWizRemote = null;
try
{
InitialContext ctx = new InitialContext( new AppConnectParm().getProperty() );
runMRPWizRemote = (ibase.webitm.ejb.mfg.RunMRPWizRemote)ctx.lookup("ibase/RunMRPWiz/remote");
OthersDetailsData = runMRPWizRemote.getOthersDetails(othersDetails , currentSorder);
runMRPWizRemote = null;
System.out.println("OthersDetailsData=="+OthersDetailsData);
String xslFileName = getXSLFileName( "mrp_others_details_wiz_" + this.user_lang + "_" + this.user_country + ".xsl" );
//String xslFileName = getXSLFileName( "requirement_item_code_wiz_en_US.xsl" );
OthersDetailsData = ( new ibase.webitm.utility.GenericUtility() ).transformToString( xslFileName, OthersDetailsData, CommonConstants.APPLICATION_CONTEXT + File.separator + "temp", "Output", ".html" );
System.out.println("OthersDetailsData==="+OthersDetailsData);
}
catch ( Exception e )
{
throw new ITMException(e);
}
finally
{
if ( runMRPWizRemote != null )
{
runMRPWizRemote = null;
}
}
return OthersDetailsData;
}
private String getXSLFileName( String xslFileName )throws ITMException
{
String retFileName = null;
try
{
String defaultPath = null;
if( CommonConstants.APPLICATION_CONTEXT != null )
{
defaultPath = CommonConstants.APPLICATION_CONTEXT + CommonConstants.ITM_CONTEXT + File.separator;
}
else
{
defaultPath = ".." + File.separator + "webapps" + File.separator + "ibase" + File.separator + CommonConstants.ITM_CONTEXT + File.separator;
}
File xslPath = new File( defaultPath + File.separator + "xsl" + File.separator + CommonConstants.THEME + File.separator + "WIZARD");
if ( !xslPath.exists() )
{
xslPath.mkdir();
}
System.out.println( " xslPath [" + xslPath +"] xslFileName ["+xslFileName +"]");
File xslFile = new File(xslPath , xslFileName);
if( xslFile.exists() )
{
retFileName = xslFile.getAbsolutePath();
}
else
{
throw new ITMException( new Exception( retFileName + " Wizard XSL file Not Found") );
}
}
catch (Exception e)
{
throw new ITMException(e);
}
return retFileName;
}
}
......@@ -33,6 +33,8 @@ public class TimeMRP
//end added by sabyasachi 17.03.2011
boolean createDemand = false;
String saleOrder="";
double orderDemand=0;
public TimeMRP()
{
......@@ -54,12 +56,21 @@ public class TimeMRP
//changed method arguments by sabyasachi 29-03-2011
//public void setDemand(double demand,String saleOrder, String lineNo)
public void setDemand(double demand)
{
this.demand += demand;
//this.saleOrder = saleOrder;
//this.lineNo = lineNo;
}
public void setOrderDemand(double orderDemand)
{
this.orderDemand=orderDemand;
}
public double setOrderDemand()
{
return this.orderDemand;
}
//changed method definition by sabyasachi 29-03-2011 end
public double getDemand()
......
select item_code, due_date, round(sum(demand),0) demand, sum(supply) supply , sum(stock_qty) stock_qty, sum(oth_supply) oth_supply, sum(pending_po) pending_po ,sum(pending_do) pending_do, sum(pending_indent) pending_indent, sum(pending_dr) pending_dr,tran_id,tran_ser ,site_code from
(
SELECT a.site_code||'@'||d.item_code||'@'||a.lot_no||'@'||a.lot_sl||'@'||a.loc_code||'@'||(case when c.alloc_pref is null then 'X' else c.alloc_pref end) as tran_id,
'Stock' as tran_ser, d.item_code__plan as item_code,
FN_MRP_DUEDATE(timestamp('@fromdate@-00.00.00')) as due_date,
0 as demand,
(a.quantity-a.alloc_qty) as supply,(a.quantity-a.alloc_qty) as stock_qty,
0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr , a.site_code
FROM STOCK a, INVSTAT b , LOCATION c,item d
WHERE a.loc_code = c.loc_code
AND b.inv_stat = c.inv_stat
AND NVL(b.stat_type, ' ') <> @ordtypes@
and ( a.site_code || d.item_code__plan ) IN ( '@itemcode@' )
AND NVL(b.plan_prod,'N') = 'Y'
AND a.item_code=d.item_code
) alias
group by item_code,due_date ,tran_id,tran_ser,site_code
having sum(supply) <> 0
select item_code, due_date, 0 demand, sum(supply) supply , sum(stock_qty) stock_qty, sum(oth_supply) oth_supply, sum(pending_po) pending_po ,sum(pending_do) pending_do, sum(pending_indent) pending_indent, sum(pending_dr) pending_dr,tran_id,tran_ser ,site_code from
(
SELECT a.site_code||'@'||d.item_code||'@'||a.lot_no||'@'||a.lot_sl||'@'||a.loc_code||'@'||(case when c.alloc_pref is null then 'X' else c.alloc_pref end) as tran_id,
'Stock' as tran_ser, d.item_code__plan as item_code,
FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date,
0 as demand,
(a.quantity-a.alloc_qty) as supply,(a.quantity-a.alloc_qty) as stock_qty,
0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr , a.site_code
FROM STOCK a, INVSTAT b , LOCATION c,item d
WHERE a.loc_code = c.loc_code
AND b.inv_stat = c.inv_stat
AND NVL(b.stat_type, ' ') <> @ordtypes@
and ( a.site_code || d.item_code__plan ) IN ( '@itemcode@' )
AND NVL(b.plan_prod,'N') = 'Y'
AND a.item_code=d.item_code
) alias
group by item_code,due_date ,tran_id,tran_ser,site_code
having sum(supply) <> 0
This diff is collapsed.
......@@ -37,6 +37,21 @@
( sales_demand.due_date <= to_date('@todate@')) AND
( 0 = @madetostock@ )
Group By item.item_code__plan,sales_demand.due_date
UNION ALL
SELECT item.item_code__plan as item_code,invtrace.tran_date as due_date,
sum(invtrace.eff_qty) as demand,
0 as supply , 0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
FROM invtrace, item, location, invstat
WHERE ( invtrace.item_code = item.item_code ) and
( location.loc_code = invtrace.loc_code) and
( invstat.inv_stat = location.inv_stat) and
( invstat.stat_type <> 'S' ) and
( invtrace.site_code in ('@sitecode@') ) AND
( item.item_code__plan = '@itemcode@') AND
( invtrace.tran_date >= to_date('@fromdate@')) and
( invtrace.tran_date <= to_date('@rundate@')) and
( invtrace.ref_ser in ('D-ISS','S-DSP') )
Group By item.item_code__plan,invtrace.tran_date
UNION ALL
SELECT item.item_code__plan as item_code,distorder_det.due_date as due_date,
sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) as demand,
......@@ -113,14 +128,37 @@ FROM indent,item
( porder.pord_type not in (@ordtypes@) ) and
( porddet.dlv_date <= to_date('@todate@'))
Group By item.item_code__plan,porddet.dlv_date
UNION ALL
SELECT item.item_code__plan as item_code,FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date,
0 as demand ,
DDF_INV_CLSTK_MRP('@sitecode@',item.item_code,to_date(fn_sysdate())) as supply,
DDF_INV_CLSTK_MRP('@sitecode@',item.item_code,to_date(fn_sysdate())) as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
FROM item
WHERE item.item_code__plan= '@itemcode@'
and DDF_INV_CLSTK_MRP('@sitecode@',item.item_code,to_date(fn_sysdate())) > 0
UNION ALL
select item_code,due_date,sum(demand) demand,sum(supply) supply,sum(stock_qty) stock_qty,
sum(oth_supply) oth_supply,sum(pending_po) pending_po,sum(pending_do) pending_do,sum(pending_indent) pending_indent,
sum(pending_dr) pending_dr from
( SELECT d.item_code__plan as item_code,FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date,0 as demand,
(a.quantity-a.alloc_qty) as supply,(a.quantity-a.alloc_qty) as stock_qty,
0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
FROM STOCK a, INVSTAT b , LOCATION c,item d
WHERE a.loc_code = c.loc_code
AND b.inv_stat = c.inv_stat
AND NVL(b.stat_type, ' ') <> 'S'
AND a.site_code = '@sitecode@'
AND a.item_code = '@itemcode@'
AND NVL(b.plan_prod,'N') = 'Y'
AND a.item_code=d.item_code
UNION ALL
SELECT d.item_code__plan as item_code,FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date,0 as demand,
NVL((eff_qty * -1),0) as supply,NVL((eff_qty * -1),0) as stock_qty,
0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
FROM INVTRACE a, LOCATION b, INVSTAT c,item d
WHERE a.loc_code = b.loc_code
AND b.inv_stat = c.inv_stat
AND NVL(c.stat_type, ' ') <> 'S'
AND a.item_code = '@itemcode@'
AND a.site_code = '@sitecode@'
AND NVL(c.plan_prod,'N') = 'Y'
AND a.item_code=d.item_code
AND a.EFF_date > to_date(fn_sysdate())) group by item_code,due_date
UNION ALL
SELECT item.item_code__plan as item_code,to_date('@fromdate@') as due_date,
0 as demand,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment