自动根据用户查看对应销售员销售订单
小于 1 分钟
这一段取当前用户
- 查询报表:自动根据用户查看对应销售员销售订单
示例代码
DECLARE @userid varchar(20)
SELECT @userid = c.[U_NAME]
FROM[master].[dbo].[sysprocesses] a
INNER JOIN [dbo].[USR5] b
ON a.[spid] = b.[SessionID]
AND a.[hostprocess] = b.[ProcessID]
INNER JOIN [dbo].[OUSR] c ON b.[UserCode] = c.[USER_CODE]
WHERE a.[spid] = @@spid
AND b.[Action] = 'I'
ORDER BY b.[Date] DESC
-------------------------------------------
SELECT T0.[CardName], T0.[DocNum], T0.[TaxDate], T1.[ItemCode] AS '物料编号', T1.[Quantity] AS '数量'
, T1.[Price] AS '单价', T1.[LineTotal] AS '行总计', T0.[DocTotal], T0.[PaidToDate] AS '已清'
FROM ORDR T0
INNER JOIN RDR1 T1 ON T0.[DocEntry] = T1.[DocEntry]
INNER JOIN OSLP T2 ON T0.[SlpCode] = T2.[SlpCode]
WHERE T0.[CANCELED] = 'N'
AND T0.[TaxDate] >= [%0]
AND T0.[TaxDate] <= [%1]
AND T0.[DocType] = 'I'
AND T2.SlpName = @userid
ORDER BY T0.[DocNum] DESC