Prompt for Date Values in Query

I have the following query but instead of setting the variables I would like to be prompted upon running. 
I tried using the [%0] but couldn't get it to work.  Any suggestions would be appreciated.
declare  @StartDate DateTime
declare @EndDate DateTime
set @StartDate = '20091101'
set @EndDate = '20091130'
select substring(rdr1.ITEMCODE,1,3) as BRAND, ROUND(sum(rdr1.linetotal),2) AS ORDERTOTAL, isnull(ROUND(sum(dln1.linetotal),2),0) AS SHIPTOTAL, isnull(ROUND(sum(rdr1.linetotal),2)  - ROUND(sum(dln1.linetotal),2),0) AS TOTALDIF, ROUND(sum(rdr1.grssprofit),2) AS ORDERGP, isnull(ROUND(sum(dln1.grssprofit),2),0) AS SHIPGP, isnull(ROUND(sum(rdr1.grssprofit),2) - ROUND(sum(dln1.grssprofit),2),0) AS GPDIF, isnull(ROUND((sum(dln1.linetotal) / sum(rdr1.linetotal)*100),2),0) AS FILLRATE
from rdr1
LEFT OUTER join dln1
on (rdr1.docentry = dln1.baseentry and rdr1.itemcode = dln1.itemcode) join ordr on ordr.docentry = rdr1.docentry join oitm on oitm.itemcode = rdr1.itemcode
where rdr1.linestatus = 'C' And ordr.canceled = 'N' And ordr.docstatus = 'C' And oitm.u_status = '01' And
rdr1.docdate >= @StartDate And rdr1.docdate <= @EndDate
GROUP BY substring(RDR1.ITEMCODE,1,3) ORDER BY substring(RDR1.ITEMCODE,1,3)

Try this one:
declare @StartDate DateTime
declare @EndDate DateTime
/* select * from rdr1 t where t.docdate between [%0] and  [%1]*/
set  @StartDate =  [%0]
set @EndDate = [%1]
select substring(rdr1.ITEMCODE,1,3) as BRAND, ROUND(sum(rdr1.linetotal),2) AS ORDERTOTAL, isnull(ROUND(sum(dln1.linetotal),2),0) AS SHIPTOTAL, isnull(ROUND(sum(rdr1.linetotal),2) - ROUND(sum(dln1.linetotal),2),0) AS TOTALDIF, ROUND(sum(rdr1.grssprofit),2) AS ORDERGP, isnull(ROUND(sum(dln1.grssprofit),2),0) AS SHIPGP, isnull(ROUND(sum(rdr1.grssprofit),2) - ROUND(sum(dln1.grssprofit),2),0) AS GPDIF, isnull(ROUND((sum(dln1.linetotal) / sum(rdr1.linetotal)*100),2),0) AS FILLRATE
from rdr1
LEFT OUTER join dln1
on (rdr1.docentry = dln1.baseentry and rdr1.itemcode = dln1.itemcode) join ordr on ordr.docentry = rdr1.docentry join oitm on oitm.itemcode = rdr1.itemcode
where rdr1.linestatus = 'C' And ordr.canceled = 'N' And ordr.docstatus = 'C' And  oitm.u_status = '01' And
rdr1.docdate >= @StartDate And rdr1.docdate <= @EndDate
GROUP BY substring(RDR1.ITEMCODE,1,3) ORDER BY substring(RDR1.ITEMCODE,1,3)

