How to suppress a row based on current date -  at query level?

In an Bex query report i have suppress rows based on current date.
There is no current date available in query.
there is a date field in the query.
If by chance the date in that field is lesser than current date, I have to suppress that row.
How can this be achieved?

What is the code ofr creating a variable to get values >= to current date?
I have implemented the following code which is not working.
data L_S_range like line of E_T_range[].
CLEAR L_S_RANGE.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'GE'.
L_S_RANGE-LOW = SY-DATUM.
APPEND L_S_RANGE TO E_T_RANGE[].
Actually i have written in class, which will be inherited in superclass.
Edited by: akshara20 on Feb 2, 2011 1:21 PM

Similar Messages

  • How to suppress Result rows in a Query in Web Application Designer

    Hi
                 I am trying to post a query in Web Application Designer. I am able to run the query in WAD but the Results rows appear. I choose Suppress Result Rows always in All Characteristics option in the query in BEx Explorer but still i see result rows in the WAD. Can anyone please let me know how to suppress Result rows so that they dont appear in Web Application Designer.
    Thanks,
    Padma

    To get the enhanced menu-
    1. Open the template in WAD.
    2. Go to Web Item properties.
    3. Go to Entries in Context Menu.
    4. Find the "Enhanced Menu" property. Set it to "display" if you want it to be visible in template result.
    5. Next time when you execute your template you will be able to access it by right clicking.
    or
    If you just want to supress results without adding enhanced menu in the context menu, simply set "Calculate result as" to "No Display".

  • How to Increase the Rows and Columns Size of Bex Query in Enterprise Portal  of SAP  7.3

    Dear All,
    Please let me know the process how to Increase the Rows and Columns  Size of Bex Query in Enterprise Portal  of SAP  7.3 .
    Currently I am getting Only  4 columns and 10 rows in One Page .And I am getting 1,2 etc tabs for both row and column. So i want to increase the column length more than 100  and row length more than 10000.
    Please suggest me a suitable solution to over come this issue.
    Please find the Below screen shot.
    Thanks
    Regards,
    Sai

    Dear All,
    Please find the attached screen shot.
    The report be open with 4 or 5 columns and 5 or 6 rows.
    So, please  let me know how to increase the length of the table.
    Do the needful for me to over come this issue.
    Thanks
    Regards,
    Sai.

  • How to Add 15 Days to the current Date in eCATT

    Hello eCATT Guru's,
    How to add 15 days to the current date in eCATT.
    I have changed the Date format to mm/dd/yyyy.
    now i want to add 15 days to the sy-datum.
    How to do that.do any one know?
    Thanks in Advance,
    Raj

    Check out this link -
    http://help.sap.com/saphelp_46c/helpdata/en/d7/e21a50408e11d1896b0000e8322d00/frameset.htm
    It gives details about DATE variables in CATT. Hope this will help you out.
    ashish
    Reward points if you find this helpful.
    Message was edited by: Ashish Gundawar

  • How to display current date in query header?

    Hi,
    How to display current date in query header?
    I use Query Designer for development.
    Thanks,
    Arun KK

    Hi Arun,
    You can define fixed header lines and footer lines so that when you generate the query list, they can receive current values of certain fields. When you define a header line or a footer line, you must specify a character string of the type &field, where field is the short name of a field.
    This function allows you (for example) to place a sort criterion in the header line.
    You can include the following fields as variables in the headers directly:
    %NAME
    Name of the user processing the query
    %DATE
    Current date
    %TIME
    Current time
    %PAGE
    Current page number (6 characters)
    %P
    Current page number (3 characters)
    These fields can be used in the short forms N,D,T and P. If you want to use these letters as short names for query fields, the field values from the query are used.
    You can also see the link
    [http://help.sap.com/saphelp_nw70/helpdata/EN/6e/dd68721faf11d6b1d500508b6b8b11/frameset.htm]
    Regards,
    NR

  • FM to get previous sunday date based on current date(SY-DATUM)

    hi all,
    Is there any function module to get the previous sunday date based on current date(sy-datum)?
    Regards,
    Kapil Sharma

    Hi Kapil,
    You can follow the logic below:
    data:
    l_date like sy-datum, **TODAY
    l_date2 like sy-datum, **Previous Sunday
    data:
    l_daynr like HRVSCHED-DAYNR.
    *Get today's date
    l_date = sy-datum.
    *Gey today's day (Monday, Tuesday, etc.)
    CALL FUNCTION 'HRIQ_GET_DATE_DAYNAME'
    EXPORTING
    langu = 'EN'
    date = l_date
    IMPORTING
    daynr = l_daynr.
    CASE l_daynr.
    *If it is Monday
    WHEN 1.
    -Subtract 2 days for the previous Sunday
    CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
    EXPORTING
    id_date = l_date
    id-operator = '-'
    is_duration = 2
    IMPORTING
    ed_date = l_date2.
    *If it is Tuesday
    WHEN 2.
    CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
    EXPORTING
    id_date = l_date
    id-operator = '-'
    is_duration = 3
    IMPORTING
    ed_date = l_date2.
    *If it is Wednesday
    WHEN 3.
    CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
    EXPORTING
    id_date = l_date
    id-operator = '-'
    is_duration = 4
    IMPORTING
    ed_date = l_date2.
    *If it is Thursday
    WHEN 4.
    CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
    EXPORTING
    id_date = l_date
    id-operator = '-'
    is_duration = 5
    IMPORTING
    ed_date = l_date2.
    *If it is Friday
    WHEN 5.
    CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
    EXPORTING
    id_date = l_date
    id-operator = '-'
    is_duration = 6
    IMPORTING
    ed_date = l_date2.
    *If it is Saturday
    WHEN 6.
    CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
    EXPORTING
    id_date = l_date
    id-operator = '-'
    is_duration = 7
    IMPORTING
    ed_date = l_date2.
    *If it is Sunday
    WHEN 7.
    CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
    EXPORTING
    id_date = l_date
    id-operator = '-'
    is_duration = 8
    IMPORTING
    ed_date = l_date2.
    ENDCASE.
    Regards,
    Dilek

  • FM to get the previous sunday date based on current date(sy-datum)

    hi all,
    Is there any function module to get the previous sunday date based on current date(sy-datum)?
    Regards,
    Kapil Sharma
    Moderator Message: Basic date related questions are not allowed
    Edited by: Suhas Saha on Sep 19, 2011 11:39 AM

    Hi,
    There are function modules to find out the current day of the week depending on sy-datum. These are as below:
    1. DATE_COMPUTE_DAY - Returns a number indicating what day of the week the date falls on. e.g. Monday is returned as a 1, Tuesday as 2,...., Sunday as 7.
    2. RH_GET_DATE_DAYNAME  - Returns the day based on the date provided, e.g. Monday, Tuesday,..., Sunday.
    Using any of the above, if you can find out the current day, then you can calculate and compute the date of the previous Sunday.
    My observation is that using the first FM might make the calculation simpler.
    Hope this is of help to you.
    Regards,
    Shayeree

  • How to suppress the report based on outer dimension in nested report

    Hi Experts,
    We have a report with nesting of two dimensions in rows. They are Program dimension and Account Dimension.
    We need to supress the report based on the program dimension members. i.e whenever there are no values against all the accounts for a particular program that particular program should get supressed.
    In the screenshot attached I am looking to supress the rows 37,38 and 39 as the data against this program is empty.
    However I dont want to supress the rows 31 and 33 as there is a capital data against this program in row number 32. So we have to supress the rows based on absence of data at program level.
    We are using SP14 on BPC 10.
    I remember that such functionality could be acheived in BPC 7.5 by flagging the required dimension to have suppress in Expansion Range. So I guess, similar functionality would be there in BPC 10 as well.
    I have evaluated the option of VBA macro to hide the required rows, but was wondering if we can achieve the same using EPM functionality as we used to do in BPC7.5.
    Thanks in advance for your suggestions!!
    Regards,
    Shiva

    Hi Shiva,
    First you have to check the option Keep Blocks:
    This option will show the whole block even if only one line contain some not zero/empty cells in the row.
    Second, when you select option Filter on All Columns/Rows you have to select OR as operator between columns:
    In this case the test for >0 (or for <0) will be applied to each column and the result will be OR'ed with other columns. True will be even if one column contains not zero and not empty cell.
    You logic to check individual column require to hardcode the members - not good!
    Vadim
    P.S. If you select AND for Filter on All Columns/Rows - then only lines with all cells with non zero / non empty will be shown as in your example!

  • Adding rows based on current and next row

    I got some excellent help on multiplying rows based on start and end date in this
    thread, resulting in the query below. It helps me follow Vehicle activity and Vehicle allocation of our vehicles day by day. Now I would like to add another feature to the query, if it is possible.
    The problem is that in our database, only actual tasks are registered, which means that the time when the vehicle is between tasks is not showing. I could of course calculate total available time per vehicle and month, but that would not tell me where the
    vehicles are waiting, when during the day, etc.
    So I would like to insert rows for when the vehicles are standing still, and the logic would be something like this:
    If vehicle number on current row equals vehicle number on the next row and End (date/time) of current row < Start (date/time) of next row, insert row after current row. Set Start=End of current row and End=Start of next row. Set From=To
    of current row and To=To of current row. Set Vehicle activity to "Not active". Finaly copy all other fields from current row.
    Is this possible to achieve in Power Query?
    Brgds,
    Caj
    let
        Source = Sql.Databases("sql10"),
        SLM = Source{[Name="SLM"]}[Data],
        dbo_V_LKPI = SLM{[Schema="dbo",Item="V_LKPI"]}[Data],
        RenamedColumns = Table.RenameColumns(dbo_V_LKPI,{{"ActualDeparture", "Start"}, {"ActualArrival", "End"}}),
         Records = Table.ToRecords(V_LocoKPI),
          DateTime.IsSameDay = (x, y) => Date.Year(x) = Date.Year(y) and Date.Month(x) = Date.Month(y) and Date.Day(x) = Date.Day(y),
          Expand = (x) => List.Generate(
              () => Record.Combine({x, [End=Date.EndOfDay(x[Start])]}),
              (record) => record[Start] <= x[End],
              (record) => let
                  NextStart = Date.StartOfDay(Date.AddDays(record[Start], 1)),
                  NextEnd = Date.EndOfDay(NextStart),
                  ThisEnd = List.Min({NextEnd, x[End]})
              in
                  Record.Combine({record, [Start=NextStart, End=ThisEnd]})),
          Transformed = List.Transform(Records, each if DateTime.IsSameDay([Start], [End]) then {_} else Expand(_)),
          Combined = List.Combine(Transformed),
          Result = Table.FromRecords(Combined)
      in
          Result
    Csten

    Here's some sample code. Again, we use List.Generate to build either a record or a list of records and then use List.Combine to bring the results back together before converting them to a table.
    let
        CombineTwoRows = (x, y) =>
            let
                combine = x[Vehicle] = y[Vehicle] and x[End] < y[Start],
                added = Record.Combine({x, [Start=x[End], End=y[Start], Active=false]}),
                result = if combine then {added, y} else {y}
            in result,
        GenerateStandingRows = (table, combine) =>
            let
                Handle = (x, y) => {x, y},
                buffered = Table.Buffer(table),
                n = Table.RowCount(buffered),
                windows = List.Generate(
                    () => {1, {buffered{0}}},
                    (x) => x{0} <= n,
                    (x) => {x{0} + 1, if x{0} < n then combine(buffered{x{0}-1}, buffered{x{0}}) else {buffered{x{0}}}},
                    (x) => x{1})
            in
                windows,
        InsertInactivity = (table) => Table.FromRecords(List.Combine(GenerateStandingRows(table, CombineTwoRows))),
        TestData = Table.FromRows({
            {1, #datetime(2014, 2, 23, 13, 0, 0), #datetime(2014, 2, 23, 13, 10, 0), true},
            {1, #datetime(2014, 2, 23, 13, 20, 0), #datetime(2014, 2, 23, 13, 30, 0), true},
            {2, #datetime(2014, 2, 23, 13, 20, 0), #datetime(2014, 2, 23, 14, 0, 0), true},
            {2, #datetime(2014, 2, 23, 14, 20, 0), #datetime(2014, 2, 23, 14, 40, 0), true},
            {2, #datetime(2014, 2, 23, 16, 0, 0), #datetime(2014, 2, 23, 17, 0, 0), true},
            {2, #datetime(2014, 2, 24, 2, 0, 0), #datetime(2014, 2, 24, 3, 0, 0), true},
            {3, #datetime(2014, 2, 24, 1, 0, 0), #datetime(2014, 2, 24, 8, 0, 0), true},
            {3, #datetime(2014, 2, 24, 9, 0, 0), #datetime(2014, 2, 24, 10, 0, 0), true}
            }, {"Vehicle", "Start", "End", "Active"})
    in
        InsertInactivity(TestData)

  • QUERY FOR HOW TO ACCESS NEXT ROW WHILE IN CURRENT ROW

    Hi, can you please make a oracle sql query for the following.
    My Data in table dt0attlog:
    ID  staffid  logdt          login                        logout       
    01  aw101    01.12.11   01.12.11 08.30   
    01  aw101    01.12.11                             01.12.11 10.30   
    01  aw101    01.12.11   01.12.11 11.40   
    01  aw101    01.12.11                            01.12.11 14.30   
    01  aw101    01.12.11   01.12.11 15.00   
    01  aw101    01.12.11                             01.12.11 17.45   
    01  aw102    01.12.11   01.12.11 19.20   
    01  aw102    01.12.11                               01.12.11 20.30   
    01  aw102    01.12.11   01.12.11 21.50   
    01  aw102    01.12.11                             01.12.11 23.10   
    01  aw102    01.12.11   01.12.11 23.20   
    01  aw102    02.12.11                          02.12.11 07.00   
    01  aw102    02.12.11   02.12.11 18.00
    01  aw102    03.12.11                        03.12.11 04.30
    01  aw103    01.12.11   01.12.11 09.40 
    01  aw104    01.12.11                         01.12.11 18.00   
    My required output:
    ID  staffid      logdt      login                    logout                diff-in-seconds   
    01  aw101    01.12.11   01.12.11 08.30    01.12.11 10.30  7200
    01  aw101    01.12.11   01.12.11 11.40    01.12.11 14.30  10200
    01  aw101    01.12.11   01.12.11 15.00    01.12.11 17.45  9900
    01  aw102    01.12.11   01.12.11 19.20    01.12.11 20.30  4200
    01  aw102    01.12.11   01.12.11 21.50    01.12.11 23.10  4800
    01  aw102    01.12.11   01.12.11 23.20    02.12.11 07.00  27600
    01  aw102    02.12.11    02.12.11 18.00    03.12.11 04.30  37800
    01  aw103    01.12.11   01.12.11 09.40
    01  aw104    01.12.11              01.12.11 18.00
    Here record aw102 & dt. 01.12.11 / 02.12.11, it should shows the next day out in
    the current date ie. 01.12.11.
    thanks and await your great help please.

    the followings are the testcase
    SQL> create table dt0device (
      2     deviceid varchar2(15),
      3     staffid varchar2(10),
      4     logdt  date,
      5      in_out_flag varchar2(3));
    Table created.
    SQL>  insert into dt0device values('01','aw101',to_date('01.12.2011 08:30','DD/MM/RRRR HH24.MI'),'IN');
    1 row created.
    SQL>   insert into dt0device values('01','aw101',to_date('01.12.2011 10:30','DD/MM/RRRR HH24.MI'),'OUT');
    1 row created.
    SQL>   insert into dt0device values('01','aw101',to_date('01.12.2011 11:40','DD/MM/RRRR HH24.MI'),'IN');
    1 row created.
    SQL>   insert into dt0device values('01','aw101',to_date('01.12.2011 14:30','DD/MM/RRRR HH24.MI'),'OUT');
    1 row created.
    SQL>   insert into dt0device values('01','aw101',to_date('01.12.2011 15:00','DD/MM/RRRR HH24.MI'),'IN');
    1 row created.
    SQL>   insert into dt0device values('01','aw101',to_date('01.12.2011 17:45','DD/MM/RRRR HH24.MI'),'OUT');
    1 row created.
    SQL>
    SQL>   insert into dt0device values('01','aw102',to_date('01.12.2011 19:20','DD/MM/RRRR HH24.MI'),'IN');
    1 row created.
    SQL>   insert into dt0device values('01','aw102',to_date('01.12.2011 20:30','DD/MM/RRRR HH24.MI'),'OUT');
    1 row created.
    SQL>   insert into dt0device values('01','aw102',to_date('01.12.2011 21:50','DD/MM/RRRR HH24.MI'),'IN');
    1 row created.
    SQL>   insert into dt0device values('01','aw102',to_date('01.12.2011 23:10','DD/MM/RRRR HH24.MI'),'OUT');
    1 row created.
    SQL>   insert into dt0device values('01','aw102',to_date('01.12.2011 23:20','DD/MM/RRRR HH24.MI'),'IN');
    1 row created.
    SQL>   insert into dt0device values('01','aw102',to_date('02.12.2011 07:00','DD/MM/RRRR HH24.MI'),'OUT');
    1 row created.
    SQL>   insert into dt0device values('01','aw102',to_date('02.12.2011 18:00','DD/MM/RRRR HH24.MI'),'IN');
    1 row created.
    SQL>   insert into dt0device values('01','aw102',to_date('03.12.2011 04:30','DD/MM/RRRR HH24.MI'),'OUT');
    1 row created.
    SQL>
    SQL>   insert into dt0device values('01','aw103',to_date('01.12.2011 09:40','DD/MM/RRRR HH24.MI'),'IN');
    1 row created.
    SQL>   insert into dt0device values('01','aw104',to_date('01.12.2011 18:00','DD/MM/RRRR HH24.MI'),'OUT');
    1 row created.
    SQL>  create table dt0attlogdevice
      2     ( staffid   varchar2(10),
      3       logdt date,
      4       login  date,
      5       logout date);
    Table created.
    SQL>   insert into dt0attlogdevice  select staffid,logdt,
      2              decode(in_out_flag,'IN',logdt,null) login,
      3              decode(in_out_flag,'OUT',logdt,null) logout
      4       from dt0device;
    16 rows created.
    SQL> select staffid,to_char(logdt,'DD/MM/RR') logdt, to_char(login,'DD/MM/RR HH24.MI') login,
      2  to_char(logout,'DD/MM/RR HH24.MI') logout
      3  from dt0attlogdevice;
    STAFFID    LOGDT    LOGIN          LOGOUT                                      
    aw101      01/12/11 01/12/11 08.30                                             
    aw101      01/12/11                01/12/11 10.30                              
    aw101      01/12/11 01/12/11 11.40                                             
    aw101      01/12/11                01/12/11 14.30                              
    aw101      01/12/11 01/12/11 15.00                                             
    aw101      01/12/11                01/12/11 17.45                              
    aw102      01/12/11 01/12/11 19.20                                             
    aw102      01/12/11                01/12/11 20.30                              
    aw102      01/12/11 01/12/11 21.50                                             
    aw102      01/12/11                01/12/11 23.10                              
    aw102      01/12/11 01/12/11 23.20                                             
    STAFFID    LOGDT    LOGIN          LOGOUT                                      
    aw102      02/12/11                02/12/11 07.00                              
    aw102      02/12/11 02/12/11 18.00                                             
    aw102      03/12/11                03/12/11 04.30                              
    aw103      01/12/11 01/12/11 09.40                                             
    aw104      01/12/11                01/12/11 18.00                              
    16 rows selected.
    ===
    from the above table , I want to generate ouput as below:
    staffid  logdt      login             logout          diff-in-seconds   
    aw101    01.12.11   01.12.11 08.30    01.12.11 10.30  7200
    aw101    01.12.11   01.12.11 11.40    01.12.11 14.30  10200
    aw101    01.12.11   01.12.11 15.00    01.12.11 17.45  9900
    aw102    01.12.11   01.12.11 19.20    01.12.11 20.30  4200
    aw102    01.12.11   01.12.11 21.50    01.12.11 23.10  4800
    aw102    01.12.11   01.12.11 23.20    02.12.11 07.00  27600
    aw102    02.12.11   02.12.11 18.00    03.12.11 04.30  37800
    aw103    01.12.11   01.12.11 09.40
    aw104    01.12.11              01.12.11 18.00
    Here record aw102 & dt. 01.12.11 / 02.12.11, it should shows the next day out in
    the current date ie. 01.12.11.
    I dont know how to make query for the above output.
    please help me.

  • How to Suppress result rows for ALL Characteristic within BEX Analyzer

    HI,
    We Currently upgrade from BEX 3.5 to BEX 7.
    In BEX 3.5 Analyzer  there was an option by right clicking on a Characteristic and then going to "All Characteristic" and then "Suppress all  Result Rows."
    In BEX 7 Analyzer it seems that you can only suppress result rows one characteristic at a time.  Is there a way in BEX 7 Analyzer  to suppress ALL characteristic at once.  The same as BEX 3.5.
    Thanks!
    Edited by: Raylene Tucker on Feb 8, 2010 12:07 PM
    Edited by: Raylene Tucker on Feb 8, 2010 12:09 PM

    Hi,
    in 7x Analyzer,  surpressing the results & Filtering  is specific to characteristic. and this feature is more advanced and useful than the at a time surpress,
    even i fyou go to the Query Properties, it will allow you to surpress by characteristic only instead of at a time.
    Hopes it is clear
    Regards
    ReddY A

  • How not show duplicate rows based on one field

    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
    Hello
    I have a query that looks for certain scripts that did not run on a particular day compared to what ran the same day a week ago. We want to include the start_datetime and end_datetime but when I add it to the select statement it brings up all instances of the jobs that run multiple times during the day. Is there a way to exclude the extra rows based on the script_name field?
    SELECT instances.script_name,
                             instances.instance_name,
                             REGEXP_REPLACE(master.description,
                                            chr(49814),  -- em-dash
                                            '-') description
                                            --instances.start_datetime
                      FROM   xxcar.xxcar_abat_instances Instances,
                             xxcar.xxcar_abatch_master  Master
                      WHERE  1 = 1
                      AND    TRUNC(start_datetime) = TRUNC(TO_DATE(:p_StartDate, 'YYYY/MM/DD HH24:MI:SS')) - (:p_NumOfWeeks * 7)
                      AND    Instances.SCRIPT_NAME = Master.SCRIPT_NAME (+)
                      MINUS
                      SELECT script_name,
                             instance_name,
                             NULL
                             --NULL
                      FROM   xxcar.xxcar_abat_instances
                      WHERE  1 = 1
                      AND    TRUNC(start_datetime) = TRUNC(TO_DATE(:p_StartDate, 'YYYY/MM/DD HH24:MI:SS'))

    MINUS does a set operation - removing rows from the first set that exactly match the second set.
    When you add columns to the first set, you want a more restricted filtering - try a multi-column NOT IN:
    To remove multiple runs, group and get min/max
    SELECT instances.script_name,
                             instances.instance_name,
                             REGEXP_REPLACE(master.description,
                                            chr(49814),  -- em-dash
                                            '-') description,
                             min(instances.start_datetime) start_datetime,
                             min(instances.end_datetime) end_datetime
                      FROM   xxcar.xxcar_abat_instances Instances,
                             xxcar.xxcar_abatch_master  Master
                      WHERE  1 = 1
                      AND    TRUNC(start_datetime) = TRUNC(TO_DATE(:p_StartDate, 'YYYY/MM/DD HH24:MI:SS')) - (:p_NumOfWeeks * 7)
                      AND    Instances.SCRIPT_NAME = Master.SCRIPT_NAME (+)
                      AND (script_name, instance_name) NOT IN
                    ( SELECT script_name,
                             instance_name
                      FROM   xxcar.xxcar_abat_instances
                      WHERE  1 = 1
                      AND    TRUNC(start_datetime) = TRUNC(TO_DATE(:p_StartDate, 'YYYY/MM/DD HH24:MI:SS'))
    group by instances.script_name, instances.instance_name, master.descriptionYou didn't give table definitions, and the query has schemas in it, so I didn't test it.
    regards,
    David

  • Cursor and Update rows based on value/date

    SQL Server 2012
    Microsoft SQL Server Management Studio
    11.0.3128.0
    Microsoft Analysis Services Client Tools
    11.0.3128.0
    Microsoft Data Access Components (MDAC)
    6.1.7601.17514
    Microsoft MSXML 3.0 4.0 5.0 6.0 
    Microsoft Internet Explorer
    9.11.9600.16518
    Microsoft .NET Framework
    4.0.30319.18408
    Operating System
    6.1.7601
    The objective of this is to test the Cursor and use it on a production environment after this is fixed. What I would like to do is update rows in a column i duplicated originally called 'HiredDate' from AdventureWorks2012 HumanResources.Employee table. I
    made a duplicate column called 'DateToChange' and would like to change it based on a date I have picked, which returns normally 2 results (i.e. date is '04/07/2003'). The code runs but will not change both dates. It did run however with an error but changed
    only 1 of the 2 rows because it said ['nothing available in next fetch'].
    The code to add the columns and perform the query to get the results I am running this against:
    -- ADD column 'DateToChange'
    ALTER TABLE [HumanResources].[Employee] ADD DateToChange Date NOT NULL;
    -- Copy 'HireDate' data to 'DateToChange'
    UPDATE HumanResources.Employee SET DateToChange = HireDate;
    -- Change 'DateToChange' to NOT NULL
    ALTER TABLE [HumanResources].[Employee] ALTER COLUMN DateToChange Date NOT NULL;
    SELECT BusinessEntityID,HireDate, CONVERT( char(10),[DateToChange],101) AS [Formatted Hire Date]
    FROM HumanResources.Employee
    WHERE [DateToChange] = '04/07/2003';
    Code:
    USE AdventureWorks2012;
    GO
    -- Holds output of the CURSOR
    DECLARE @EmployeeID INT
    DECLARE @HiredDate DATETIME
    DECLARE @HiredModified DATETIME
    DECLARE @ChangeDateTo DATETIME
    --Declare cursor
    -- SCROLL CURSOR ALLOWS "for extra options" to pul multiple records: i.e. PRIOR, ABSOLUTE ##, RELATIVE ##
    DECLARE TestCursor CURSOR SCROLL FOR
    -- SELECT statement of what records going to be used by CURSOR
    -- Assign the query to the cursor.
    SELECT /*HumanResources.Employee.BusinessEntityID, HumanResources.Employee.HireDate,*/ CONVERT( char(10),[DateToChange],101) AS [Formatted Hire Date]
    FROM HumanResources.Employee
    WHERE DateToChange = '01/01/1901'
    /*ORDER BY HireDate DESC*/ FOR UPDATE OF [DateToChange];
    -- Initiate CURSOR and load records
    OPEN TestCursor
    -- Get first row from query
    FETCH NEXT FROM TestCursor
    INTO @HiredModified
    -- Logic to tell the Cursor while "@@FETCH_STATUS" 0 the cursor has successfully fetched the next record.
    WHILE (@@FETCH_STATUS = 0 AND @@CURSOR_ROWS = -1)
    BEGIN
    FETCH NEXT FROM TestCursor
    IF (@HiredModified = '04/07/2003')/*05/18/2006*/
    -- Sets @HiredModifiedDate data to use for the change
    SELECT @ChangeDateTo = '01/01/1901'
    UPDATE HumanResources.Employee
    SET [DateToChange] = @ChangeDateTo --'01/01/1901'
    FROM HumanResources.Employee
    WHERE CURRENT OF TestCursor;
    END
    -- CLOSE CURSOR
    CLOSE TestCursor;
    -- Remove any references held by cursor
    DEALLOCATE TestCursor;
    GO
    This query is run successfully but it does not produce the desired results to change the dates
    04/07/2003 to 01/01/1901.
    I would like the query to essentially be able to run the initial select statement, and then update and iterate through the returned results while replacing the necessary column in each row.
    I am also open to changes or a different design all together. 
    For this query I need:
    1. To narrow the initial set of information
    2. Check if the information returned, in particular a date, is before [i.e. this current month minus 12 months or
    12 months before current month]
    3. Next replace the dates with the needed date
    [Haven't written this out yet but it will need to be done]
    4. After all this is done I will then need to update a column on each row:
    if the 'date' is within 12 months to 12 months from the date checked
    NOTE: I am new to TSQL and have only been doing this for a few days, but I will understand or read up on what is explained if given enough information. Thank you in advance for anyone who may be able to help.

    The first thing you need to do is forget about cursors.  Those are rarely needed.  Instead you need to learn the basics of the tsql language and how to work with data in sets.  For starters, your looping logic is incorrect.  You open
    the cursur and immediately fetch the first row.  You enter the loop and the first thing in the loop does what?  Fetches another row.  That means you have "lost" the values from the first row fetched.  You also do not test the success of
    that fetch but immediately try to use the fetched value.  In addition, your cursor includes the condition "DateToChange = '01/01/1901' " - by extension you only select rows where HireDate is Jan 1 1901.  So the value fetched into @HiredModified will
    never be anything different - it will always be Jan 1 1901.  The IF logic inside your loop will always evaluate to FALSE.  
    But forget all that.  In words, tell us what you are trying to do.  It seems that you intend to add a new column to a table - one that is not null (ultimately) and is set to a particular value based on some criteria.  Since you intend the
    column to be not null, it is simpler to just add the column as not null with a default.  Because you are adding the column, the assumption is that you need to set the appropriate value for EVERY row in the table so the actual default value can be anything.
     Given the bogosity of the 1/1/1901 value, why not use this as your default and then set the column based on the Hiredate afterwards.  Simply follow the alter table statement with an update statement.  I don't really understand what your logic
    or goal is, but perhaps that will come with a better description.  In short: 
    alter table xxx add DateToChange date default '19010101'
    update xxx set DateToChange = HireDate where [some unclear condition]
    Lastly, you should consider wrapping everything you do in a transaction so that you recover from any errors.  In a production system, you should consider making a backup immediately before you do anything - strongly consider and have a good reason not
    to do so if that is your choice (and have a recovery plan just in case). 

  • How to create a filter based on Effective date EFFDT

    Hello to all,
    I am currently creating reports from an HR database that stores records by employee (EMPLID) based on effective date(EFFDT) and Effective Sequence (EFFSEQ).
    It is easy to get a report that shows all entries up to a certain data (using <= or >=), however, I am not able to create a Filter (in the report or in the prompt)
    that shows me the MAX(EFFDT) up to a certain data dd/mm/yyyy. (any one)
    The sql script we use is the follwiing
    SELECT A.EFFDT, A.EFFSEQ, A.ACTION, A.EMPL_CLASS, *
    FROM PS_JOB A
    WHERE A.EMPLID=' ' ----*(PROMPT1)*
    AND A.EFFDT=(SELECT MAX(B.EFFDT) FROM PS_JOB B
    WHERE B.EMPLID=A.EMPLID
    AND B.EFFDT<=' ') *(PROMPT2)*
    AND A.EFFSEQ=(SELECT MAX(B.EFFSEQ) FROM PS_JOB B
    WHERE B.EMPLID=A.EMPLID
    AND B.EFFDT=A.EFFDT)
    Do I need to create a variable? If yes, How?
    Please send me your suggestions or past experiences with BI on the subject.
    Thanks
    Roberto

    Hi Roberto,
    I would create a session variable via the Oracle BI Administration Tool.
    See the following of how to achieve this:
    http://download.oracle.com/docs/cd/E12096_01/books/admintool/admintool_Variables4.html
    Reference this variable in your filter. It looks something like this VALUEOF(NQ_SESSION."VARIABLE_NAME")
    Good Luck,
    Daan Bakboord

  • Data changed based on current date  in Bex

    Hi Gurus,
       Hope you are all doing good ! I have a scenario in queries in Bex. When the query is executed the current system date must be captured and the data must be divided by the count of the previous months.
       For instance if the query is executed today the data must be divided by 1 ( for  jan)
       if it is executed next month, then the data muset be divided by 2 ( jan + feb ).
       Is there any COUNT variable in Bex ? Any idea how this could be done?
      Points would be assigned for sure.
    Regards,
    Sunitha.R

    Sunitha,
        You should create a variable which is not user entry and user exit as processing type. Based upon the date entered you should write code in CMOD to derive the figure with which you can divide the amount.
    The logic can be something like this:...
    If the user enters     period like 02.2207(feb 2007), then you can pass value as 2 for the variable newly created. This is a simple code which can be written easily if you have ABAP knowledge.
    Try it out.....

Maybe you are looking for

  • Frame Maker 10 with S1000D - Figure TOC not in format

    I am using Frame Maker 10 with S1000D Application Pack, i have new document from S1000D->New->Crew Modle, inputing the data as per the Elements and updating the TOC S1000D->Update TOCs all works fine, but when i insert the Figure and updated the TOCs

  • Error with the average

    Hi Gurus. II need to calculate the avg, but when I choose the atributte for the KF and choose avg for all values, the result are wrong, because the query return the sum of all values. Exemple: V1 = 12 V2 = 14 V3 = 13 V4 = 15 V6 = 14 the result of the

  • How can I reduce clicking when saving images?

    I often open a set of JPEG files and edit them. Unfortunately, saving them after editing is far from streamlined. I have to click three times (save, overwrite, jpeg settings) if I want to save a single file, with wait times in between. Ideally, I wou

  • Cannot install the new update for extreme audio on vi

    when i click the .exe and get to the instalation page it tells me i have a unsupported product and exits i have the vista drivers installed from feb. how do i get this to work?

  • Camera Roll not working properly

    So I have two questions about the camera on the iPhone. The first is that when I take a picture it will appear centered, but when I go to view it in the camera roll it appears off center. Anyone having a situation similar? The other question I have i