cancel
Showing results for 
Search instead for 
Did you mean: 

Query error using User Defined Files and Parameters

Former Member
0 Kudos

I am trying to select a date range with this query. When it is run without the WHERE clause, it works fine. When I add the WHERE clause, I get the error 'Received Alerts' (OAIB). Here is the code:

SELECT T0.DocNum, T0.DocDate, T0.CardName, T0.U_RMA_NUM, T1.ItemCode, T1.Dscription, T1.Quantity, T1.LineTotal, T2.Name[Return Reason Desc], T3.Name[Disposition Description],T0.Comments FROM ORDN T0 INNER JOIN RDN1 T1 ON T0.DocEntry = T1.DocEntry Left Outer JOIN [dbo].[@PRE_CUSTREA] T2 ON T0.U_RMA_CREAS = T2.Code Left Outer JOIN [dbo].[@PRE_RMADISP] T3 ON T0.U_RMA_DISP = T3.Code

WHERE T0.DocDate between [%0] and ['%1]

Does anyone have any ideas why this is erring out? Thanks for your help.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Phyllis

Try the following without the single quotes:

WHERE T0.DocDate >= [%0] and T0.DocDate <= [%1]

Just a question, is this query being linked to an alert, or are you running it from the query manager?

Kind regards

Peter Juby

Former Member
0 Kudos

I am running this query under Query Manager. That did not work either. I am now getting an error that says Incorrect syntax near '0' Here is the latest code:

SELECT T0.DocNum, T0.DocDate, T0.CardName, T0.U_RMA_NUM, T1.ItemCode, T1.Dscription, T1.Quantity, T1.LineTotal, T2.Name[Return Reason Desc], T3.Name[PreGel Disposition Description],T0.Comments FROM ORDN T0 INNER JOIN RDN1 T1 ON T0.DocEntry = T1.DocEntry Left Outer JOIN [dbo].[@PRE_CUSTREA] T2 ON T0.U_RMA_CREAS = T2.Code Left Outer JOIN [dbo].[@PRE_RMADISP] T3 ON T0.U_RMA_DISP = T3.Code

Where T0.DocDate >= [%0] and T0.DocDate <=[%1]

former_member583013
Active Contributor
0 Kudos

There seems to be nothing wrong with your query. Could you try to use dbo with the table names as shown

[dbo\].[ORDN\]

Former Member
0 Kudos

Thank you SO much for this suggestion, Suda!. It worked like a charm.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Phyllis,

I have tried to run your query without UDT. It works fine.

My suggestion is to tune your query to dig out which UDT is a trouble maker and make some changes to field type etc. accordingly.

Thanks,

Gordon

Former Member
0 Kudos

I tend to agree that the problem is with the User Defined Files. I have 2 user defined files in the query. I have taken them out one at a time and I still have the same problem. That would suggest that both files have a problem. How do I find the problem and then change the field type?

Former Member
0 Kudos

To narrow the problem down is a technique to debug. You must be creative. If you can add just two UDF to start with, it may be easier.

Former Member
0 Kudos

Hi Phyllis

If you are using 2007 then you must use single quotes before and after the square brackets in variables for dates. I know that in some earlier versions, SAP did not require the single quotes for variables.

Kind regards

Peter Juby

Former Member
0 Kudos

I am using 2005 A but I tried your suggestion anyway. It still does not work but I get a different error - Conversion failed when converting dattime from character string. Any other ideas?