Problem on Query Generator
Hi Expert,
I made the following query:
SELECT T0.[RefDate], T0.[TransId], T1.[Account], T1.[ShortName], T1.[Debit], T1.[Credit], T1.[ProfitCode] FROM OJDT T0 INNER JOIN JDT1 T1 ON T0.TransId = T1.TransId WHERE T0.[RefDate] between [%0] and [%1]
However error log appears as follows:
1). [Microsoft][SQL Native Client][SQL Server]Arithmetic overflow error converting expression to data type datetime. 'User-Defined Values' (CSHS)
Can you please figure out how to solve this problem?
Thanks...
ArlmiPJ
hi ArlmiPJ,
SQL Management studio has different syntax from within SBO especially if we use variables like
'[%0]'
. please try to use the ff. Query below
Rund this Query in SQL Management Studio
SELECT T0.RefDate, T0.TransId, T1.Account, T1.ShortName, T1.Debit, T1.Credit, T1.ProfitCode
FROM OJDT AS T0 INNER JOIN
JDT1 AS T1 ON T0.TransId = T1.TransId
WHERE (T0.RefDate BETWEEN CONVERT(DATETIME, '2012-01-01 00:00:00', 102) AND CONVERT(DATETIME, '2012-02-13 00:00:00', 102))
Run this Query from SBO
SELECT T0.RefDate, T0.TransId, T1.Account, T1.ShortName, T1.Debit, T1.Credit, T1.ProfitCode
FROM OJDT T0 INNER JOIN JDT1 T1 ON T0.TransId = T1.TransId
WHERE T0.RefDate between '[%0]' and '[%1]'
regards,
Fidel
Similar Messages
-
Qyery problem in query generator
Hi friends,
I have one problem regarding query generator.
I want to take the field value from the active form for query generator. I got in the demo that u have to use $[table.field]. But still I got the error.
Query which I tried.
SELECT 'TRUE' FROM OCRD T0 WHERE $[OCRD.CardCode] = '[%0]'
any one who take the value from active form as a parameter and pass to the query in the query generator please send my the sample query.
Thanks in advance.hi,
Thanks for your reply.
When I try to execute the first query from the query generator I got the error.
Error :-
Incorrect syntax near $4.0.0
statement 'Received Alerts' could not be prepared.
When I try to execute the second query from the query generator I got the error.
Error :-
Incorrect syntax near 'Ocrd.cardcode'
Statement 'Search function (CSHS)' could not bne prepared.
What would be the reason.
Please help me in solving this problem. -
Hi, I'm having sounds like silly problem using Query Generator, if I execute this query it does not give me the 'selection list' for Fiscal Year. I'm using v8.8 PL10 but in v2007 it's working fine. If I use other table like OITM w/ fieldX =N'[%0]', its working in v8.8.
SELECT T0.[Code], T0.[Name] FROM [dbo].[@BA_OAMD2] T0 WHERE T0.[U_FisYear] =N'[%0]'
thanks,
Edited by: Jojo on Jan 8, 2011 4:55 PM
Edited by: Jojo on Jan 8, 2011 4:56 PMHi, I think the problem has nothing to do w/ the SQL, because if I run it in v2007 it works but not in v8.8.
SELECT T0.[Code], T0.[Name] FROM [dbo].[@BA_OAMD2] T0 WHERE T0.[U_FisYear] =[%0]
creating inner join w/ OFPR and make where condition in OFPR.[Code] is the alternative solution, but I want to use only the code above and let me have 'list selection'
SELECT T0.* FROM [dbo].[@BA_OAMD2] T0
inner join OFPR T1 on T0.[U_FisYear] =T1.Code WHERE T1.[Code] =[%0]
I have noticed that if I use UDT in my SQL w/ variable selection the option for 'list selection' and right click on selection criteria 'List of Items' is not working. I'm using v8.8 PL10, is it a bug?
Edited by: Jojo on Jan 9, 2011 4:22 PM -
Difference in Query generated by OBIEE for same report
Hi,
I am using a a report(X) in a filter condition.
I am seeing a peculiar issue with OBIEE server. When i am running a report(X) alone, the query generated is different. But when i am using the same report in filter condition of other report(Y), the same report is generating some other query. The first report(X) is running fine but the second(Y) is not running at all.
Case 1(Report X) Query: The report is breaking into 3 parts for different fact tables and combining the data to give result.
Case 2(Report Y): A single query is being formed and within it is fecthing the data from different fact tables using subqueries.
Case2 is creating a lot of problem as the performance is totally poor.
Any suggesstions??
Thanks
TatajiHi, we haven't debugged the application or traced the query against the production server (it's in our customer's office) buy I think there's no difference since the query itself has been tested using sqldeveloper against both servers (XE 11.2 and Enterprise 11.1) and the behavior is consistent. By consistent I mean:
- The query executed via sqldeveloper against Oracle XE 11.2 runs ok and so does the application.
- The query executed via sqldeveloper against Oracle Enterprise 11.1 fails with an ORA-01790 error, and so does the application (exceptions are being logged in the Event Log).
To sum up: the same query runs ok in Oracle XE 11.2 and fails in Oracle Enterprise 11.1.
Additional information: we have tried explicit casting the NULL literals to the corresponding data types (in the UNION ALLs) and the query works fine in both versions. ¿Is there an option in ODAC to tell the query generator to write this explicit castings?
Regarding the DB schema and the LINQ query, I'll be sending them asap.
Regards,
Ernesto. -
Dear all,
I face an issue in Query generator.
When i execute the query in query generator, the error is like this
1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
'Service Contracts' (OCTR)
My query is like this
Declare @StartYear as char(4)
Declare @EndYear as char(4)
Declare @Dept as char(3)
Declare @UnitBusiness as char(3)
Begin
set @StartYear = (Select YEAR(T0.[RefDate]) from JDT1 T0 where T0.[RefDate] = [%0] )
set @EndYear = (Select YEAR(T1.[RefDate]) from JDT1 T1 where T1.[RefDate] = [%1])
set @Dept = (Select T2.[Name] from OASC T2 where T2.[Name] = [%2])
set @UnitBusiness = (Select distinct SUBSTRING(T3.[Segment_0],10,2) from OACT T3 where ( T3.[Segment_0] = [%3] OR ( 1 = (CASE WHEN [%3] = 'All' THEN 1 ELSE 2 END) ) ))
Exec NEC_RPT_FinanceReport @StartYear,@EndYear,@Dept,@UnitBusiness
End
The problem is i can not show the input screen after i execute the query generator.
If i remove the the Variable @Dept and replace with the value it runs well.
Does any one know where is the problem ?
Thanks in advance
Regards
Bodhi86HI Neetu, i have change the query without using store procedure
my query is like this
Declare @StartYear as char(4)
Declare @EndYear as char(4)
Declare @Dept as char(3)
Declare @UnitBusiness as char(3)
Begin
set @StartYear = (Select YEAR(T0.[RefDate]) from JDT1 T0 where T0.[RefDate] = [%0] )
set @EndYear = (Select YEAR(T1.[RefDate]) from JDT1 T1 where T1.[RefDate] = [%1])
set @Dept = (Select T2.[Name] from OASC T2 where T2.[Name] = [%2])
set @UnitBusiness = (Select distinct SUBSTRING(T3.[Segment_0],10,2) from OACT T3 where ( T3.[Segment_0] = [%3] OR ( 1 = (CASE WHEN [%3] = 'All' THEN 1 ELSE 2 END) ) ))
Select @StartYear,@EndYear,@Dept,@UnitBusiness
The error is like this
1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Must specify table to select from.
2). [Microsoft][SQL Server Native Client 10.0][SQL Server]Statement 'User-Defined Values' (CSHS) (s) could not be prepared.
Can you help me
Thanks in advance -
i have problems with a query, i need that have the follows fields.
SELECT T0.[DocNum] AS #Doc, T0.[NumAtCard] AS Referencia, T0.[docDate] AS Fecha, T0.[LicTradNum] AS RFC, T0.[CardName] AS 'Nombre del Cliente', T0.[DocTotalFC] AS TotME, T0.[DocRate] AS 'TC Fact', T0.[DocTotal] AS TotMS, T0.[VatSumFC] AS 'IVA ME', T0.[VatSum] FROM [dbo].[OINV] T0
But i need to know if this invoices have a PR, RF, RC,etc.
I saw that ORIN(RIN1) is for -> RC, OINV(INV9) -> RF, ORCT -> PR but i dont know how make a correctly INNER JOIN. When the invoice have a PR giveme Num of PR, if the invoice have a RC giveme the number of document destination.
So, how can i join these tables for get that information.
Thank you for you help.SELECT * FROM ORDR T0
INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
This is a basic inner join created from the SAP Query Generator
Template would be
Select <field names> FROM <base table name>
Inner join <table you want to join> on <<condition you want to two tables to joins>>
or
Simply you can write it
SELECT * FROM ORDR T0, RDR1 T1 WHERE T0.DocEntry = T1.DocEntry
it will do the same thing and you can simply join more tables.
Hope this will help...
Sanjaya -
Using Variables in Query generator
I'm using the following query to pull a report together later to be used in a query print layout. When i specify the specific part number and customer code it returns what i expect but as soon as i add a variable it says "Must specify table"!
SELECT T0.U_ACI_CAPT, T0.U_ACI_VDS1, T0.U_ACI_VDE1, T0.U_ACI_VSS1, T0.U_ACI_VSE1, T0.U_ACI_VDS2, T0.U_ACI_VDE2, T0.U_ACI_VSS2, T0.U_ACI_VSE2, T0.U_ACI_KWT1, T0.U_ACI_KWT2, T0.U_ACI_SPD1, T0.U_ACI_SPD2, T0.U_ACI_RNC1, T0.U_ACI_RNC2, T0.U_ACI_RNC3, T0.U_ACI_RNC4, T1.ItemCode, T1.Substitute, T0.U_ACI_VDS3, T0.U_ACI_VDE3, T0.U_ACI_VSS3, T0.U_ACI_VSE3, T0.U_ACI_KWT3, T0.U_ACI_SPD3, T0.U_ACI_RNC5, T0.U_ACI_RNC6, T0.U_ACI_ACDC, T0.U_ACI_PHSE, T0.U_ACI_50HZ, T0.U_ACI_60HZ, T0.U_ACI_OFRQ
FROM ((OSCN T1 INNER JOIN ITT1 T2 ON T1.ItemCode = T2.Father) INNER JOIN ITT1 T3 ON T2.Code = T3.Father) INNER JOIN "@ACI_MRBK" T0 ON T3.Code = T0.U_ItemCode
WHERE T1.ItemCode = '[%0]' AND T1.CardCode = '[%1]'
Anyone know how to get these things working?Hi,
if your problem is similar with this symptom :
Using SAP Business One Survey Variables (parameters) in a 'Set' SQL Statement can give an error in the Query Generator.
here the solution I've got from SAP notes:
In such cases you need to put in an SQL remark statement a reference field in the DB for the Survey Variable (any field).
For Example: (to make the above query work)
Declare @Num as numeric(2)
Set @Num = /* T0.DocNum */ [%0]
Select T0.DocNum
From ORDR T0
Where docnum = @Num
Good luck
Rgds,, -
Declarations in SAP QUERY generated ABAP Programs
hi,
i had created a ABAP Program through ABAP Query (SQ01,SQ02,SQ03) but i have a issue that when i transport it to the PRD server i got the run time error. The Z program which i had created is the copy of the SQ01 generated program and i had done all the includes declarations in this program. but there is a problem that it is consist of the declarations of the structures,quries .
I want to know is it necessary to always transport the Infoset and user group and the structure which is present in the program generated .
Please provide me guidelines for this problem .
Edited by: ricx .s on Jul 6, 2009 5:31 AM
Edited by: ricx .s on Jul 6, 2009 8:07 AMhi,
i had copied the program bcoz i want to chekc that it is really necessary to transport the user group and infoset so that it can achieve functionality similar to the SAP QUERY.
is there any other way without whichi can ahieve the functionality of SAP QUERY generated program and take it into the ABAP Porgram? -
Must specift the table to select from error in query generator.
SELECT OPCH.CardCode,OPCH.CardName, DateName(month,OPCH.TaxDate) + '-' + DateName(year,OPCH.TaxDate) As [Year],OPCH.TransId as [JE Ref],'IN' As [DocType]
,OPCH.DocEntry As [Base DocEntry],OPCH.WTSUM As [Recieved Amount],((OPCH.WTSUM/110.3) * 100 ) As [Invoice Amount],((OPCH.WTSUM/110.3) * 100 * 0.1) As [Service Tax]
,((OPCH.WTSUM/110.3) * 100 * 0.002) As [Edu.Cess],((OPCH.WTSUM/110.3) * 100 * 0.001) As [S.H.Cess]
,((OPCH.WTSUM/110.3) * 100 * 0.1) + ((OPCH.WTSUM/110.3) * 100 * 0.002) + ((OPCH.WTSUM/110.3) * 100 * 0.001) As [Total Service Tax]
FROM OPCH,PCH1
WHERE OPCH.DocEntry = PCH1.DocEntry
AND OPCH.WTSUM > 0
And PCH1.TargetType <> '19'
AND OPCH.DocDate >= [%0]
AND OPCH.DocDate <= [%1]
When i try to run this query in query generator system gives me error msg as "Must specify table to select from" if i remove the last two lines
" AND OPCH.DocDate >= [%0]
AND OPCH.DocDate <= [%1] "
it works fine in the query generator.
can any one help in this regards,
thanks,
praveenHai Praveen!
This problem is because of [%0] in query.
Declare @FromDate as datetime
Declare @ToDate as datetime
set @FromDate = (select min(opch.docdate) from opch where opch.docdate >= '[%0]')
set @ToDate = (select max(opch.docdate) from opch where opch.docdate <= '[%1]')
Use this query in first lines of ur query and write your query.
SELECT OPCH.CardCode,OPCH.CardName, DateName(month,OPCH.TaxDate) + '-' + DateName(year,OPCH.TaxDate) As Year,OPCH.TransId as JE Ref,'IN' As DocType
,OPCH.DocEntry As Base DocEntry,OPCH.WTSUM As Recieved Amount,((OPCH.WTSUM/110.3) * 100 ) As Invoice Amount,((OPCH.WTSUM/110.3) * 100 * 0.1) As Service Tax
,((OPCH.WTSUM/110.3) * 100 * 0.002) As http://Edu.Cess,((OPCH.WTSUM/110.3) * 100 * 0.001) As http://S.H.Cess
,((OPCH.WTSUM/110.3) * 100 * 0.1) + ((OPCH.WTSUM/110.3) * 100 * 0.002) + ((OPCH.WTSUM/110.3) * 100 * 0.001) As Total Service Tax
FROM OPCH,PCH1
WHERE OPCH.DocEntry = PCH1.DocEntry
AND OPCH.WTSUM > 0
And PCH1.TargetType '19'
AND OPCH.DocDate >= @FromDate
AND OPCH.DocDate <= @ToDate
Regards,
Thanga Raj.K -
Unable to run user defined table in Query Generator...
hi experts,
iam unable to run the user defined table in query generator..this is the query iam using...
Select T0.U_Date from dbo.@ENQHEAD T0 where T0.U_EnqNo='[%0]'
When i run this query it popups a window & asking EnqNo,when i select any enquiry no it's saying an error like----- Incorrect syntax near '@ENQHEAD'. iam unable to solve the above problem can anybody suggest me sme ideas....
thanking you,
shangai.Hi Shangai,
I've just tried to reproduce the issue and found the following query worked correctly for me:
SELECT T0.[Name] FROM [dbo].[@D01] T0 WHERE T0.[U_SO] = '[%0]''
The only difference I can see is the square brackets [] in my query?
Regards,
Niall -
Hi
I am trying to run a select query in a database which has performance problems and I get the following stats
recursive calls 47
db block gets 0
consistent gets 36909
physical reads 203
redo size 205164
bytes sent via SQL*Net to client 1873
bytes received via SQL*Net from client 1716
SQL*Net roundtrips to/from client 4
sorts (memory) 2
sorts (disk) 0
I get a lot of consistent gets and redo size compare to the same query run on a good performing db(results below). Why should a select query generate a lot of redo? Can some one suggest me where should I be looking at to resolve this issue?
Thanks
recursive calls 47
db block gets 0
consistent gets 3470
physical reads 0
redo size 0
bytes sent via SQL*Net to client 1885
bytes received via SQL*Net from client 1725
SQL*Net roundtrips to/from client 5
sorts (memory) 2
sorts (disk) 0
Edited by: APV on Nov 18, 2008 1:08 PMQueries can also generate redo if auditing is enabled. If you don't have auditing enabled and you find that a SELECT statement with no FOR UPDATE clause sometimes generates redo entries, you might be witnessing a case of delayed block cleanout
-
Wildcard empty variable query generator
Hi all,
I am using the typical [%1] variables in the query generator. However, my latest query needs to have many different variable parameters and I would like to leave some of them blank.
For example, the parameters are:
Warehouse Code [%0]
Item Group [%1]
Unit (UDF) [%2]
Row (UDF) [%3]
Column (UDF) [%4]
Problem is... I want to be able to leave some of the parameters blank and I don't want the system to filter by that parameter at all.
SO if I just want to put warehouse code in, then all the other parameters should be *. Or if i want to use item group and row, then all the others will be *. Right now I have to enter exactly what i want from all parameters, so it doesn't work very well. I figured this wouldn't be so difficult.
Any suggestions?
MThanks guys, my final code was kind of a mish mash. Works where if you don't enter any variables you will see the entire list of serialized items unfiltered, if you want to sort by location (unit, column, row, warehouse) then you can enter them as needed.
SELECT
T0.[IntrSerial],
T1.[ItemCode],
T1.[ItemName],
T2.[ItmsGrpNam] as 'Item Group Name',
T1.[ItmsGrpCod] as 'Item Group Code',
T1.[U_Unit],
T1.[U_Row],
T1.[U_Col],
T3.[WhsName],
T0.[WhsCode]
FROM OSRI T0
INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode
INNER JOIN OITB T2 ON T1.ItmsGrpCod = T2.ItmsGrpCod
INNER JOIN OWHS T3 ON T0.WhsCode = T3.WhsCode
WHERE
((T3.[WhsName] ='[%0]') OR ('[%0]'=''))
AND
((T2.[ItmsGrpNam] ='[%1]') OR ('[%1]'=''))
AND
((T1.[U_Unit] ='[%2]') OR ('[%2]' IS NULL) OR ('[%2]'=''))
AND
((T1.[U_Row] ='[%3]') OR ('[%3]' IS NULL) OR ('[%3]'=''))
AND
((T1.[U_Col] ='[%4]') OR ('[%4]' IS NULL) OR ('[%4]'=''))
ORDER BY
T1.[ItmsGrpCod],
T1.[ItemCode]
The where clauses allow you to leave the variable blank if you want, which is very handy! I know I will use this code again. -
Query Generator Funny error message
Hello Experts, Not sure if you ever seen something like this, but be great if anyone can offer me some insight...
on a normal query with parameter I have something like thsi
/*select from ORDR t0*/
declare @begandate as datetime
/* where */
set @begandate = /* t0.docdate*/ '[%0]'
and it runs fine with just about any table, view...etc.. But as soon as you have a UDT in SBO... put in like
/*select from ORDR t0*/
declare @begandate as datetime
/* where */
set @begandate = /* t0.docdate*/ '[%0]'
select * from dbo.[@bos_del_pri] a inner join ordr b on b.u_prioritycode = a.code
where b.docdate = @begandate
it give me funny error messages, "Only one epxression can be specifed in the select list when the subquery is not intrudoced with Exist"
This is ran at a SBO 2005B PL35... when I ran a similar query in SBO 2005A PL45 I get soemthing like
"must specify table to select from".. I know this error message doesn't make sense, but not sure if anyone has encounter the same problem, and if yes possible solutions?
Thank YouHello Friends,
This is in accordance to provide the information that Query Generator does not work with parameters and User defined tables together. As per my experience in SQL UDT tables start with "@" and variables declared in SQL are also prefixed with "@" so SQL does not make any difference between UDT of SAP and variable of SQL. Thus we are not able to use ([%0] parameters and UDT tables) together.
Please correct me if I am wrong.
Please forgive me if i have posted wrong information
I look forward to your reply.
Regards,
Murtaza -
How to add parameters to a stored procedure in B1 Query generator
Dear All,
I made a stored procedure in sql. I'd like to call it from B1. It's working fine when I call like this (I created an empty query in Query generator and paste this) :
exec stproc @projectFrom = '',
@projectTo = 'PRJ03',
@profitCodeFrom = '',
@profitCodeTo = 'uj',
The problem is, Could I call this procedure with parameters like normal queries (select ... where .. = [%0])? Can I pass parameters to it somehow?
Thanks a lot
JaniInside B1 :
DECLARE @return_value int
Declare @Fromdate datetime
declare @Todate datetime
declare @supp nvarchar(15)
SELECT * FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry where
T0.cardcode = '%Supp' and T0.DocDate <=%FromDate
and T0.DocDate >=%ToDate
EXEC @return_value=SQL2XMLforINV
@Fromdate= %FromDate,
@ToDate= %ToDate,
@Supp = '%Supp'
SELECT 'Return Value' = @return_value
And in SQL I have a stored procedure :
Starting like this :
PROCEDURE [dbo].[SQL2XMLforINV]
@Fromdate datetime,
@Todate datetime,
@supp nvarchar(15)
AS
DECLARE @bcpCommand AS varchar(3000)
declare @base nvarchar(50)
BEGIN
SET NOCOUNT ON;
And my error message is in B1 ....
Thanks in advance for your help .... -
Query generator used to make general total and row total
Dear experts/gurus,
I have a problem how to create general total and total field in row by using query generator. In inventory in warehouse report of SBO 2004A SP 00 PL 41, there are total row of price x quantity / warehouse (if selection criteria is warehouse) and general total. I have made query report that quite similar with inventory in warehouse report using query generator and put selection criteria and item but I still can't find out the solution. is it possible using query generator to do that or if I use query analyzer, what is the code that I have to put ? is it compute sum(qty x price) by itemcode or there is stil another ? i appreciate your answer. TIA
Rgds,Hi Jimmy,
Here's one approach to solve your problem:
= = = = = = =
select oitm.itemcode, oitm.itemname, whs.whscode, whs.quantity
from oitm inner join
(select itemcode, sum(onhand) as quantity, whscode from oitw group by itemcode, whscode) whs
on oitm.itemcode=whs.itemcode
= = = = = = =
...the main query refers to the subquery as it was another table. The subquery calculates quantity per warehouse from the oitw table.
Of course you could create a view in SQL Server instead of a subquery. That would make the query inside B1 query generator more simple and would also make it faster to execute.
Henry
Maybe you are looking for
-
PopupMenu displayed incorrectly in applet on Mac 9.2 and Netscape 7.02
Hi All, I am running an applet on Mac OS 9.2 with Netscape 7.02 (with default jvm, no additional plug-in installed). The applet contains menubar with 5 Menus (implemented using PopupMenu) options. The diffrent menus are File, Edit, Zoom, Transform an
-
Help with SAP GUI on Trial VMWare Edition
I currently have a trial version of NetWeaver installed (SAP NetWeaver 7.0.1 Java + ABAP Trial VMWare Edition), but having problems getting the GUI to work. The VM is using GNOME 2.12.2. I'm currently having trouble with SAP GUI. According to SAP h
-
Busobj.Application problem after installing BO XI 3.1
Hi, Untill recent I had a Windows server with BO server 6.5 installed. A VB script program was scheduled to export BO-reports regularly. It worked fine. Yesterday, I have installed on that BO 6.5 server, BO XI 3.1 Client tools. Since than, the progra
-
Can I download a version of application loader for Snow Leopard?
I'm not able to upgrade to mountain lion at the moment but I need to upload my app. The only version application loader I can find is for 10.7. Right now my operating system is 10.6. I've seen that you can use xcode to submit using the archive but
-
No more nautilus-columns in Nautilus 3
Apparently nautilus-columns no longer works in Nautilus 3. Is there another plugin that will read EXIF/ID3 data, or is anything being done to port nautilus-columns?