on 04-04-2012 9:57 AM
hi
im trying to create an alert for payments by overdue customers and its not going well. i created this query:
SELECT T1.[DocTotal] AS 'Document Total', T1.[BpAct] AS 'BP Account', T0.[DocStatus] AS 'Document Status', T0.[CANCELED] AS 'Cancelled' FROM [dbo].[OINV] T0 , [dbo].[ORCT] T1 WHERE (T1.[DocTotal] <> (0 ) AND T1.[BpAct] <> (N'0' ) AND T0.[DocStatus] = (N'[%0]' )
im getting an error:
1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near the keyword 'FOR'.
2). [Microsoft][SQL Server Native Client 10.0][SQL Server]Statement 'User-Defined Values' (CSHS) (s) could not be prepared.
please help
thank you
travelyn
Hi Travelyn,
You can try:
SELECT
T0.CardName, T0.DocNum,T0.DocTotal,T0.PaidToDate,
T0.DocStatus, T0.CANCELED AS 'Cancelled'
FROM dbo.OINV T0
WHERE T0.PaidToDate < T0.DocTotal AND DateDiff(DD,T0.DocDueDate,Getdate())>0
Thanks,
Gordon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Gordon query should work fine.
DateDiff(DD,T0.DocDueDate,Getdate())>0 is not on the tables. You will only find the docduedate field in the table OINV.
Getdate() is a function for the system date/current date on which the query is run
and the complete function works as checking the difference between the number of days between todays date and the document due date.
Need more clarification, please let us know.
Kind Regards,
Jitin
SAP Business One Forum Team
Here is the correct query alerts:
SELECT T1.[DocTotal] AS 'Document Total', T1.[BpAct] AS 'BP Account', T0.[DocStatus] AS 'Document Status', T0.[CANCELED] AS 'Cancelled' FROM [dbo].[OINV] T0 , [dbo].[ORCT] T1 WHERE (T1.[DocTotal] <> (0 ) AND T1.[BpAct] <> (N'0' ) AND T0.[DocStatus] = N'[%0]' )
you can try it again
Rgds,
JimM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check this :
SELECT T1.[DocTotal] AS 'Document Total', T1.[BpAct] AS 'BP Account',
T0.CardName as 'Business Partner Name',
T0.[DocStatus] AS 'Document Status',
T0.[CANCELED] AS 'Cancelled'
FROM [dbo].[OINV] T0 , [dbo].[ORCT] T1
WHERE (T1.[DocTotal] <> (0 )
AND T1.[BpAct] <> (N'0' ) AND T0.[DocStatus] = N'[%0]' )
Have you checked the option of having the max(T0.docdate) as an option for the last invoice added in the system for that business partner?
Kind Regards,
Jitin
SAP Business One Forum Team
User | Count |
---|---|
108 | |
15 | |
10 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.