Skip to Content
0
Former Member
May 05, 2010 at 03:30 PM

Query Issue

16 Views

Hello

I wrote the following query for purpose of returning open quotes for the following day for the person logged into SAP.

I'm having an issue with: T3.INTERNAL_K = $[user]

It keeps coming back with a "service contracts" error. can I not use this variable within this query? any suggestions on modify it?

I don't want the user to have to enter any variables

SELECT T0.[U_SalesEmployee] AS 'Sales Employee', T0.[U_Create] AS 'Created', T0.[U_NumLevel] AS '#Levels',

T0.[U_Customer] AS 'Customer', T0.[U_CardCode] AS 'CustId', T0.[U_NumAtCard] AS 'Cust Ref/PO', T0.[U_Type] AS 'Type',

T0.[U_Status] AS 'Status', T0.[U_SubEnd] AS 'Expires',T0.[U_CntctPrsn] AS 'Contact', T0.[U_TotalPrice] AS 'Total Price',

T0.[U_SubNum] AS 'Quote #' FROM [dbo].[@LBSISUBH] T0 (nolock)

join OCRD t1 on T0.U_CardCode=t1.CardCode

join OHEM t2 on t1.SlpCode=t2.salesPrson

join OUSR T3 on t2.userId=T3.USERID

WHERE T0.[U_Type] = 'Quote' and T0.U_Status = 'Open' and

T0.U_NumLevel > 0 and (convert(varchar, T0.[U_create], 1) = convert(varchar, getdate()-1, 1))

and T3.INTERNAL_K = $[user]

order by T0.U_SalesEmployee, T0.U_Type, T0.U_TotalPrice