Query Generator Variable Alias

Hi,
How can I create an alias for variables in scripts made with query generator? For example, if i include where clauses such as begin date and end date using greater/less than, they will be both shown in the criteria selection box as "Posting Date." This may be confusing to users unfamiliar with the query format. Can I change these prompt names? Thank you.

Hi Allen,
If you mean the selection box when you run query to input values, then the answer is no.  The selection box will only desplay the field description like you can see in DTW template.
For the query results, I am sure you know how alias can be assigned
Thanks,
Gordon

Similar Messages

  • Query Generator/Variables

    In Query Generator I need to prompt for dates using [%0] and [%1].  However, I get an error once I input dates.  Do the query variables come in as string format and if so, how do I compare a date input

    I'm not a specialist on this, but I have to learn this for the Certification exam. So, I played with Queries and noticed that the date format is driven by the Date format parameter in Administration - General settings - Display.
    I tried the following query:
    SELECT CardCode, UpdateDate FROM OCRD T0 WHERE T0.UpdateDate >= '[%1]'  ORDER BY T0.UpdateDate
    When the date format is CCYY-MM-DD it works with 2003-11-31 and 03-11-31 and 03.11.31.
    When the date format is set to DD.MM.YYYY the query runs OK with 31.12.02.
    HTH
    Juha

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

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

  • SQL Query with variable range

    Hi
      I want to give range to a user to enter in a variable through sql query . If there are 200 records , if user wants to display from 5-45 , 75-110 , 130-145. how it can be done through SQl Query
    Thanks
    Edited by: Matt on Aug 31, 2010 6:23 PM - modified title - please use a meaningful title in future

    Dear Saini,
    This query will allow you to choose the values only when you know them.
    SELECT T0.[DocEntry], T0.[ItemCode] FROM INV1 T0 WHERE T0.[LineNum] >[%0]   and T0.[LineNum] <[%1]
    If you run it in the query Generator in SAP Business One a little window will pop up and will ask you to choose the 2 variables.
    You can choose different variables every time you run it. At least you won't have to save many queries with different values.
    If you want 2 different groups, e.g. from 10 to 20 and from 30 to 40, then you can add another part in the where clause:
    SELECT T0.[LineNum], T0.[ItemCode], T0.[DocEntry] FROM INV1 T0 WHERE T0.[LineNum]  >= [%0] and  T0.[LineNum]  <= [%2] and T0.[LineNum]  >= [%4] or  T0.[LineNum]  <= [%6]
    Please, let me know if this query helps.
    Regards,
    Marcella Rivi
    SAP Business One Forums Team

  • 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 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.)

  • 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

  • Sales report from query generator

    Hi Experts,
    Im using query generator i had given selection criteria like, Posting date from and To, Profit centre, Numbering series name,
    query:
    SELECT T0.[DocNum], T0.[VatSum], T0.[DocTotal], T1.[PrcCode], T1.[PrcName], T1.[Balance] FROM OINV T0 , OPRC T1 INNER JOIN NNM1 T2 ON T0.Series = T2.Series WHERE T0.[DocDate] > ='[%0]' AND  T0.[DocDate] < ='[%1]' AND T1.[PrcCode] ='[%2]', T2.[SeriesName] ='[%3]'
    Error:
    1.     1)(Microsoft)SQL Native client)(SQL Server)Incorrect syntax error near u2018 u2018,Microsoft(SQL Native client) (SQL Server)statement u2018User Defined Valuesu2019 (CSHS)(1) could not be prepared.
    can u give any idea to solve this problem,
    thanks in advance,
    anand.r

    Hi,
    I made a mistake in the variables:
    SELECT     T0.DocNum, T0.VatSum, T0.DocTotal, T1.PrcCode, T1.PrcName, T1.Balance
    FROM         dbo.OPRC AS T1 INNER JOIN
                          dbo.OINV AS T0 INNER JOIN
                          dbo.NNM1 AS T2 ON T0.Series = T2.Series ON T1.PrcCode = T0.Project
    WHERE     (CAST(T0.DocDate AS VarChar) <= [%1]) AND (T1.PrcCode = [%2]) AND (T2.SeriesName = [%3]) AND (CAST(T0.DocDate AS VarChar) >= [%0])
    Kind regards,
    Hendri Wessels
    EDIT: I see that the variables do work in B1UP like this, but not in SAP Query generator.
    Edited by: Hendri Wessels on Jul 27, 2009 8:58 AM

  • Declare func on Query Generator

    Hi,
    I am Using SAP B1 for hana ver 9.0 PL10
    I have a difficulty to use Declare function as variable reference in Query Generator, Any tips for this matter ?
    Thanks

    You can do this using the SAP Business One Query Manager. The code below calls a stored procedure with one parameter of the DateTime type, which the user is prompted to enter:
          declare @tmp as nvarchar(100)
          select @tmp = T0.Name from [@ADV] T0
          WHERE T0.U_Date = '[%0]'
          EXEC myReport '[%0]'
    The table @ADV is used just to let SBO know that the actual type of the [%0] parameter is Date.

  • Making generated variable names?

    Hey, I'm trying to make new Vector variables given some input I already have. I'm doing it as follows:
    for (int i=0; i < commandName.size()-1; i++) {
    String newVariableName = commandName.elementAt(i).toString();
    Vector newVariableName = new Vector();
    Of course, it's not working - but do you know if it is possible to generate variable names in this manner?

    Use HashMap.
    You will generally find that most languages that offer variable dereferencing are also essentially "typeless", although you can sometimes query what the type of the "value" of a variable is.
    HashMap does this exactly, with the bonus that you can double your namespace by creating two maps! :-)

  • CAN WE HAVE IF CONDITION IN QUERY GENERATOR

    Hi friends,
    am, trying to make use of if condition to obtain a set of values in query generator.  Its possible to retrieve the required result set using query analyser but not in query generator.  am trying to execute the following query
    if exists (select owor.u_reactor from owor,oitt where oitt.code=owor.itemcode and owor.u_reactor = 1 and owor.itemcode = '100-100')
    begin
                    select itt1.u_reactor1 from oitt,itt1 where itt1.father = oitt.code and itt1.father = '100-100'
    end
    else
    if exists (select owor.u_reactor from owor,oitt where oitt.code=owor.itemcode and owor.u_reactor = 2 and owor.itemcode = '100-100')
    begin
         select itt1.u_reac_23 from oitt,itt1 where itt1.father = oitt.code and itt1.father = '100-100'
    end
    else
    if exists (select owor.u_reactor from owor,oitt where oitt.code=owor.itemcode and owor.u_reactor = 3 and owor.itemcode = '100-100')
    begin
         select itt1.u_reactor4 from oitt,itt1 where itt1.father = oitt.code and itt1.father = '100-100'
    end
    if it is not possible to write such query in query generator  can someone help me with a workaround solution.
    Thank u
    Vaitheeswaran

    Hi,
    I dont think Nested IF Statements are allowed in PLD. The reason that u get the result in Query analyser and not in Query Generator is that SAP supports Transact SQL and many SQL Server 2000 functions are not supported.
    However there is a work around in Print Layout Designer for using IF condition by having Linked Objects. Kindly see some tutorials regarding Linked fields available on SDN site and think of some other way of implementing this nested IF query.
    Regards
    Rizwan Hafeez
    Team Lead
    SAP Addon Development Section
    Abacus Consulting - Pakistan

  • How to do this in Query Generator?

    Dear Experts,
    Please check my following query I've written in Query Generator.
    /* select from dbo.OCRD t0 */
    declare @BP nvarchar(20)
    set @BP=/* t0.CardName */ '[%0]'
    declare @Dt1 datetime
    declare @Dt2 datetime
    set @Dt1=/* Start Date */ [%1]
    set Dt2=[%2]
    select distinct t1.po, Max(t1.supplier) Supplier,Max(t1.process) Process, Max(t1.OrderNo) OrderNo,Max(t1.Date) Date,
    isnull((select sum(t2.Quantity) from dbo.ir t2 where t2.po=t1.po and t2.TType<0),0) Issued,
    isnull((select sum(t3.Quantity) from dbo.ir t3 where t3.po=t1.po and t3.TType>0),0) Received,
    isnull((select sum(t2.Quantity) from dbo.ir t2 where t2.po=t1.po and t2.TType<0),0)-isnull((select sum(t3.Quantity) from dbo.ir t3 where t3.po=t1.po and t3.TType>0),0) Balance
    from dbo.ir t1 where t1.Supplier=@BP and (t1.Date>=@Dt1 and t1.Date<=@Dt2) group by t1.po
    The Query works well. But for the the lines
    set @Dt1=/* Start Date */ [%1]
    set Dt2=[%2]
    it displays BP Code as the prompt next the text boxes meant for inputting dates. I would like to display 'Start Date' and 'End Date' respectively for Dt1 and Dt2.
    Please explain me how to go about it.
    Thanks in advance.
    Regards
    Anand

    declare @Dt1 datetime
    set @Dt1=/* Start Date */ [%0]
    declare @Dt2 datetime
    set @Dt2=/* End Date */ [%1]
    /* select from dbo.OCRD t0 */
    declare @BP nvarchar(20)
    set @BP=/* t0.CardName */ '[%2]'
    I've changed. When I run the query the input box does not appear, the query shows only a blank table.
    Thanks
    Anand

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

Maybe you are looking for