Query with 2 variables

I have a query with two variables (Employee and Date). The query is working fine if both of the variables are check and values assigned. But if only one variable is checked and a value assigned then the query will return 0 results. Is it possible that the query cannot work with only one variable out of the 2? Do I need a workaround or am i doing something wrong?
Here is the query:
SELECT T0.DocNum, T0.DocDate, T0.DocDueDate, T0.CardCode, T0.CardName, T0.Address, T0.DocTotal, T0.U_Employee, T1.firstName,T1.lastName,  T0.Comments FROM OVPM T0 LEFT JOIN OHEM T1 ON T0.U_EMPLOYEE = T1.FIRSTNAME' 'T1.LASTNAME WHERE T0.DocType = 'A' AND T0.U_EMPLOYEE = [%0] AND T0.DocDate =[%1].
Thank you so much for your help,
Irina Stanca

AFAIK, at least with 'complex queries' unchecked parameter gets
some default/blank value. Therefore, you should allow default values in your
WHERE clause.
You want: WHERE T0.COL = @VAR
You write: WHERE (T0.COL = @VAR OR [logical test for @VAR is a default value])
Snippets like this may help you in finding out that default value:
-- snip --
/SELECT FROM [dbo].[OHEM] T9/
declare @VAR_EMPL as char(20)
/* WHERE */
set @VAR_EMPL = /* T9.lastName */ '[%0]'
/SELECT FROM [dbo].[OVPM] T8/
declare @VAR_DATE as char(20)
/* WHERE */
set @VAR_DATE = /* T8.DocDate */ '[%1]'
SELECT '@VAR_EMPL: ' + '|' + @VAR_EMPL + '|' +  '@VAR_DATE: ' + @VAR_DATE + ' DATEDIFF: ' + cast(DATEDIFF(day, CAST('1900-01-01' as datetime), CAST(@VAR_DATE as datetime)) as varchar)
[/code]
-- snip --
Yes, it looks like the default value for dates is '1900-01-01'.
Therefore, you may want to code this way
.. WHERE (DocDate = @VAR_DATE OR DATEDIFF(day, CAST('1900-01-01' as datetime), CAST(@VAR_DATE as datetime)) > 0)
I also noticed a date-related issue that may cause problems in complex queries
if you work with dates from last century AND if your date format in B1 is YY instead of CCYY:
you enter 1907 and B1 interprets it as 2007.
HTH
Juha

