|
|
@ -2014,7 +2014,9 @@ DROP TABLE #NewTempERP"; |
|
|
|
string sql = @"DECLARE @Status VARCHAR(10)
|
|
|
|
SELECT @Status=c.Status FROM ICSInventoryLot a |
|
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint |
|
|
|
INNER JOIN ICSODeliveryNotice c ON b.TransCode=c.ODNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint |
|
|
|
INNER JOIN ICSOutsourcingOrder D ON B.TransCode=D.OOCode AND B.TransSequence=D.Sequence AND B.WorkPoint=D.WorkPoint |
|
|
|
INNER JOIN ICSODeliveryNotice c ON C.OODetailID=D.OODetailID AND A.InvCode=C.InvCode AND b.WorkPoint=c.WorkPoint |
|
|
|
INNER JOIN ICSOASNDetail E ON E.LotNo=A.LotNo AND C.OASNCode=E.OASNCode AND E.WorkPoint=A.WorkPoint |
|
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.ODNType='1' |
|
|
|
|
|
|
|
IF (@Status IS NULL) |
|
|
@ -2030,11 +2032,15 @@ DROP TABLE #NewTempERP"; |
|
|
|
UPDATE c SET RCVQuantity=ISNULL(RCVQuantity,0)+'{2}' |
|
|
|
FROM ICSInventoryLot a |
|
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint |
|
|
|
INNER JOIN ICSODeliveryNotice c ON b.TransCode=c.ODNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint |
|
|
|
INNER JOIN ICSOutsourcingOrder D ON B.TransCode=D.OOCode AND B.TransSequence=D.Sequence AND B.WorkPoint=D.WorkPoint |
|
|
|
INNER JOIN ICSODeliveryNotice c ON C.OODetailID=D.OODetailID AND A.InvCode=C.InvCode AND b.WorkPoint=c.WorkPoint |
|
|
|
INNER JOIN ICSOASNDetail E ON E.LotNo=A.LotNo AND C.OASNCode=E.OASNCode AND E.WorkPoint=A.WorkPoint |
|
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.ODNType='1' |
|
|
|
IF EXISTS(SELECT a.LotNo FROM ICSInventoryLot a |
|
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint |
|
|
|
INNER JOIN ICSODeliveryNotice c ON b.TransCode=c.ODNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint |
|
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint |
|
|
|
INNER JOIN ICSOutsourcingOrder D ON B.TransCode=D.OOCode AND B.TransSequence=D.Sequence AND B.WorkPoint=D.WorkPoint |
|
|
|
INNER JOIN ICSODeliveryNotice c ON C.OODetailID=D.OODetailID AND A.InvCode=C.InvCode AND b.WorkPoint=c.WorkPoint |
|
|
|
INNER JOIN ICSOASNDetail E ON E.LotNo=A.LotNo AND C.OASNCode=E.OASNCode AND E.WorkPoint=A.WorkPoint |
|
|
|
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND c.ODNType='1' |
|
|
|
AND dbo.GetExcessInQty(c.InvCode, c.WorkPoint, 'OverIn005', c.Quantity,1,1,'')<c.RCVQuantity) |
|
|
|
BEGIN |
|
|
@ -2092,7 +2098,7 @@ INTO #NewTempERP |
|
|
|
from ICSWareHouseLotInfoLog |
|
|
|
WHERE Identification='{0}' AND ERPUpload='0' |
|
|
|
|
|
|
|
SELECT c.VenCode+a.ToWarehouseCode+c.ODNCode+a.MUSER AS Costre,c.VenCode,a.ToWarehouseCode AS WarehouseCode,c.ODNCode ,a.MUSER,ROW_NUMBER() OVER (ORDER BY c.VenCode,a.ToWarehouseCode,c.ODNDetailID,a.InvCode) AS Sequence,d.OOCode,d.OODetailID, |
|
|
|
SELECT c.VenCode+a.ToWarehouseCode+c.ODNCode+a.MUSER AS Costre,c.VenCode,a.ToWarehouseCode AS WarehouseCode,c.ODNCode ,c.ODNID,d.OOID,a.MUSER,ROW_NUMBER() OVER (ORDER BY c.VenCode,a.ToWarehouseCode,c.ODNDetailID,a.InvCode) AS Sequence,d.OOCode,d.OODetailID, |
|
|
|
a.InvCode,SUM(a.Quantity) AS Quantity,CASE inv.AmountEnable WHEN '1' THEN SUM(a.Quantity*(lot.Amount/lot.Quantity)) ELSE '0' END AS Amount,isnull((c.UnitPrice),0) as UnitPrice,c.Currency,c.ODNDetailID,con.Enable AS UpdateTodoQuantity,conStock.Enable AS UpdateStock |
|
|
|
,a.WorkPoint,ISNULL(ext.ProjectCode, '') AS ProjectCode,CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END AS BatchCode,ISNULL(ext.Version, '') AS Version,ISNULL(ext.Brand, '') AS Brand, |
|
|
|
ISNULL(ext.cFree1, '') AS cFree1,ISNULL(ext.cFree2, '') AS cFree2,ISNULL(ext.cFree3, '') AS cFree3,ISNULL(ext.cFree4, '') AS cFree4,ISNULL(ext.cFree5, '') AS cFree5,ISNULL(ext.cFree6, '') AS cFree6,ISNULL(ext.cFree7, '') AS cFree7,ISNULL(ext.cFree8, '') AS cFree8,ISNULL(ext.cFree9, '') AS cFree9,ISNULL(ext.cFree10, '') AS cFree10 |
|
|
@ -2103,15 +2109,16 @@ SELECT c.VenCode+a.ToWarehouseCode+c.ODNCode+a.MUSER AS Costre,c.VenCode,a.ToWar |
|
|
|
INNER JOIN ICSInventory inv ON a.InvCode=inv.InvCode AND a.WorkPoint=inv.WorkPoint |
|
|
|
LEFT JOIN ICSInventoryBatchEnable invBat ON a.InvCode=invBat.InvCode AND a.ToWarehouseCode=invBat.WHCode AND a.WorkPoint=invBat.WorkPoint |
|
|
|
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint |
|
|
|
INNER JOIN ICSODeliveryNotice c ON b.TransCode=c.ODNCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint |
|
|
|
inner join ICSOutsourcingOrder d on c.OODetailID=d.OODetailID and c.WorkPoint=d.WorkPoint |
|
|
|
INNER JOIN ICSOutsourcingOrder D ON B.TransCode=D.OOCode AND B.TransSequence=D.Sequence AND B.WorkPoint=D.WorkPoint |
|
|
|
INNER JOIN ICSODeliveryNotice c ON C.OODetailID=D.OODetailID AND A.InvCode=C.InvCode AND b.WorkPoint=c.WorkPoint |
|
|
|
INNER JOIN ICSOASNDetail E ON E.LotNo=A.LotNo AND C.OASNCode=E.OASNCode AND E.WorkPoint=A.WorkPoint |
|
|
|
INNER JOIN ICSConfiguration con ON con.Code='Stock001' AND a.WorkPoint=con.WorkPoint |
|
|
|
INNER JOIN ICSConfiguration conStock ON conStock.Code='UpdateStock001' AND a.WorkPoint=conStock.WorkPoint |
|
|
|
GROUP BY d.OOCode,d.OODetailID,inv.AmountEnable,c.VenCode,a.ToWarehouseCode,c.ODNCode,c.ODNID,a.MUSER,a.InvCode,c.ODNDetailID,isnull((c.UnitPrice),0),c.Currency,con.Enable,conStock.Enable |
|
|
|
GROUP BY c.ODNID,d.OOID,d.OOCode,d.OODetailID,inv.AmountEnable,c.VenCode,a.ToWarehouseCode,c.ODNCode,c.ODNID,a.MUSER,a.InvCode,c.ODNDetailID,isnull((c.UnitPrice),0),c.Currency,con.Enable,conStock.Enable |
|
|
|
,a.WorkPoint,ISNULL(ext.ProjectCode, ''),CASE WHEN (invBat.BatchEnable IS NULL AND ISNULL(inv.BatchEnable, '0')='1') OR ISNULL(invBat.BatchEnable, '0')='1' THEN ISNULL(ext.BatchCode, '') ELSE '' END,ISNULL(ext.Version, ''),ISNULL(ext.Brand, ''), |
|
|
|
ISNULL(ext.cFree1, ''),ISNULL(ext.cFree2, ''),ISNULL(ext.cFree3, ''),ISNULL(ext.cFree4, ''),ISNULL(ext.cFree5, ''),ISNULL(ext.cFree6, ''),ISNULL(ext.cFree7, ''),ISNULL(ext.cFree8, ''),ISNULL(ext.cFree9, ''),ISNULL(ext.cFree10, '') |
|
|
|
|
|
|
|
SELECT DISTINCT Costre,WorkPoint,VenCode,WarehouseCode AS WHCode,ODNCode,OOCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity,UpdateStock FROM #TempERP |
|
|
|
SELECT DISTINCT Costre,WorkPoint,VenCode,WarehouseCode AS WHCode,ODNID as ODNCode, OOID AS OOCode,MUSER AS [User],SYSDATETIME() AS MTime,UpdateTodoQuantity,UpdateStock FROM #TempERP |
|
|
|
SELECT Costre,Sequence,InvCode,Quantity,Amount,ODNDetailID,OODetailID,WarehouseCode AS WHCode,Currency,UnitPrice,ProjectCode,BatchCode,Version,Brand,cFree1,cFree2,cFree3,cFree4,cFree5,cFree6,cFree7,cFree8,cFree9,cFree10 |
|
|
|
FROM #TempERP |
|
|
|
|
|
|
|