Similar Messages

  • Calendar prompt for Date variable from bex

    Hi All,
    I have a Bex query where I have a variable on 0CALDAY
    - Customer exit (i_step = 1 to populate with current date)
    - Single value
    - Mandatory
    I created universe on this query and in webI selection screen i do see the variable prompt.
    I am not able to see the current date populated automatically since exit values are not populated to WebI at runtime.
    My problem is that in WebI selection screen we get list of date values from the info provider instead of Calendar prompt
    where user can enter the values directly.
    I am currently on BO XI 3.1 SP3.
    Is there any specific setting in Universe or bex query which is required to get this Calendar prompt instead of list of values for dates?
    Note: When we were on SP1 the universe created then had same variable from bex and it still shows us Calendar prompt but ever since we upgraded to SP3 for the query splitter functionality we not able to get the calendar prompt for date variable in new universe we create
    Thanks
    Ritesh

    Yep.
    Now tell me how you want to show that Prompt @ WebI report level.
    My problem is that in WebI selection screen we get list of date values from the info provider instead of Calendar prompt
    where user can enter the values directly. Exactly, i didn't get this??
    @Prompt:
    You have flexibility to show options like:
    Mono/Multi: User can select Single value or Multiple.
    BW Variable: Same we have (Single/Multiple)
    Free/Constrained: User can Enter his/her value directly or No change option.
    BW Variable: By defalut you will get this, once you made it to Optional input.
    Persistent/Not_Persistent: Refreshed report has to show last selected value means use Persistent otherwise Not_P.
    By seeing the Prompt syntax , I can say your Variable is after Customer Exit, Correct??
    Workaround for your Problem is:
    <FILTER KEY="ZV_DATE"><CONDITION OPERATORCONDITION="Equal"><CONSTANT TECH_NAME="@Prompt('Date (Previous Day)','A','Date\LovDate (Previous Day)Base',mono,primary_key)"/></CONDITION></FILTER>
    You have to remove that Date class and objects from prompt syntax. Because of that it showing up LOV's not calendar.
    Like:
    <FILTER KEY="ZV_DATE"><CONDITION OPERATORCONDITION="Equal"><CONSTANT TECH_NAME="@Prompt('Date (Previous Day)','A',',mono,primary_key)"/></CONDITION></FILTER>
    Why, It should be blank??
    Because Date needs no class\object to show up, by default you will get Calendar on the fly.
    Hope you got my point.
    Thank You!!

  • CreateWithParams operation for Date value

    Hi,
    i want to use createwithparams for date value. I have drag and dropped the createwithparams operation and in the page def file and i have inserted NamedDate and in that i have entered NDName, NDType as "oracle.jbo.domain.Date" and NDValue. But its not working... Please help

    Which Jdev version. What error ? What value do you exactly pass ?

  • Master data values in Query

    Hello,
    i want to restrict division by certain value in a query. i cannot see one of such values in the restriction window in the available list of values.
    i checked master records for division and it has this value. the infoprovider may not have this value.
    in the 0division infoobject the settings in the business explorer tab are:
    Query Def. Filter Value Selection: M Values in master data table.
    Query Execution Filter Val. Selectn:M Values in master data table.
    Why can't i see the value in the query for restriction?
    thanks

    Hi Aby,
    <i>Have you tried clicking on the "display other values" button right before the find text box in the restriction window (the one with the small yellow arrow)? If not, then click on tht button and put in some restriction rule to cut down on the number of entries displayed. This should display the value you desire.</i>
    In addtion to that uncheck 'only values from InfoProvider'
    regards

  • Month-to-Date and Year-to-Date values in Query

    Hello experts,
    One of our BI reports has the following requirement: the user should be asked for the report date. After the user inputs the date, the report shows the key figures in three different "flavors": one is the values for that date, the second one is the cumulate values from the first day of the month of the report date to the report date itself, and the third is the cumulate values from the first day of the year of the report date to the report date itself.
      I created my report date variable based on 0CALDAY. Then I searched for SAP-exit variables that would help me achieve this, but could not really find any, except for 0P_ABO10, 0P_ABO11, 0P_ABO12 variables, all of them have as description "Start of Key Date Year". I tried creating a few selections in which the dates taken were defined as a range from each of these variables to the report date variable (for the year-to-date values), but I got the error "Variable 0P_ABO10 could not be substituted". I also got this error for the other two variables. And I could not find any SAP-exit variables like "Start of Key Date Month", in order to do the Month-to-Date part. My next try was to use the field "Key Date" with a variable in it, instead my own report date variable based on 0CALDAY, but it gave me the same errors.
    I searched the forums and found a few threads that looked useful, like
    First and Last day of month and
    1st day of month / 1st day of week variables
    However, they require some ABAP coding, and I do not know where to place the code (actually, I do not know where to work with ABAP code), and I also believe that I would have to do some changes to it.
    Any suggestions?

    Hi Pedro,
    You have to create customer exit in T_Code: CMOD
    1. Create a Z project
    2. Select RSR00001 as enhancement type.
    3. Go into include ZXRSRU01
    4. create a code like
    Here A is your variable based on 0calmonth with type customer exit and B is variable for 0calday.
    Try to write logic for your case taking this as example.
    WHEN 'A'.
        IF I_Step = 2.
          Loop at I_T_VAR_RANGE into L_T_VAR_RANGE where VNAM = 'B'.
            Concatenate L_T_VAR_RANGE-LOW(4) '001' into D1.
            Concatenate L_T_VAR_RANGE-LOW(4) '012' into D2.
            Clear L_S_Range.
            L_S_Range-low = D1.
            L_S_RANGE-high = D2.
            L_S_RANGE-sign = 'I'.
            L_S_RANGE-opt = 'BT'.
            Append L_S_Range to E_T_Range.
          ENDLOOP.
        ENDIF.
    If you want exact code I can help you in that.
    Thanks,
    Kams

  • Project Online - offline project plan prompts for date range to be entered when accessing Resource Usage view

    When I save a project plan to my local computer from Project Online and open it up in an offline mode and access Resource Usage view I get prompted with Date Range dialog boxes with the first one saying "Show resources/assignments that start or finish
    after:" and the second one with "And before:".
    I don't have any filters that are setup in Project Online that are not available in offline mode to trigger these prompts.
    Please let me know what could be causing the date range prompts. Thanks.

    Hi,
    You probably retrieve an enterprise filter into your local file. Just open the organizer from MS Project, go to the filter tab (be sure to have your project selected in the drop down menu at the top left of right of the organizer) and delete the date range
    filter.
    Hope this helps,
    Guillaume Rouyre, MBA, MCP, MCTS |

  • All Dates displayed for "Characteristic Values" in Query Designer

    Hello Experts,
    We are on BI 7.0, level 13.  I am having an issue within the Query Designer with regards to dates.  I have a write-optimized DSO that contains 3 date fields (for example, ZDATE1, ZDATE2, and ZDATE3).  Each date InfoObject is of type DATS so the system automatically creates it with reference to 0DATE. 
    When I create a query in the Query Designer, on the left hand side, I expand the "Characteristic Values" node under each date field.  The Query Designer shows the same list of values for each of the 3 dates even though they are not valid values posted in the DSO for those fields.
    For example, ZDATE1 only has 1 value posted in the DSO (01/01/2005).
    ZDATE2 only has 1 value posted in the DSO (01/01/2006).
    ZDATE3 only has 1 value posted in the DSO (01/01/2007).
    Bute when I expand the "Characteristic Values" node in the Query Designer, I see ALL THREE values under each date field.  I would expect to only see the 1 value posted for the InfoObject in the DSO.  Also note that each InfoObject is defined to show "Only posted values in InfoProvider".
    It appears that Query Designer will show all values for the reference InfoObject 0DATE instead of the ones posted to the actual InfoObject in the DSO.  If I delete the data in the DSO, the Characteristic Values list still remains because they exist in 0DATE.  Anyone encounter this before?  How can I get the Characteristic Values list to only show posted values for that InfObject?
    Thanks for your help!
    J

    Thanks for the response.  I went into the DSO and right clicked on each of the Date fields.  I looked at the Provider-specific properties and there is the option for "Query Exec.FilterVal" which only restricts what values appear when restricting during execution, not during query creation.
    Is there someplace else I should look or someplace else I can make change to only display posted dates when creating a query?  Thanks!

  • User Prompt for Date Range in Bex Query Analyzer

    I have a workbook that has two queries. The queries both require the user to enter a date range upon refresh. I want the user to be able to hit refresh, enter the date input into the dialog box and then both queries to use this date range for their input. I have seen this in other book, but when I click refresh on my book it only runs the first query. How do I get the second query to use the first queries input?

    use the same variable in both the queries. this will let the user enter the date in a single variable and this will refresh both the queries.
    rgds, Ghuru

  • Hide a row or column for characteristic value # in Query Designer

    Hi gurus,
    I would if we could hide a result row / column if one of the characteristic value is #. The requirement is actually to remove the meaningless row / column from the whole result set. For example, I have a char Material Group in the column. Since not every Material is assigned to a Material Group, I will get the following layout:
    Material_Group A
    Material_Group B
    Material_Group C
    Is it possible to define in query designer so that the column with # will automatically not be displayed?
    Thanks,
    Meng

    Hi Meng,
    I guess we have the same users..
    But there is one thing that is going to make a non sense on the report: if you do not display the "#" for material group, then the total of your query by material group will not be the summation of what is displayed on the screen...and if the user explort the information in Excel (pretty sure they will do so), you will have some calls that your query does not balance....
    Based on that assumption, tell the users to assign a material group to the materials, so that this unassigned column disappears. You could even give them a control report listing all the parts that do not have a material group
    If this is a standard business rule not to have a material group for all parts, then, what you could do is to change the text for empty rows for Material group, then the "#" will disappear and wil be under the text description you defined.
    But keep in mind that your data is made of materials which do not have a material group in their definition, noraml or not ?
    PY

  • Optional Prompt for Date type parameter in Crystal Report.

    Hi Every One,
    I have a date type parameter in crystal report.When I am convert it to optional prompt it is showing following message.
    But the Type field is gray out when I was selecting list of values Dynamic.
    Please suggest.
    Thanks and Regards
    DEV

    Hi,
    Please check SAP note:
    1710595 - CR_Defining "Optional Prompt" as True for SAP Crystal
    Reports Does Not Work
    Thanks & Regards,
    Nagarajan

  • How to setup a default value when defining (prompting) for a value?

    When I prompt the user in a SQL statement then I can declare a default value like in:
    SELECT *
    FROM all_users
    WHERE username = nvl('&myvariable','SYSTEM');
    But when I define a variable this does not work:
    define tablename=nvl('&tablename','test123')
    How can I setup a default value here?
    Peter

    Is there a way to define a default value DIRECTLY in SQLplus DEFINE command (and not later when the value is used in SQL statement)?no, there is not for DEFINE but you can use ACCEPT:
    SQL> accept tablename prompt 'Enter value for table Name:' default EMP
    Enter value for table Name:
    SQL> select column_name
      2  from cols
      3  where table_name='&tablename';
    OrderNumber=1234
    COLUMN_NAME
    EMPNO
    ENAME
    JOB
    MGR
    HIREDATE
    SAL
    COMM
    DEPTNO
    8 rows selected.Max
    [My Italian Oracle blog| http://oracleitalia.wordpress.com/2010/02/07/aggiornare-una-tabella-con-listruzione-merge/]

  • Adaptive tag for date value - output in milliseconds?

    I'm trying to add code to my presentation template, so when a page has multiple content items, I grab the most recent value of all 'last modified dates' for the content items on the page, so this would essentially display the page's last modified date. The approach I'm trying involves outputting the modified date for each content item into a format I can sort in a javascript function, then retrieve the most recent value to display at the bottom of the page's content. In this case, I figured the best manner to sort the items easily would be to display the date in milliseconds, then sort, and finally convert the most recent modified date into mmmm dd, yyyy hh:mm AM/PM format.
    I see there is a method to obtain this date in millseconds (since January 1, 1970) format in javascript, however, is there a way to do this using the adaptive tag <pcs:value expr="modified" format="____________">?
    If not, is there a better way to obtain dates for sorting in a javascript function, so can obtain the entire date, hours, and minutes? I did find one method that grabs the month, day, and year, but not the hours and minutes.
    Thanks!

    Hi Suman/Jeedesh,
    As per Pco notification, it will trigger whenever any of the tag value changes in Agent instance subscription items.
    For above issue, My suggestion
    1. Create DB table name TAGLIST with 200 tags as rows in columns (Tagname, TagValue)
    2. Based on notification trigger, create a transaction and update values w.r.t TagNames in above table
    3. Next time, when notification trigger with fresh value for any of the tag, cross check with existing TagName with Value and update in DB table.
    4. And in the mean time, send those Tag details vie mail trigger or as per requirement
    Instead of creating 200 notification, above is a just alternate way suggestion to achieve dynamic tag value change notification.
    Hope it might solve your problem
    Regards,
    Praveen Reddy

  • Prompt for date between..... and ........

    Hi Guys,
    How could I translate something like this in BI
    undefine day
    select sum(total_revenue) from resv_history
    where day between '&DAY' and '&DAY'
    and day between '&DAY' and '&DAY';
    So, I would need two prompts where in each I could select a period between two dates. Is it possible at all?
    The results should show as below
    TOTAL REVENUE
    20-APR-07-25-APR-07 20-MAY-08-28-MAY-08
    300000 Euro 550000 Euro
    Does it make sense?
    Thanks and Regards
    Giuliano

    Hi.
    You need four date prompts.
    See similar blog entries, everything is there:
    OBIEE same dimension different value measures (example with two date prompts - is equal)
    http://108obiee.blogspot.com/2009/07/obiee-same-dimension-different-value.html
    or
    Comparing Arbitrary Time Periods (example with four date prompts - is between)
    http://kpipartners.blogspot.com/2009/07/comparing-arbitrary-time-periods.html
    Regards
    Goran
    http://108obiee.blogspot.com
    Edited by: Goran O on 2009.08.07 01:06

  • Prompting for cusor values

    I want to be able to change the cursor values by prompting the user
    to enter values for the cd_id column
    WHERE cd_id IN(182026,178918) ;
    DECLARE
    stmnt varchar2(1000);
    CURSOR c1 IS
    SELECT CD_ID, CD_DISAB,CL_ID
    FROM cl_disabs
    WHERE cd_id IN(182026,178918) ;
    BEGIN
    FOR t_rec IN c1 LOOP
    DBMS_OUTPUT.PUT_LINE(t_rec.cd_disab ||' , '||t_rec.cd_id||' ,'||t_rec.cl_id );
    stmnt := 'INSERT INTO cl_d VALUES(t_rec.cd_disab,t_rec.cd_id ,t_rec.cl_id )';
    END LOOP;
    END;
    /

    Have you played much with ( &P )? I know it will allow a user to input a variable. Might work for you.
    Jim P.

  • To create a Crystal Report which will prompt for a value and if nothing is entered select the alternative value from the database record.

    Hi Experts,
    I am working on a report in Crystal (2008) which will prompt user to input a value, but if nothing is entered then it will select relevant database value.
    I created a string parameter prompt called "{?Pack_Qty_Overide}" and used the following formula.
    IF {?Pack_Qty_Overide} = ""
    THEN {OITM.SalPackUn}
    ELSE {?Pack_Qty_Overide}
    However, when I check the formula in editor, it says that there should be a number at the end of "Else" clause.
    What am I doing wrong?

    Hi Janos,
    OITM.SalPackUn is Numeric(19.6). When I used parameter input type as number, my formula returned error that "A number is required here" at the "if .... " statement.
    So I used the formula you provided and it worked, such that when I input a quantity in parameter prompt it would display that, but if no override value given, the field remains blank - i.e. it does not display the value stored in OITM.SalPackUn.
    What am I doing wrong?
    Thanks,
    YP

Maybe you are looking for

  • Very dim screen on MacBook Pro - how to prove it?

    I bought an MBP about 4 weeks ago (just before the new rev came out, so this one does not have LED backlight) and have mostly been using it connected to a 23" cinema display. When I was using the built-in screen the other day I realised it was very d

  • Error while starting Topology manager

    Hi, I have Oracle XE & ODI installed in Enterprise Linux. Both are on the same machine. I have created the new schema (Fusion) and also ran the repcreate.sh to create the master repository for the same. Now to log into topology manager, I created a n

  • Batch Determination with SLED Selection Using LOBM_RLZ

    Hi All, I am trying to determine Batches at the time of Goods Issue against Production Order (i.e. Movement Type 261). These are the steps I have used. 1. Created a Batch Class with Standard Characteristics LOBM_RLZ, LOBM_VFDAT, LOBM_LFDAT. 2. Assign

  • Interactive pdf form with text fields. Chinese fonts

    Hi All We have designed an interactive pdf with text fields. We need the text fields to be in a Chinese font. I understand that this cant be done in Indesign (change the inputting font to Chinese) I have moved the file over to Acrobat Pro and used th

  • Trouble with icloud restoring

    Hello, I have restored my iphone setup via iCloud here with iphone 6th But now 4 hours after standing still when the screen is locked to restore from iCloud and it does not do anything or downloaded anything. I have updated to 8.0.2 via computer, bec