|
发表于 2008-8-29 12:45:41
|
显示全部楼层
老兄,可用量是根据各种条件算出来的.不是在CurrentStock表里的静态数据.系统存在相应的视图和存储过程,你这样查当然显示不出来了.
如果你有兴趣的话,可以参照一下脚本,自己整理一下:
begin tran aa
rollback tran aa
exec sp_reset_connection
go
Set TRANSACTION ISOLATION LEVEL READ COMMITTED
go
SELECT cScenarioID AS ScenarioID FROM UA_ScenarioEntry AS ScenarioEntry, UA_Scenario AS Scenario WHERE ScenarioEntry.cScenarioID = Scenario.cID AND ScenarioEntry.cMenu_Id = 'ST040201' AND cID IN ( SELECT cScenarioID FROM UA_ScenarioGroup WHERE cGroup_Id IN ( SELECT cGroup_Id FROM UA_Role WHERE cUser_Id = 'xushan') )
go
select ivalue from SCM_SysTableTS where ctablename =N'ua_account' and convert(money,tblufts) =221.8396
go
select ivalue from SCM_SysTableTS where ctablename =N'accinformation' and convert(money,tblufts) =6683.4274
go
select ivalue from SCM_SysTableTS where ctablename =N'UA_period' and convert(money,tblufts) =221.8397
go
select ivalue from SCM_SysTableTS where ctablename =N'gl_mend' and convert(money,tblufts) =6667.5124
go
exec sp_reset_connection
go
select [Name] from Rpt_GlbDEF_Base where [Name] = N'现存量查询' and LocaleId='zh-CN' and SystemID='ST' and bNewRpt=0
go
select top 1 * from Rpt_GlbDEF_Base where [Name] = N'现存量查询' and SystemID = 'ST'
go
Select ID,Name,Title,DefaultTitle,Note,Relation,DatabaseEx,IsBaseTable From Rpt_GlbDef Where SystemID='ST' and Name=N'现存量查询'
go
Select ClassName,IsBaseTable,Note From Rpt_GlbDef Where ID='1809'
go
Select ISNull(FilterClass,'') From Rpt_GlbDef Where ID='1809'
go
Select ISNull(FilterID,'') From Rpt_GlbDef Where ID='1809'
go
Select * From Rpt_FldDef WITH (NOLOCK) Where ID = 1809
go
Select DataAuthObjID From Rpt_GlbDef Where ID = 1809 and DataAuthObjID is not null and ltrim(rtrim(DataAuthObjID))<>''
go
Select Name,Expression,Caption,Flag,IsSingle,Note,iTop From Rpt_FltDef Where ID = 1809 AND ModeEx =20 Order by Name,Flag
go
Select Convert(money,Pubufts) from UFMeta_999.dbo.flt_DefineMeta_Cache with (nolock) where FilterID='ST[__]现存量查询' and LocaleID='zh-CN'
go
SET NO_BROWSETABLE ON
go
Select * from flt_Solution with (nolock) where [FilterID]='ST[__]现存量查询' And IsDefault=1 and LocaleID='zh-CN' and isPublic=0 and UserID='xushan'
go
Select * from flt_Solution with (nolock) where [FilterID]='ST[__]现存量查询' And IsDefault=1 and LocaleID='zh-CN' and IsPublic=1
go
select cAuth_id from ua_auth where cAuth_id='ST020107'
go
Select count(cAuth_Id) from UFSystem..UA_Auth_Base Where cAuth_Id='ST020107_01' Or cAuth_Id='ST020107_02' Or cAuth_Id='ST020107_03' Or cAuth_Id='ST020107_04'
go
Select count(cAuth_Id) from UFSystem..UA_Auth_Base Where cAuth_Id='ST020107_01' Or cAuth_Id='ST020107_02' Or cAuth_Id='ST020107_03' Or cAuth_Id='ST020107_04'
go
SELECT top 1 1 FROM ua_Task_Common with(nolock) WHERE iLogId=1549520940.12015
go
INSERT INTO ua_Task_Common with(rowlock)(cAcc_Id,iYear,cUser_Id,cAuth_Id,cStation,cTaskId,iLogId,cSub_Id,cAppServer) VALUES(N'999',2008,N'xushan',N'ST020107_01',N'REDFLY',N'13146129',1549520940.12015,N'ST',N'{32D7EB99-36CE-4A82-902D-387428473C86}')
go
SELECT TOP 1 cstation,cauth_id as cauth_id FROM UA_Task_Special with(nolock) WHERE (iAuthType =1 and iyear=2008 or iAuthType=2) AND cacc_id=N'999' AND ilogid<>1549520940.12015
go
SELECT top 1 1 FROM UA_tasklog with(nolock) WHERE ctaskid=N'13146129'
go
INSERT INTO UA_log with(rowlock) VALUES(N'999',N'ST',N'xushan',N'ST020107_01',N'REDFLY',getdate(),NULL,1549520940.12015,'2008',0)
go
SELECT top 1 1 FROM ua_Task_Common with(nolock) WHERE iLogId=3003185266.34731
go
INSERT INTO ua_Task_Common with(rowlock)(cAcc_Id,iYear,cUser_Id,cAuth_Id,cStation,cTaskId,iLogId,cSub_Id,cAppServer) VALUES(N'999',2008,N'xushan',N'ST020107_02',N'REDFLY',N'13146129',3003185266.34731,N'ST',N'{32D7EB99-36CE-4A82-902D-387428473C86}')
go
SELECT TOP 1 cstation,cauth_id as cauth_id FROM UA_Task_Special with(nolock) WHERE (iAuthType =1 and iyear=2008 or iAuthType=2) AND cacc_id=N'999' AND ilogid<>3003185266.34731
go
SELECT top 1 1 FROM UA_tasklog with(nolock) WHERE ctaskid=N'13146129'
go
INSERT INTO UA_log with(rowlock) VALUES(N'999',N'ST',N'xushan',N'ST020107_02',N'REDFLY',getdate(),NULL,3003185266.34731,'2008',0)
go
SELECT top 1 1 FROM ua_Task_Common with(nolock) WHERE iLogId=126187679.284359
go
INSERT INTO ua_Task_Common with(rowlock)(cAcc_Id,iYear,cUser_Id,cAuth_Id,cStation,cTaskId,iLogId,cSub_Id,cAppServer) VALUES(N'999',2008,N'xushan',N'ST020107_03',N'REDFLY',N'13146129',126187679.284359,N'ST',N'{32D7EB99-36CE-4A82-902D-387428473C86}')
go
SELECT TOP 1 cstation,cauth_id as cauth_id FROM UA_Task_Special with(nolock) WHERE (iAuthType =1 and iyear=2008 or iAuthType=2) AND cacc_id=N'999' AND ilogid<>126187679.284359
go
SELECT top 1 1 FROM UA_tasklog with(nolock) WHERE ctaskid=N'13146129'
go
INSERT INTO UA_log with(rowlock) VALUES(N'999',N'ST',N'xushan',N'ST020107_03',N'REDFLY',getdate(),NULL,126187679.284359,'2008',0)
go
SELECT top 1 1 FROM ua_Task_Common with(nolock) WHERE iLogId=3422088617.53647
go
INSERT INTO ua_Task_Common with(rowlock)(cAcc_Id,iYear,cUser_Id,cAuth_Id,cStation,cTaskId,iLogId,cSub_Id,cAppServer) VALUES(N'999',2008,N'xushan',N'ST020107_04',N'REDFLY',N'13146129',3422088617.53647,N'ST',N'{32D7EB99-36CE-4A82-902D-387428473C86}')
go
SELECT TOP 1 cstation,cauth_id as cauth_id FROM UA_Task_Special with(nolock) WHERE (iAuthType =1 and iyear=2008 or iAuthType=2) AND cacc_id=N'999' AND ilogid<>3422088617.53647
go
SELECT top 1 1 FROM UA_tasklog with(nolock) WHERE ctaskid=N'13146129'
go
INSERT INTO UA_log with(rowlock) VALUES(N'999',N'ST',N'xushan',N'ST020107_04',N'REDFLY',getdate(),NULL,3422088617.53647,'2008',0)
go
SELECT top 1 ilogid FROM ua_Task_Common with(nolock) WHERE ctaskid=N'13146129' AND cauth_id=N'ST020107_02'
go
DELETE FROM ua_Task_Common with(rowlock) WHERE ilogid=3003185266.34731
go
UPDATE UA_log with(rowlock) SET Success=1,douttime= getdate() WHERE ilogid=3003185266.34731
go
SELECT top 1 ilogid FROM ua_Task_Common with(nolock) WHERE ctaskid=N'13146129' AND cauth_id=N'ST020107_03'
go
DELETE FROM ua_Task_Common with(rowlock) WHERE ilogid=126187679.284359
go
UPDATE UA_log with(rowlock) SET Success=1,douttime= getdate() WHERE ilogid=126187679.284359
go
SELECT top 1 ilogid FROM ua_Task_Common with(nolock) WHERE ctaskid=N'13146129' AND cauth_id=N'ST020107_04'
go
DELETE FROM ua_Task_Common with(rowlock) WHERE ilogid=3422088617.53647
go
UPDATE UA_log with(rowlock) SET Success=1,douttime= getdate() WHERE ilogid=3422088617.53647
go
Update Rpt_GlbDef_Base set WhereEx='ST020107' where ID= 1809
go
Select * from Rpt_FldDef where ModeEx =27 and ID =1809
go
select * from Rpt_PrintSetting where id=1809 And LocaleID = 'zh-CN'
go
Select * from Rpt_FldDef where ID =1809 and ModeEx =25 order by OrderEx
go
Select * from Rpt_FldDef where ID =1809 and ModeEx =26 order by OrderEx
go
Select ActionClass,DoubleClick,ShowOnToolbar,Caption,Name,ToolTip From Rpt_CustomEvents Where ReportName='现存量查询' And cSub_id='ST'
go
SELECT * FROM UA_Account WHERE cAcc_Id = N'999'
go
drop table tempdb..TMPUF_13146129_heron597747400_REDFLY
go
Set lock_timeout 300000
go
Select * From ufsystem..UA_Account Where cAcc_Id=N'999'
go
select convert(money,tblufts) as tblufts from SCM_SysTableTS where ctablename=N'ua_account'
go
Select cSysID,cID,cName,cCaption,cType,cValue,cDefault,bVisible,bEnable from AccInformation with (nolock) Where cSysId In(N'AA',N'ST',N'SA',N'PU',N'IA',N'GS',N'CA',N'PM',N'QM',N'OM',N'MO',N'FC',N'EX',N'EQ',N'SR',N'IM')
go
select convert(money,tblufts) as tblufts from SCM_SysTableTS where ctablename=N'accinformation'
go
Select iId as [Month] ,dBegin as [BeginDate],dEnd as [EndDate] From ufsystem..UA_period with (nolock) Where iYear=2008 And cAcc_Id=N'999' Order By iId
go
select convert(money,tblufts) as tblufts from SCM_SysTableTS where ctablename=N'UA_period'
go
Select * From GL_mend with (nolock) order by iPeriod
go
select convert(money,tblufts) as tblufts from SCM_SysTableTS where ctablename=N'gl_mend'
go
select cclass, citemname,cdicdbname,ctype ,isnull(citemname,'') as citemname from userdef with (nolock) where cclass =N'存货'
go
select top 1 cname from accinformation where csysid=N'EX' and cname=N'bReduceExportWaitoutQty' and cValue ='True'
go
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SELECT W.cWhCode, W.cWhName, I.cInvCode, I.cInvAddCode, I.cInvName, I.cInvStd, I.cInvCCode , IC.cInvCName,
CU_M.cComUnitName AS cInvM_Unit, CASE WHEN I.iGroupType = 0 THEN NULL WHEN I.iGrouptype = 2 THEN CU_A.cComUnitName WHEN I.iGrouptype = 1 THEN CU_G.cComUnitName END AS cInvA_Unit,CASE WHEN I.iGroupType = 0 THEN NULL WHEN I.iGroupType = 2 THEN (CASE WHEN CS.iQuantity = 0.0 OR CS.iNum = 0.0 THEN NULL ELSE CS.iQuantity/CS.iNum END) WHEN I.iGroupType = 1 THEN CU_G.iChangRate END AS iExchRate,
Null as cInvDefine1, Null as cInvDefine2, Null as cInvDefine3, Null as cFree1, Null as cFree2, Null as cFree3, Null as cFree4, Null as cFree5, Null as cFree6, Null as cFree7, Null as cFree8, Null as cFree9, Null as cFree10, Null as cInvDefine4, Null as cInvDefine5, Null as cInvDefine6, Null as cInvDefine7, Null as cInvDefine8, Null as cInvDefine9, Null as cInvDefine10, Null as cInvDefine11, Null as cInvDefine12, Null as cInvDefine13, Null as cInvDefine14, Null as cInvDefine15, Null as cInvDefine16,cs.cBatch, cs.EnumName As iSoTypeName, cs.csocode as SOCode, convert(nvarchar,cs.isoseq) as iRowNo,
cs.cvmivencode,v1.cvenabbname as cvmivenname , isnull(E.enumname,N'') as cMassUnitName,CS.dVDate, CS.dMdate,CS.iMassDate,
(iQuantity) AS iQtty,( CASE WHEN iGroupType = 0 THEN 0 WHEN iGroupType = 2 THEN ISNULL(iNum,0) WHEN iGroupType = 1 THEN iQuantity/ CU_G.iChangRate END) AS iNum,
CASE WHEN CS.bStopFlag = 1 OR CS.bGspStop = 1 THEN iQuantity ELSE IsNull(fStopQuantity,0) END AS iStopQtty,
CASE WHEN CS.bStopFlag = 1 OR CS.bGspStop = 1 THEN (CASE WHEN iGroupType = 0 THEN 0 WHEN iGroupType = 2 THEN ISNULL(iNum,0) WHEN iGroupType = 1 THEN iQuantity/ CU_G.iChangRate END)
ELSE (CASE WHEN iGroupType = 0 THEN 0 WHEN iGroupType = 2 THEN ISNULL(fStopNum,0) WHEN iGroupType = 1 THEN fStopQuantity/ CU_G.iChangRate END) END AS iStopNum,
(fInQuantity) AS fInQtty,
(CASE WHEN iGroupType = 0 THEN NULL WHEN iGroupType=2 THEN ISNULL(fInNum,0) WHEN iGroupType = 1 THEN fInQuantity/ CU_G.iChangRate END) AS fInNum,
(fTransInQuantity) AS fTransInQtty,
(CASE WHEN iGroupType = 0 THEN NULL WHEN iGroupType=2 THEN ISNULL(fTransInNum,0) WHEN iGroupType = 1 THEN fTransInQuantity/ CU_G.iChangRate END) AS fTransInNum,
(ISNULL(fInQuantity,0) + ISNULL(fTransInQuantity,0)) AS fInQttySum,
(CASE WHEN iGroupType = 0 THEN NULL WHEN iGroupType=2 THEN ISNULL(fInNum,0) + ISNULL(fTransInNum,0) WHEN iGroupType = 1 THEN (ISNULL(fInQuantity,0) + ISNULL(fTransInNum,0))/ CU_G.iChangRate END) AS fInNumSum,
(fOutQuantity) AS fOutQtty,
(CASE WHEN iGroupType = 0 THEN NULL WHEN iGroupType=2 THEN ISNULL(fOutNum,0) WHEN iGroupType = 1 THEN fOutQuantity/ CU_G.iChangRate END) AS fOutNum,
(fTransOutQuantity) AS fTransOutQtty,
(CASE WHEN iGroupType = 0 THEN NULL WHEN iGroupType=2 THEN ISNULL(fTransOutNum,0) WHEN iGroupType = 1 THEN fTransOutQuantity/ CU_G.iChangRate END) AS fTransOutNum,
(ISNULL(fOutQuantity,0) + ISNULL(fTransOutQuantity,0)) AS fOutQttySum ,
(CASE WHEN iGroupType = 0 THEN NULL WHEN iGroupType=2 THEN ISNULL(fOutNum,0) + ISNULL(fTransOutNum,0) WHEN iGroupType = 1 THEN (ISNULL(fOutQuantity,0) + ISNULL(fTransOutNum,0))/ CU_G.iChangRate END) AS fOutNumSum,
(fDisableQuantity) AS fDisableQtty,
(CASE WHEN iGroupType = 0 THEN NULL WHEN iGroupType=2 THEN ISNULL(fDisableNum,0) WHEN iGroupType = 1 THEN fDisableQuantity/ CU_G.iChangRate END) AS fDisableNum,
(CASE WHEN bInvBatch=1 THEN CASE WHEN bStopFlag =1 OR bGSPStop= 1 THEN 0 ELSE ISNULL(iQuantity,0) - IsNull(fStopQuantity,0) END + ISNULL(fInQuantity,0) - ISNULL(fOutQuantity,0) ELSE CASE WHEN bStopFlag =1 OR bGSPStop= 1 THEN 0 ELSE ISNULL(iQuantity,0) - IsNull(fStopQuantity,0) END + ISNULL(fInQuantity,0) - ISNULL(fOutQuantity,0) END) AS fAvailQtty,
(CASE WHEN iGroupType = 0 THEN 0 WHEN iGroupType = 2 THEN CASE WHEN bInvBatch=1 THEN CASE WHEN bStopFlag =1 OR bGSPStop= 1 THEN 0 ELSE ISNULL(iNum,0) - IsNull(fStopNum,0) END + ISNULL(fInNum,0) - ISNULL(fOutNum,0) ELSE CASE WHEN bStopFlag =1 OR bGSPStop= 1 THEN 0 ELSE ISNULL(iNum,0) - IsNull(fStopNum,0) END + ISNULL(fInNum,0) - ISNULL(fOutNum,0) END WHEN iGroupType = 1 THEN (CASE WHEN bInvBatch=1 THEN CASE WHEN bStopFlag =1 OR bGSPStop= 1 THEN 0 ELSE ISNULL(iQuantity,0) - IsNull(fStopQuantity,0) END + ISNULL(fInQuantity,0) - ISNULL(fOutQuantity,0) ELSE CASE WHEN bStopFlag =1 OR bGSPStop= 1 THEN 0 ELSE ISNULL(iQuantity,0) - IsNull(fStopQuantity,0) END + ISNULL(fInQuantity,0) - ISNULL(fOutQuantity,0) END)/CU_G.iChangRate ELSE NULL END) AS fAvailNum
INTO tempdb..TMPUF_13146129_heron597747400_REDFLY
FROM v_CurrentStock CS inner join dbo.Inventory I ON I.cInvCode = CS.cInvCode
left join dbo.InventoryClass IC ON IC.cInvCCode = I.cInvCCode LEFT OUTER JOIN dbo.ComputationUnit CU_G ON
I.cSTComUnitCode =CU_G.cComUnitCode
LEFT OUTER JOIN dbo.ComputationUnit CU_A ON I.cAssComUnitCode = CU_A.cComunitCode
LEFT OUTER JOIN dbo.ComputationUnit CU_M ON I.cComUnitCode = CU_M.cComunitCode
LEFT OUTER JOIN dbo.Warehouse W ON CS.cWhCode = W.cWhCode
left join vendor v1 on v1.cvencode = cs.cvmivencode
LEFT OUTER JOIN dbo.v_aa_enum E with (nolock) on E.enumcode=convert(nchar,CS.cMassUnit) and E.enumType=N'ST.MassUnit'
WHERE 1=1
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
go
Select top 1 * from tempdb..TMPUF_13146129_heron597747400_REDFLY
go
Drop table tempdb..TMPUF_13146129_heronGroup607607240_REDFLY
go
SELECT [cWhCode],max([cWhName]) as [cWhName],[cInvCode],max([cInvAddCode]) as [cInvAddCode],max([cInvName]) as [cInvName],max([cInvStd]) as [cInvStd],max([cInvCCode]) as [cInvCCode],max([cInvCName]) as [cInvCName],max([cInvM_Unit]) as [cInvM_Unit],max([cInvA_Unit]) as [cInvA_Unit],sum([iExchRate]) as [iExchRate],sum([cInvDefine1]) as [cInvDefine1],sum([cInvDefine2]) as [cInvDefine2],sum([cInvDefine3]) as [cInvDefine3],sum([cInvDefine4]) as [cInvDefine4],sum([cInvDefine5]) as [cInvDefine5],sum([cInvDefine6]) as [cInvDefine6],sum([cInvDefine7]) as [cInvDefine7],sum([cInvDefine8]) as [cInvDefine8],sum([cInvDefine9]) as [cInvDefine9],sum([cInvDefine10]) as [cInvDefine10],sum([cInvDefine11]) as [cInvDefine11],sum([cInvDefine12]) as [cInvDefine12],sum([cInvDefine13]) as [cInvDefine13],sum([cInvDefine14]) as [cInvDefine14],sum([cInvDefine15]) as [cInvDefine15],sum([cInvDefine16]) as [cInvDefine16],sum([cFree1]) as [cFree1],sum([cFree2]) as [cFree2],sum([cFree3]) as [cFree3],sum([cFree4]) as [cFree4],sum([cFree5]) as [cFree5],sum([cFree6]) as [cFree6],sum([cFree7]) as [cFree7],sum([cFree8]) as [cFree8],sum([cFree9]) as [cFree9],sum([cFree10]) as [cFree10],max([cBatch]) as [cBatch],max([iSoTypeName]) as [iSoTypeName],max([cvmivencode]) as [cvmivencode],max([SOCode]) as [SOCode],max([iRowNo]) as [iRowNo],sum([iQtty]) as [iQtty],sum([iNum]) as [iNum],sum([iStopQtty]) as [iStopQtty],sum([iStopNum]) as [iStopNum],sum([fInQtty]) as [fInQtty],sum([fInNum]) as [fInNum],sum([fTransInQtty]) as [fTransInQtty],sum([fTransInNum]) as [fTransInNum],sum([fInQttySum]) as [fInQttySum],sum([fInNumSum]) as [fInNumSum],sum([fOutQtty]) as [fOutQtty],sum([fOutNum]) as [fOutNum],sum([fTransOutQtty]) as [fTransOutQtty],sum([fTransOutNum]) as [fTransOutNum],sum([fOutQttySum]) as [fOutQttySum],sum([fOutNumSum]) as [fOutNumSum],sum([fDisableQtty]) as [fDisableQtty],sum([fDisableNum]) as [fDisableNum],sum([fAvailQtty]) as [fAvailQtty],sum([fAvailNum]) as [fAvailNum],max([cvmivenname]) as [cvmivenname],max([dMdate]) as [dMdate],sum([iMassDate]) as [iMassDate],max([cMassUnitName]) as [cMassUnitName],max([dVDate]) as [dVDate] Into tempdb..TMPUF_13146129_heronGroup607607240_REDFLY FROM tempdb..TMPUF_13146129_heron597747400_REDFLY GROUP BY [cWhCode], [cInvCode]
go
SELECT * FROM tempdb..TMPUF_13146129_heronGroup607607240_REDFLY WHERE (1 = 1) ORDER BY [cWhCode], [cInvCode]
go |
|