Similar Messages

  • Report Designer - Query with variable

    Hi!
    When testing the report designer, we have found an issue - it’s not possible to embedding queries with variables.
    We have found note https://websmp107.sap-ag.de/~form/sapnet?_FRAME=CONTAINER&_OBJECT=012006153200000232982006
    that suggest a solution to the issue.
    My question is simply, does anyone know if this is a temporary fix, or is this a constraint that is not planned to be fixed by SAP? The note is a bit ambiguous.
    BR
    bjørn

    Hello,
    Queries with variables are still in restrictions for Report Designer.
    You can use this work-arond creating Query View and fill up the variables. This allows you to define a Report in RD. Then, use Web Appication Designer to include your Report into Web Application and replace the Query View with your initial Query.
    For the integration do following:
    1. Create new Web Template in WAD
    2. Drag-and-drop Web Item "Report"
    3. Go to Property Window in WAD and search for "REPORT" (description Report Design) parameter in Web Items Parameters
    4. Use the button on the right side of the parameter to open Report Designer and choose your Report in it.
    5. You should see that new Data Provider was created in WAD -> Open it and set it to your initial Query.
    5. Save you Web Template and execute in the browser.
    Regards, Karol
    Development BI

  • Copy function based on the query with variables

    Hello
    Let me share the scenario I need to implement. I have a planning query with layout like shop / material / sales volume. The variables are shop number and calendar month. User opens the planning query, selects shop number and month, then sees the list of materials and puts the planned sales volume, then saves as a temporary version. Saving as a temporary version is realized by standard u201Csaveu201D function. The matter is that the user needs to have a possibility to copy this version to official one. I created the button and linked it with the copy function. The problem is that when a user clicks this button, the function asks him/her to provide variables again. I would like to have the button which copies the data with the same selection criteria as the query already has.
    Any idea?
    Arelis.

    Hi,
    I think when you add the button you specify the planning sequence name and that takes the filter of the modeler .Now when you try to call the planning sequence the filter variables are also added to the button as VAR_NAME, VAR_VALUE which prompts you for the variable again.Delete VAR_NAME,VAR_VALUE at the back of the button  manually and then save your work book.Then it will not ask for variable entry and the values that you have specified in the query filter will pass on to modeler filters.As variables are global.
    Similarly if you are using planning function then at the back of the button remove the VAR_NAME,VAR_VALUE.
    Hope this may help.
    Regards,
    Indu

  • 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 while executing Query with Variable.

    Hi All,
    I have written a query to fetch values from some user tables and sap tables. The query is as below.
    select a.docentry,a.u_scname,e.block,e.[City],
    e.[Country], e.[State1],
    e.[StreetNo], e.[ZipCode],
    e.[Building], e.[Cellular],a.[U_WONo], a.[U_DocDate],
    a.[UserSign], b.[LineId], b.[U_Des],
    b.[u_SDes], b.[U_UoM],
    b.[U_Qty], b.[U_Rte],
    b.[U_Tamt], a.[U_PrjName], a.[u_WO_PB],
    a.[U_WO_UL], a.[U_WO_FC],
    a.[U_WO_PYT], a.[U_WO_COP],
    a.[U_WO_TRMT], a.[U_WO_DocSub],
    a.[U_WO_ADV], a.[U_WO_OCondition],
    a.[U_WO_PRPBY], a.[U_WO_RCMBY],e.[CntctPrsn],
    (T4.[WhsName]+ '-' + T4.[Street] +'-' + T4.[Block])  as 'Work Address ',
    T4.[Building], T4.[City],
    T4.[ZipCode], T4.[U_PMCNT],  T4.[WhsName], e.Taxid0
    from [@e360_owor] as a join [@e360_wor1] as b
    on a.docentry = b.docentry
    left outer join
    ( select c.cardname,d.TaxId0,d.Taxid1, c.block, c.[City],
    c.[Country], c.[State1],
    c.[StreetNo], c.[ZipCode],
    c.[Building], c.[Cellular], c.[CntctPrsn]  from ocrd
    as c  join crd7 as d  on  c.cardcode = d.cardcode 
      where d.TaxId0 is not <b>null</b> ) as e
    on
    a.U_SCName = e.CardName 
    left outer join OWHS T4 on T4.[WhsName] = a.[U_Prj]
    where
    a.U_WONo = '[%0]'
    In this code, when the variable is assigned to field U_WONo, then I get an error
    Must Specify A Table To Select From. Statement 'Service Contractors' (OCTR) (s)  could nto be prepared.
    But when the values for variables are hard coded, the query executes.
    I have been working on it from long time, but same error exists. Could anybody help resolve the same...
    I am using SAP B1 2007 B, patch level 15.
    Thanks in advance,
    Regards
    Rohan

    The error messages may be misleading. With complicated queries with parameter request I frequently saw references to service contract (or something other).
    Sometimes SBO does not manage correctly variables in complicated queries and there is a note about the workaround to solve the problem:[Note730960|https://websmp130.sap-ag.de/sap/bc/bsp/spn/sapnotes/index2.htm?numm=730960]

  • Refresh Query with variable is not working

    I have issue with my query.
    0customer -Property (key and text) and Selection parameter
    When I place 0customer in the filter area and save the query execute the query and refresh the query I am able to change the customer number parameter values.
    Variable has option  Can be changed during query execution. Filter value is also not displaying in the report
    When I move 0customer in the  Row area and save the query -first time it is displaying the selection parameter values and when you hit refresh it will refresh the same query .but it is not populating the selection parameter .
    advance thx

    You can display values& texts for variables using menu button where you can display the text elements.
    Regards
    Pradip

  • Query with variable defined date no idea how

    Hello to all,
    i have a problem with a query, in this query i need a variable date that can be entered in the SQL statement.
    If the CREATE TABLE and INTO Values are needed, they can be found here:
    Re: Need Help with complex query for productio database
    with t2 as (
                select  t.*,
                        lead(step_date) over(partition by order_nr order by step_date) next_step_date
                  from  table_2 t
    select  t1.*,
            nvl(
                max(
                    case t2.wo_step
                      when 'U' then t2.step_date
                    end
               sysdate
              ) - t1.create_date age_1,
            nvl(
                max(
                    case t2.wo_step
                      when 'R' then t2.step_date
                    end
               sysdate
              ) - t1.create_date age_2,
            sum(
                case
                  when t2.wo_step in ('B','5') then t2.next_step_date - t2.step_date
                end
               ) step_b_5,
            sum(
                case t2.wo_step
                  when 'C' then t2.next_step_date - t2.step_date
                end
               ) step_c,
            sum(
                case t2.wo_step
                  when 'K' then t2.next_step_date - t2.step_date
                end
               ) step_k,
            sum(
                case t2.wo_step
                  when 'E' then t2.next_step_date - t2.step_date
                end
               ) step_e,
            sum(
                case t2.wo_step
                  when 'F' then t2.next_step_date - t2.step_date
                end
               ) step_f,
            sum(
                case t2.wo_step
                  when 'S' then t2.next_step_date - t2.step_date
                end
               ) step_s,
            sum(
                case t2.wo_step
                  when 'R' then t2.next_step_date - t2.step_date
                end
               ) step_r
    ,          CASE
                   WHEN      t1.priority = '02'
                   AND          nvl(
                               max(
                                   case t2.wo_step
                                     when 'U' then t2.step_date
                                   end
                                        sysdate
                             ) - t1.create_date >= 5
                   THEN     'FALSE'
                   WHEN      t1.priority = '05'
                   AND          nvl(
                               max(
                                   case t2.wo_step
                                     when 'U' then t2.step_date
                                   end
                                        sysdate
                             ) - t1.create_date >= 8
                   THEN     'FALSE'
                   WHEN      t1.priority = '12'
                   AND          nvl(
                               max(
                                   case t2.wo_step
                                     when 'U' then t2.step_date
                                   end
                                        sysdate
                             ) - t1.create_date >= 30
                   THEN     'FALSE'
                   ELSE     'TRUE'
              END AS "IN MPD"                                  
      from  table_1 t1,
            t2
      where t2.order_nr = t1.order_nr
      group by t1.order_nr,
               t1.priority,
               t1.create_date,
               t1.act_step,
               t1.step_date,
               t1.employee,
               t1.descriptionIn this query i want to replace sysdate with a variable date that i want to define one time, maybe in the first line of the SQL query or one of the Top lines.
    The reason for this is, i want my results to an specific date, well i can change da system time but i want to solve that in the query.
    Or if there is a way to get promted for this variable each time when the qury runs, that would also be fine.
    I tried already DEFINE BEGIN END, but i get only a bunch of errors. I thins i do a basic mistake.
    Thank You all.

    Hi,
    To create and set a bind variable in SQL*Plus, you can do this:
    VARIABLE  base_date_text   VARCHAR2 (20)
    EXEC     :base_date_text := '01-Mar-2013 00:00:00';:base_date_text can now be used anywhere in your query where a string is allowed. Unfortunately, you can't have DATE bind variables, so that means it's only useful in calls to TO_DATE.
    You could calll TO_DATE everywhere you are now calling SYSDATE, or you could do something like this:
    with t2 as (
                select  t.*,
                        lead(step_date) over(partition by order_nr order by step_date) next_step_date
                        TO_DATE (:base_date_text, 'DD-Mon-YYYY HH24:MI:SS')   AS base_date
                  from  table_2 t
               )  ...This adds a column to t2 called base_date, which is a real DATE. Anywhere in the main query, you can reference t2.base_date instead of SYSDATE.
    If you want to be prompted to enter the value at run-time, then you can use SQL*Plus substitution variables, like this
    ACCEPT  base_date_text  "Please enter the date to use (DD-Mon-YYYY HH24:MI:SS format): "
    with t2 as (
                select  t.*,
                        lead(step_date) over(partition by order_nr order by step_date) next_step_date
                        TO_DATE ('&base_date_text', 'DD-Mon-YYYY HH24:MI:SS')   AS base_date
                  from  table_2 t
               )  ...Again, t2.base_date (a DATE) is now available anywhere in the main query.

  • Query with variable

    hello world,
    i have a problem, i have implemented a query that is using in different schema. These schemas have same structure, therefore to extract information i must use the same query but I must specify the different schemas to select the table. The question is: " how can i use a variable in the query? "
    Example: "Select * from aa.zz ", "Select * from bb.zz"
    I want to use the same query but to replace the name schema with a variable
    Example: "Select * from aa.zz ", "Select * from bb.zz" =>>> "Select * from x.zz " where "x" is the variable name.
    I am using this query to build a report by oracle BI publisher.
    Thanks very much.
    Regards
    Vincenzo

    You should post your question on [Sql/PLSql |http://forums.oracle.com/forums/forum.jspa?forumID=75] topic
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com

  • Explain plan for query with variables

    Trying to Explain plan for some sql in sql*plus. The query has a variable in it. How do I do this ?
    I did look into explain plan and dbms_xplan but could not find anything with variables

    use sqlplus bind variables:
    SQL> --define variable
    SQL> var x varchar2
    SQL> -- notice the colon prefixing the variable
    SQL> explain plan for select * from customer where cid = :x;
    Explained.
    SQL> select * from table( dbms_xplan.display );
    PLAN_TABLE_OUTPUT
    Plan hash value: 1709312366
    | Id  | Operation                   | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |          |     1 |    67 |     2   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| CUSTOMER |     1 |    67 |     2   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | CID      |     1 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("CID"=:X)
    14 rows selected.the variable does not need to be set to explain the query, since explain does not actually execute.
    Edited by: shoblock on Nov 6, 2008 4:51 PM

  • BI query with variables

    Hey Experts
    I have a BI query that I want to use in a Visual Composer Application.
    I have three fields Calendar Year, Amount and calculated Amount.
    Calculated amount is based on the field amount and on a variable.
    In my query the calculated amount it's defined as a formula. In Bex Analyzer my query works.
    If I don't fill in the variable, the calculated amount is empty (can not be calculated).
    I add my query as a dataservice and connect a table as output with the three fields.
    First I just added a start component to the input of the dataservice.
    Result: Only the fields amount and year are filled.
    I think it's normal because without the variable the calculation is not possible.
    Second, I added an input form to the variable port of the dataservice. In the input form I have an input field for the variable and a submit button.
    Result: Again calculated amount is not filled in.
    After a closer look. I see that in the variable port of the dataservice, my variable is declared as text. Could that be the problem. In my BI query however the variable is declared as number.
    I even tried with a start proces connected to the variable port, and added a constant to the variable. Ofcourse between quotes because the dataservice thinks the variabel is text.
    Does someone know what the problem is?
    The ultimate goal is to use a slider for the variable.
    Thanks
    Steven

    Solved,
    I used a function to convert number to text.

  • Formatted search query with variable

    Hi
    I am trying to create a formatted search on a purchase order document.The scenario is as follows:
    The issue is that the client will on certain stock records incur a tooling cost when raising a PO. This is a once off cost when they order a particular item. For example the tooling cost on a stock item is u20AC5.50. The cost price on the item is u20AC100. If they order for example 5 of these the total cost is u20AC505.50 i.e. u20AC100*5+tooling cost of u20AC5.50.
    What we are attempting to do is pull through the tooling cost and add this on to the line total using a formatted search.
    -UDF created on item record table. This is set type 'Unit and totals' and structure is 'Price'. This is called ToolingCost
    -UDF created on marketing doc rows for ToolingCost. Again this is set to the same type and structure as the UDF on the item record.
    -We have created a UDF on marketing row for total cost and set a formatted search against this with query attached that is attempting to calculate the total cost. We cannot get this to work and the problem would appear to be that the price field is a variable and this is causing an issue on the query. Can we include a variable field in our query and if so what should the syntax be?
    Our query at the moment is 'SELECT 100*($[POR1.QTY.NUMBER])+($[POR1.U_TOOLINGCOSTS.NUMBER])
    Note 100 in query syntax above to be replaced by price on POR1 table.
    Can anyone provide assistence please.
    Derek Smith

    Hi Derek........
    Try this.....
    declare @var1_Qty as varchar(255)
    declare @var2_Pr as varchar(255)
    declare @var3 as float
    declare @var4 as float
    set @var1_Qty=$[$38.11.0]
    set @var2_Pr=$[$38.14.0]
    Set @var3=$[POR1.U_TOOLINGCOSTS.0]
    set @var4=cast(substring(replace(@var2_Pr,',',''),0,len(replace(@var2_Pr,',',''))-3) as float)
    select (@var1 * @var4)+@var3
    Hope this will help you.......
    Regards,
    Rahul

  • Re: Crystal Report and SAP BW Query with Variable

    Crystal Report 2008 V1 SP3 and SAP Integration Kits 3.1 SP3 installed on my client machine.
    I can open SAP BW Query in Crystal Report. However, in the Field Explorer >Database Fields, I dont see to be able to expan the Query and see it Key Figure/Characteristic.
    I noticed this happen only if we have Variable defined in the Charactics.
    If the characteristic has no variable, then I can expand the Query under Database Fields.
    Do you have this problem?

    Yes, once I have imported the new SAP Integration Kits XI 3.1 SP3 transports into BW system, I can now expand the it.
    I can now see the Variable in Crystal Report.
    Thanks!

  • Can we run a query with variable screen at start up in Bex Analyzer

    Hello all,
    I have a query which asks for fiscal year and posting period at the start of query run. But when I run the query in analyzer, it gives me this error all the time.
    "Program error in class SAPMSSY1 method : UNCAUGHT_EXCEPTION
    System error in Program CL_RSR_REQUEST and form TEXT_ELEMENTS_GET: VARIABLE"
    Can someone help,
    Thanks in advance.

    Hello,
    Please check if OSS note 858458 is applicable in your case.
    Regards,
    Praveen

  • Select query with variable no of conditions

    Hi,
    I want to write a select query such that the conditions mentioned under WHERE clause can be variable .like :
    Select * from TABLE where F1 = var1 and F2 = var2 and F3 = var3.
    Now on the basis of some conditons the equations in where clause should be used.Say condition is variable value >6.
    Now in this case ,if
    var1 =7 var2 =3 var3 = 8 then the query shud behave like
    select * from TABLE where F1 = var1 and F3 = var3
    if :
    var1 =3 var2 = 4 var3 =3 the :
    select * from TABLE
    But only one query is to be wrote that satisfies all of these
    thanx
    Edited by: aachal on Feb 4, 2011 11:36 AM

    Hi Aachal,
    Use Dynamic select statement.
    Ex:
    data : lv_wherecond type string.
    Select * from TABLE where ( lv_wherecond ).
    Before Select stmt, code as follows.
    if var1 > 6.
           if lv_wherecond is initial.
              F1 = var1.
           else.
              concatenate lv_wherecond ' and F1 = var1'  into lv_wherecond.
           endif.
    elseif var 2 > 6.
            if lv_wherecond is initial.
               F2 = var2
            else.
               concatenate lv_wherecond ' and F2 = var2'  into lv_wherecond.
           endif.
    elseif var3 > 6.
          same as above ..
    endif.
    Hope it helps..
    Regards,
    Sravan Guduru.

  • Error when executing query with variables in excel

    When I execute a query in excel, it gives some errors if it has some variables (From Date, To Date etc):
    Error Specify a value for variable From Date
    Error Specify a value for variable To Date
    I need to execute the query and then save a view. I want to do this in excel as I am not able to save a view if I execute in a web browser.

    Hi Sanjeev.
    Of course Excel supports input of variable values.
    What version of BW/BI both backend and frontend are you using?
    Please check if you can execute the query in TA RSRT. You could try to generate the query again here.
    Hope it helps.
    BR
    Stefan

  • Complex QUERY with Variables

    I created a complex query to extract data from Journal entry and from Journal voucher. I post here a simplified version where I have deleted UDO references.
    I buit it in the Query analizer and it runs ok.
    I copied in SAP and it runs ok too.
    Now, I need to ask for the start date and end date, as in the first lines of script. But SAP raise an error message I dont understand. I tried to use '[%0]' and '[%1]' insthead of '2008/01/01' and '2008/02/29' 
    DECLARE @D1 DATETIME
    DECLARE @D2 DATETIME
    SET @D1='2008/01/01'
    SET @D2='2008/02/29'
    SELECT * FROM
    SELECT  
         A.ACCOUNT AS 'CO.GE ITALIA',
         OACT.ACCTNAME AS 'NOME CO.GE ITALIA',
         SUM(CASE WHEN (A.ACCOUNT>='500000' AND A.ACCOUNT<'600000' AND DEBIT<>0) THEN -DEBIT WHEN (A.ACCOUNT>='600000' AND A.ACCOUNT<'700000')THEN 0 ELSE CREDIT END -
              CASE WHEN (A.ACCOUNT>='500000' AND A.ACCOUNT<'600000') THEN 0 WHEN (A.ACCOUNT>='600000' AND A.ACCOUNT<'700000' AND CREDIT<>0)THEN -CREDIT ELSE DEBIT END) AS 'TOTALE'
    FROM (
    SELECT BTF1.* FROM BTF1
    UNION ALL
    SELECT JDT1.* FROM JDT1
    ) AS A
    LEFT JOIN OACT ON (OACT.ACCTCODE=A.ACCOUNT)
    LEFT JOIN OBTF ON (OBTF.BATCHNUM=A.BATCHNUM AND OBTF.TRANSID=A.TRANSID)
    WHERE A.REFDATE>=@D1 AND A.REFDATE<=@D2 AND (OBTF.BTFSTATUS<>'C' OR OBTF.BTFSTATUS IS NULL) AND (OACT.U_CUENTA<>'' AND OACT.U_CUENTA IS NOT NULL) AND (OACT.U_CUENTA<>'432000000')
    GROUP BY A.ACCOUNT, OACT.ACCTNAME
    UNION ALL
    SELECT  
         A.SHORTNAME AS 'CO.GE ITALIA',
         OCRD.CARDNAME AS 'NOME CO.GE ITALIA',
         SUM(CASE WHEN (A.ACCOUNT>='500000' AND A.ACCOUNT<'600000' AND DEBIT<>0) THEN -DEBIT WHEN (A.ACCOUNT>='600000' AND A.ACCOUNT<'700000')THEN 0 ELSE CREDIT END -
              CASE WHEN (A.ACCOUNT>='500000' AND A.ACCOUNT<'600000') THEN 0 WHEN (A.ACCOUNT>='600000' AND A.ACCOUNT<'700000' AND CREDIT<>0)THEN -CREDIT ELSE DEBIT END) AS 'TOTALE'
    FROM (
    SELECT BTF1.* FROM BTF1
    UNION ALL
    SELECT JDT1.* FROM JDT1
    ) AS A
    LEFT JOIN OACT ON (OACT.ACCTCODE=A.ACCOUNT)
    LEFT JOIN OBTF ON (OBTF.BATCHNUM=A.BATCHNUM AND OBTF.TRANSID=A.TRANSID)
    LEFT JOIN OCRD ON (OCRD.CARDCODE=A.SHORTNAME)
    WHERE A.REFDATE>=@D1 AND A.REFDATE<=@D2 AND (OBTF.BTFSTATUS<>'C' OR OBTF.BTFSTATUS IS NULL) AND (OACT.U_CUENTA<>'' AND OACT.U_CUENTA IS NOT NULL) AND (OACT.U_CUENTA='432000000')
    GROUP BY A.SHORTNAME, OCRD.CARDNAME
    ) AS B

    Thank you to everybody for your answers.
    I need to know more about this way to declare a variable in SAP.
    This is my question:
    If I need to filter by date a result from a Union All select, is sufficent to declare the Date Variable for one of the two tables in the Union All?
    Following a simple code to explain my dubt:
    DECLARE @D1 DATETIME
    DECLARE @D2 DATETIME
    SET @D1='2008/01/01'
    SET @D2='2008/02/29'
    SELECT A.ACCOUNT, A.DEBIT, A.CREDIT FROM
    SELECT * FROM JDT1
    UNION ALL
    SELECT * FROM BTF1
    ) AS A
    WHERE A.REFDATE>=@D1 AND A.REFDATE<=@D2
    Do you think the WHERE statment will continue to run as well for the Union All in the script main too?
    This is the modified initial code:
    /*SELECT * FROM JDT1 T0*/
    DECLARE @D1 DATETIME
    DECLARE @D2 DATETIME
    /* WHERE */
    SET @D1=/* T0.REFDATE */ '[%0]'
    SET @D2=/* T0.REFDATE */ '[%1]'
    Thanks in advance,
    Jonny Cortonicchi

Maybe you are looking for

  • Unable to View Data in the table of a  CDC enabled Data Store.

    hi all, I am trying to import some tables from the external metadata from my CDC enabled datastore, but after importing the tables i m unable to view the data in the table, where as the same table in a normal datastore (Without CDC) is showing data i

  • Is it possible to add a "suffix" to many song titles at once?

    When I add a live album to my iTunes collection, the song often show up as duplicates. The studio version and the live version are by the same band, so iTunes shows them as duplicate files when using Display Duplicates. To get around this I add the w

  • Compilation/loading/execution  of  XSLT mapping in XI at runtime

    Hi all, once a xslt is added to the interface mapping as XSL how its getting compiled/loaded/executed at runtime, since we adding the xslt code as such to the imported archives?did all these steps will take place for each message processing? or is th

  • PO in excel sheet

    Dear Experts, How to export PO to excel format. Rgds

  • How can i get this summation right?

    Hi experts, who can help me out with this task... I have a sub report that has a group by week. Each week contains totals from deliveries, production, demand and at the end of each week is a calculated stock level (running total). Deliveries and prod