Query Generator Parameter Problem

Hi Expert ,
I'm using below query to display only customer code for parameter selection but its displaying Vendor code too.
Kindly guide me.
Declare @Fromdate Datetime
Declare @frmcode nvarchar(max)
Declare @Tocode nvarchar(max)
set @Fromdate = (select  MAX(T12.RefDate) From JDT1  T12 where T12.RefDate  <= '[%0]')
set @frmcode = (select  MIN(T13.cardcode) From ocrd t13 where t13.CardType='c'  and   T13.cardcode  >= '[%1]')
set @Tocode = (select  MAX(t14.cardcode) From   ocrd t14 where   t14.CardType='c'  and  T14.cardcode  <= '[%2]')
Thanks
-Rajesh N

Hi,
The query is working fine. If you add selection parameter for card code, it will show all BP code regardless of card type condition. But when you select for example vendor code, no result will be displayed.
Try without declare statement also same result.
Thanks & Regards,
Nagarajan

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.

  • Query Generator 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 PM

    Hi, 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

  • User defined query parameter in query generator

    Hi All,
    i am using query generator in SAP to print some records of user defined query. precisely, the details about sales employees are to be printed. now the columns which exist in the database (ie. sales employee code, name, cardcode) etc can be given as a parameter like [%0] and [%1]. but some user defined parameter such as sales commission does not show as such parameter. i want one column as
    select T0.doctotal, (T0.doctotal * [%0]) / 100  as brokerage from OINV T0
    --where [%0] is some commission percentage that the user will give while running this query
    This query gives correct results but it gives the parameter name as 'doctotal' while showing. any idea as to how to handle it properly in SAP?
    thanks in advance,
    Binita
    Edited by: Binita  Joshi on Sep 8, 2009 3:35 PM

    I sometimes defined a UDT only for getting the appropriate parameter entering window. The table has no data; I used it only for its field names in this window.
    (The parameter request can be placed inside a comment and the entered value is used setting an SQL variable like this:
    declare @d datetime
    /*select t.createdate from ordr t where t.createdate=[%0]*/
    set @d=[%0]
    This SQL variable can be used later in the real query.)

  • CANT execute query with parameter on user defined tables using query genera

    Dear All,
    I have problem when executing query with parameter on user defined tables using query generator.
    It seems SBO cannot accept parameter to query user defined tables.
    I've tried these:
    SELECT T0.U_Status FROM [@ST_PR_H] T0 WHERE T0.U_Status = [%0] --- this FAIL
    I try to pass the value directly without using parameter and It works
    SELECT T0.U_Status FROM [@ST_PR_H] T0 WHERE T0.U_Status = 2 --- this SUCCESS
    This one works
    SELECT * FROM RDOC T0 WHERE T0.width =[%0]  --- this SUCCESS
    and this one works too
    SELECT * FROM RDOC T0 WHERE T0.width = 595  --- this SUCCESS
    Is there anyone can help me ....???
    Thanks,
    Alfa

    I  generated this code using query wizard ....
    SELECT T0.[U_Status] AS 'Document Status' FROM  [dbo].[@ST_PR_H] T0  WHERE T0.[U_Status] = (N'2' )
    and replaced the (N'2' ) with [%0]
    SELECT T0.[U_Status] AS 'Document Status' FROM  [dbo].[@ST_PR_H] T0  WHERE T0.[U_Status] = [%0]
    and It worked ......
    Thanks 4 all .....

  • Using JhsUserRole in Query Bind Parameter

    Hi there,
    I'm working with JDeveloper 10.3.4.0.
    I've define a bind variable, and I want to fill it in Jheadstart as "Query Bind Parameter".
    It should be a conditional statement which checks user permissions, like this:
    BindUserID=#{JhsUserRoles['Issue.OwnOrg'] ?  413 : 412} Using this statement, I receive this error message:
    javax.faces.FacesException: javax.faces.el.ReferenceSyntaxException: '#{JhsUserRoles['Issue.OwnOrg'] ?   413 : 412}'It seems that the ' (single quote) character causes problem in the bean file (XML syntax, nested single quotes):
    <key>BindUserID</key>
              <value>#{'#{JhsUserRoles['Issue.OwnOrg'] ? 413 : 412}'}</value>As I've searched, the character escaping mechanism in XML, is based on using Unicode, so I changed the statement to this:
    {noformat}<key>BindUserID</key>
              <value>#{'#{JhsUserRoles[#39;Issue.OwnOrg#39;] ? 413 : 412}'}</value>{noformat}But It interprets #39; to ' and I still get the same error message. (Obviously the Unicodes start with &, I've omitted them to be able to display it in this message)
    So, I want to know if there is anyway to fix this problem.
    Thank you in advance
    Farnoush

    Steven,
    Thanks for your reply.
    But, it seems that .xml bean files are not case sensitive, so JhsUserRoles works as well.
    About your suggested expression it does not work either.
    I solved the problem in this way, I edited the bean file and replace the outer *'* with *"*.
    {code}<key>BindUserID</key>
    <value>#{"#{JhsUserRoles['Issue.OwnOrg'] ? 413 : 412}"}</value>
    {code}
    And then I removed the tick of "Generate Controller Group" of the my jheadstart group.
    This solves the problem.
    Farnoush

  • 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?
    M

    Thanks 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 You

    Hello 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

  • Can a single quote be used at the beginning of a query string parameter

    Hi all,
    I am a relative newbie and have a newbie question.
    Can a single quote be used at the beginning of a query string parameter passed to a jsp page? Are there any inherant problems with this? Is there a comprehensive list of characters that must be escaped in a query string parameter?
    Example: http://mysite.com/myjsp.jsp?param1='nghdh
    Thanks

    You'll have to escape most non-letter characters before you can pass them as a URL. I don't know if it's necessary for a single quote, but better safe than sorry.
    Either use java.net.URLEncoder(...) or use javax.servlet.http.HttpServletResponse.encodeURL(String). I wouldn't recommend using unescaped characters in your URLs, that might cause pretty funny behavior that's sometimes hard to trace back. Don't worry about decoding it, your JSP/Servlet container will do it when you call javax.servlet.http.HttpServletRequest.getParameter(String).

  • 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
    Tataji

    Hi, 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.

  • Error in Query generator

    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
    Bodhi86

    HI 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

  • Query bind parameter in Advanced Search

    Hi,
    We are using a query bind parameter in an Advanced Search . The parm that is passed is on an Lov field which works when we use the lov to populate the field but doesn't get passed if we enter the value manually instead.We are using the setActionListener tag in a copy of the findLovItem.vm file:
    &lt;af:setActionListener from="#{searchxxxx.criteria.xxxx+attributename+}"
    to="#{QueryBindParamBean.+attributename+}"
    The 'from' value is taken from the 'value' field in SelectInputText tag of that attribute ('+attributename+') found in the Advanced_Search_Lov_Item in the .jspx. We are doing the exact same thing in a form view (not the search) for the same attributes but are using the corresponding value for that attribute instead and it works no problem:
    &lt;af:setActionListener from="#{xxxx+attributename+LovItem.lovFieldValue}"
    to="#{QueryBindParamBean.+attributename+}"
    any ideas why the value isn't being passed in the search page when entered manually?
    thanks!

    Hi,
    It does not directly ring a bell for me why you cannot copy this value. But since JHeadstart is simply using a bean with a Map to store it's values, it does not sound like a JHeadstart issue per se.
    To simplify the test case, you could create a simple drag-and-drop ADF application without JHeadstart and see if the same problem occurs there. If so, can you please log a TAR at MetaLink ( http://metalink.oracle.com/ ), or ask this question at the JDeveloper forum? Thanks.
    Evert-Jan de Bruin
    JHeadstart Team

  • 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 AM

    hi,
    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?

  • Send values to IN query with parameter

    Subject: send values to IN query with parameter
    Hello. Hope I'll explain my problem well enough:
    I have a query:
    -- select id from table where id in ('100')
    Now I used parameter for the IN part:
    -- select id from table where id in (:param)
    and I gave the parameter the value 100.
    now I want to have the query with two values:
    -- select id from table where id in ('100','200')
    I tried to use the parameter and give him the value of: '100','200'.
    It didn't worked :(
    Is there a syntax to give the parameter more then one value for the IN query (with out using another table or function etc')?
    Thanks in advance,Roy.

    This is the best solution I have for it.
    variable parameter varchar2(4000);
    exec :parameter := 'SYSTEM,SYS';
    select username
    from dba_users
    where username in ( select COLUMN_VALUE from table  (split_string(:parameter,',')))It uses this function
    CREATE OR REPLACE
    type string_table  as table of varchar2(4000)
    CREATE OR REPLACE
    FUNCTION split_string (
         string IN varchar2,
        delimiter IN varchar2
    ) RETURN  string_table IS
         tab string_table;
         pre integer;
         post integer;
         step integer;
         i integer;
    BEGIN
         pre := 1;
         step := length(delimiter);
         i := 0;
         tab := string_table();
         loop
              tab.extend;
              i := i + 1;
              post := instr(string,delimiter,pre);
              if ( post = 0 ) then
                   tab(i) := substr(string,pre);
                   return tab;
              end if;
              tab(i) := substr(string,pre,post-pre);
              pre := post + step;
         end loop;
    END;
    /Bye Alessandro

Maybe you are looking for

  • Flex App not working in IE9

    Friends, We have a Flex browser based app (Flex 3.6 SDK) and it has been running smoothly on IE since last 1 yr. Front-end is Flex, Middle layer Fluorine web services aka .Net, back-end is SQL. One of our customer reported this peculiar problem that

  • Unable to Activate Smartform After ERP 6.0 Upgrade

    Since upgrading from R/3 4.7 to ECC 6.0 one of our smartforms has stopped functioning in the upgraded DEV environment. When running the check on the smartform the following error is displayed: Global Definitions      Field "STRING" is unknown. It is

  • Everything deleted

    so i updated my phone and everything got deleted that was saved after april 12th. I'm really upset because i had some very important pictures. but the problem is there is nothing on iCloud or my photo stream so i can't seem to get anything back. is t

  • Failed to load DLL: HSAPI during Software Installation of Palm TX for Windows XP

    I have been attempting to load Palm TX software for Windows XP and receive error number: 0x80040702 Failed to load DLL: HSAPI.  I am able to download the zipped software from the Palm site.  After unpacking and beginning installation, I receive the e

  • Need Guidance To Overclock K8N Diamond Plus

    Helo Everyone, Newbee R8 Here.Need A Bit Guidance To Overclock My System.I Heard My Mobo Is Not Ideal For Overclock.I Had Never Overclocked It.Even I'm Not So Experienced To Do It.I Just Want To Do Tht As A Experiment.My Current CPU Runs At 2.01 Ghz