Pivot sql year/month/category

Need help with this :
Requirement : need to pivot data based on year, month and display the sales correctly. if the data for any month does not exist that month shoudl not appear in the results.
Sample data :
--DROP TABLE APPS.TEST_OM_V CASCADE CONSTRAINTS;
CREATE TABLE APPS.TEST_OM_V
TAX_CATEGORY VARCHAR2(250 BYTE),
SHIP_FROM_ORG_NAME VARCHAR2(100 BYTE),
SCHEDULE_SHIP_DATE DATE,
UNIT_SELLING_PRICE NUMBER,
ORDERED_QUANTITY NUMBER,
INVOICED_SALES NUMBER
Insert into APPS.TEST_OM_V
(TAX_CATEGORY,
SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
Values
('Operating Supplies', 'DC FONT (FONT-120)', TO_DATE('02/01/2012 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 12, 13,
23);
Insert into APPS.TEST_OM_V
(TAX_CATEGORY,
SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
Values
('COFFEE', 'DC CANADA (CAN-180)', TO_DATE('09/30/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 90, 7,
23.34);
Insert into APPS.TEST_OM_V
(TAX_CATEGORY,
SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
Values
('COFFEE', 'DC Florida (FLO-180)', TO_DATE('09/14/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 30, 8,
75);
Insert into APPS.TEST_OM_V
(TAX_CATEGORY,
SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
Values
('COFFEE', 'DC CANADA (CAN-180)', TO_DATE('10/30/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 30, 2,
100.11);
Insert into APPS.TEST_OM_V
(TAX_CATEGORY,
SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
Values
('COFFEE', 'DC CANADA (CAN-180)', TO_DATE('08/30/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 30, 2,
75);
Insert into APPS.TEST_OM_V
(TAX_CATEGORY,
SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
Values
('Operating Supplies', 'DC DIST (DIS-130)', TO_DATE('10/21/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 12, 13,
23);
Insert into APPS.TEST_OM_V
(TAX_CATEGORY,
SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
Values
('COFFEE', 'DC CANADA (CAN-180)', TO_DATE('08/30/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 30, 2,
75);
Insert into APPS.TEST_OM_V
(TAX_CATEGORY,
SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
Values
('Operating Supplies', 'DC CANADA (CAN-180)', TO_DATE('01/02/2012 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), 23, 1,
45);
Insert into APPS.TEST_OM_V
(TAX_CATEGORY,
SHIP_FROM_ORG_NAME, SCHEDULE_SHIP_DATE, UNIT_SELLING_PRICE, ORDERED_QUANTITY, INVOICED_SALES)
Values
('Operating Supplies', 'DC PACK (PK-160)', NULL, 1, 2,
1);
COMMIT;
Expected result , or anything close to this :
                                                                            2011                                     2012
                                                               AUG      SEP          OCT         JAN   FEB      UNSCHEDULED
  COFFEE
                                DC CANADA (CAN-180)          -30         606.66    -40.11         0          0          0
                                DC Florida (FLO-180)          0           165         0           0          0          0
Operating Supplies
                                DC CANADA (CAN-180)           0           0            0         -22        0          0
                                DC DIST (DIS-130)             0           0            133         0         0          0
                                DC FONT (FONT-120)            0           0            0           0         133        0
                                DC PACK (PK-160)              0           0            0           0          0           1 I tried grouping and summing and then lost my way...
select TAX_CATEGORY, SHIP_FROM_ORG_NAME, nvl(TO_CHAR((SCHEDULE_SHIP_DATE), 'MM/YYYY'),'N/A') SCHEDULE_SHIP_DATE,
sum((unit_selling_price * ORDERED_QUANTITY ) - nvl(INVOICED_SALES,0)) CARRYOVER
from XXCNC.TEST_OM_V where 1=1
group by TAX_CATEGORY, SHIP_FROM_ORG_NAME,nvl(TO_CHAR((SCHEDULE_SHIP_DATE), 'MM/YYYY'),'N/A')
order by 1,2,3;
Thanks for your help in advance.
J

Like this?:
SQL> set num 6 lin 120 trims on
SQL> col tax_category for a20
SQL> col SHIP_FROM_ORG_NAME for a32
SQL> break on tax_category
SQL> SELECT *
  2  FROM (SELECT tax_category,
  3               ship_from_org_name,
  4               NVL( TO_CHAR( ( schedule_ship_date ), 'MM/YYYY' ), 'N/A' ) schedule_ship_date,
  5               ( unit_selling_price * ordered_quantity ) - NVL( invoiced_sales, 0 ) carryover
  6        FROM test_om_v) PIVOT (SUM( carryover )
  7                        FOR schedule_ship_date
  8                        IN  ('08/2011' AS "Aug'11",
  9                            '09/2011' AS "Sep'11",
10                            '10/2011' AS "Oct'11",
11                            '11/2011' AS "Nov'11",
12                            '12/2011' AS "Dec'11",
13                            '01/2012' AS "Jan'12",
14                            '02/2012' AS "Feb'12",
15                            'N/A' AS "UNSCHEDULED"))
16  ORDER BY 1, 2, 3
17  /
TAX_CATEGORY         SHIP_FROM_ORG_NAME               Aug'11 Sep'11 Oct'11 Nov'11 Dec'11 Jan'12 Feb'12 UNSCHEDULED
COFFEE               DC CANADA (CAN-180)                 -30 606.66 -40.11
                     DC Florida (FLO-180)                       165
Operating Supplies   DC CANADA (CAN-180)                                                    -22
                     DC DIST (DIS-130)                                 133
                     DC FONT (FONT-120)                                                            133
                     DC PACK (PK-160)                                                                            1
6 rows selected.:p
Edited by: LKBrwn_DBA on Dec 16, 2011 12:18 PM

Similar Messages

  • SSRS Chart group dataset by Year (series groups)/Month (category groups) force intervals to start at JAN?

    Hi all,
    trying to figure this out in REPORT BUILDER, but I guess I can go to VS if needed...
    I've got a data set that says "sales" and its basically order summarycontaining:
    id, dateplaced, and other stuff...
    I want to use this dataset to show trendline for annual qty of orders
    created line chart with "countDistinct(id)" as the series for X
    category groups = groupby "=Month(dateplaced)" and label "=MonthName(Month(dateplaced)"
    series groups = group by "=Year(dateplaced)" and label the same.
    I think this is working as intended, please correct if not.
    The PROBLEM I'm seeing is that since my dataset returns data starting around september so my "axis" starts in september... I really would prefer it starts at Jan and ends in December... I can't see any way to do this...
    The only things I could think of are;
    put fake data in dataset that returns "empty" values for jan in the first year of data...
    change the query completely to make sure tehre are "year" "month" groupings... somehow...
    but both of these approaches seem to be "hacky" and not very maintainable or clear...
    Help!

    Hi noJedi,
    According to your description, you want to you have the category group in your chart always start from January. Right?
    In Reporting Services, when we set category group, the records will sort by the sequence of data in database by default. However, we can apply expression in
    Sorting so that those records can sort by the month. We have tested your scenario in our local environment, here are steps and screenshots for your reference:
    1. Create a chart and put the corresponding expression into category and series group.
    2. Right click on category group. Go to Sorting tab. Put the expression below into sorting expression.
    3. Save and preview. The result looks like below:
    Reference:
    Sort Data in a Data Region (Report Builder and SSRS)
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • Generation on Year Month By SQL

    Respected Freinds,
    I want to generate list of Year Months in format of YYYYMM by using sql query which will
    produce output like, depending on the given starting YYYYMM and Ending YYYYMM
    suppose if i give startin YYYYMM as 200801 and ending YYYYMM as 200912 ....
    YYYYMM
    200801
    200802
    200803
    200804
    200912

    If you have REAL dates as input (you don't mention the datatype of your input), you could:
    SQL> with dates
      2  as(
      3     select to_date('200801', 'yyyymm') startdate
      4     ,      to_date('200912', 'yyyymm')enddate
      5     from dual
      6     )
      7  select to_char(add_months(startdate, level-1), 'yyyymm')
      8  from dates  
      9  connect by level <= months_between(enddate, startdate)+1;
    TO_CHA
    200801
    200802
    200803
    200804
    200805
    200806
    200807
    200808
    200809
    200810
    200811
    200812
    200901
    200902
    200903
    200904
    200905
    200906
    200907
    200908
    200909
    200910
    200911
    200912
    24 rows selected.

  • How to get the difference of two dates in years,months and days

    Hi friends,
    how to get the difference of two dates in years,months and days
    for ex 2 years 3 months 13 days
    select (sysdate-date_Start) from per_periods_of_service
    thanks

    Something like this...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select to_date('17-nov-2006','dd-mon-yyyy') as c_start_date, to_date('21-jan-2008','dd-mon-yyyy') as c_end_date from dual union all
      2             select to_date('21-nov-2006','dd-mon-yyyy'), to_date('17-feb-2008','dd-mon-yyyy') from dual union all
      3             select to_date('21-jun-2006','dd-mon-yyyy'), to_date('17-jul-2008','dd-mon-yyyy') from dual
      4             )
      5  -- end of test data
      6  select c_start_date, c_end_date
      7        ,trunc(months_between(c_end_date, c_start_date) / 12) as yrs
      8        ,trunc(mod(months_between(c_end_date, c_start_date), 12)) as mnths
      9        ,trunc(c_end_date - add_months(c_start_date, trunc(months_between(c_end_date, c_start_date)))) as dys
    10* from t
    SQL> /
    C_START_D C_END_DAT        YRS      MNTHS        DYS
    17-NOV-06 21-JAN-08          1          2          4
    21-NOV-06 17-FEB-08          1          2         27
    21-JUN-06 17-JUL-08          2          0         26
    SQL>But, don't forget that different months have different numbers of days, and leap years can effect it too.

  • About year(), month(), date(), hour(), minute(), second() in Oracle

    In DB2, I can get the value of year, month, date, hour, minute, second from current timestamp by year(), month(), date(), hour(), minute(), second(). Like below SQL,
    SELECT current timestamp, year(current timestamp), month(current timestamp), date(current timestamp), hour(current timestamp), minute(current timestamp), second(current timestamp) FROM DUAL
    In Oracle, how can I modify above SQL?
    That is, do we have the corresponding function to each one of them in DB2?
    Thanks,
    JJ

    Hi Turloch,
    Thanks for your help.
    Here, I have another question.
    How about the days caculation?
    For example, in DB2, I have a SQL as below,
    select
    account_no
    from
    lit_transaction
    where
    ( start_date + no_of_days days - exp_days days) <= CURRENT DATE
    How can I modify above days caculation for Oracle?
    Thanks,
    J.

  • SELECT on year month only in '2013-Jan' format?

    Hi,
    is there a way of selecting on year month only in sql when the format of the date passed is '2013-Jan'. I'm not sure at the moment if I have any control of the date format passed so wanted to explore the sql options.
    using sql server 2008 r2
    thanks,

    Since SQL is a database language, we prefer to do look ups and not calculations. They can be optimized while temporal math messes up optimization. A useful idiom is a report period calendar that everyone uses so there is no way to get disagreements
    in the DML. The report period table gives a name to a range of dates that is common to the entire enterprise. 
    CREATE TABLE Something_Report_Periods
    (something_report_name CHAR(10) NOT NULL PRIMARY KEY
       CHECK (something_report_name LIKE <pattern>),
     something_report_start_date DATE NOT NULL,
     something_report_end_date DATE NOT NULL,
      CONSTRAINT date_ordering
        CHECK (something_report_start_date <= something_report_end_date),
    etc);
    These report periods can overlap or have gaps. I like the MySQL convention of using double zeroes for months and years, That is 'yyyy-mm-00' for a month within a year and 'yyyy-00-00' for the whole year. The advantages are that it will sort with the ISO-8601
    data format required by Standard SQL and it is language independent. The pattern for validation is '[12][0-9][0-9][0-9]-00-00' and '[12][0-9][0-9][0-9]-[01][0-9]-00'
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in
    Sets / Trees and Hierarchies in SQL
    Dear Celko,
    You replied with this exact same answer, word for word, over three weeks ago. Look further up the thread of replies.
    Thanks.

  • Find date if year, month, week and day is given

    Hi,
    How to find the date, if year, month, week and day is given?
    For example:
    Given, year - 2010, month - 03, Day - Wednesday, Week - 3,
    Then how can we get the date as 17-Mar-2010.
    Thanks,
    Chris

    with dt_tbl as (
                    select  2010 year,
                            3 month,
                            3 week,
                            'Wednesday' day
                      from  dual
    select  trunc(to_date(year || '-' || month || '-01','yyyy-mm-dd'),'iw') + (week - 1) * 7 +
              case day
                when 'Monday' then 0
                when 'Tuesday' then 1
                when 'Wednesday' then 2
                when 'Thursady' then 3
                when 'Friday' then 4
                when 'Saturday' then 5
                when 'Sunday' then 6
              end dt
      from  dt_tbl
    DT
    17-MAR-10
    SQL> SY.

  • Calculating years,months & days

    Hi,
    i have to calculate the time duration in years,months and days between contract_start_date and contract_end_date
    eg: Contract_Start_Date = '17-nov-2006' and Contract_End_Date = '21-jan-2008'

    Rehman wrote:
    Hi,
    i have to calculate the time duration in years,months and days between contract_start_date and contract_end_date
    eg: Contract_Start_Date = '17-nov-2006' and Contract_End_Date = '21-jan-2008'It's not the simplest of things to work out.
    If you use the intervals it will, like any other calculation, struggle with the fact that there are different number of days in the month and leap years to take account of.
    Whilst it's simple enough to determine how many whole years have passed and how many months difference there is, the moment you start to take account of the days you become stuck because days in conjunction with months cause the day calculation to be a little more indeterminate...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select to_date('17-nov-2006','dd-mon-yyyy') as c_start_date, to_date('21-jan-2008','dd-mon-yyyy') as c_end_date from dual union all
      2             select to_date('21-nov-2006','dd-mon-yyyy'), to_date('17-feb-2008','dd-mon-yyyy') from dual union all
      3             select to_date('21-jun-2006','dd-mon-yyyy'), to_date('17-jul-2008','dd-mon-yyyy') from dual
      4             )
      5  -- end of test data
      6  select c_start_date, c_end_date,
      7         to_char(c_end_date,'YYYY')-to_char(c_start_date,'YYYY')
      8        -(case when to_date(to_char(c_end_date,'DD-MM')||'-1900','DD-MM-YYYY') <
      9                    to_date(to_char(c_start_date,'DD-MM')||'-1900','DD-MM-YYYY') then 1 else 0 end) as years_between
    10        ,case when to_date(to_char(c_end_date,'DD-MM')||'-1900','DD-MM-YYYY') <
    11                    to_date(to_char(c_start_date,'DD-MM')||'-1900','DD-MM-YYYY') then
    12                    12+(to_char(c_end_date,'MM')-to_char(c_start_date,'MM'))
    13         else (to_char(c_end_date,'MM')-to_char(c_start_date,'MM'))
    14         end -
    15        (case when to_date(to_char(c_end_date,'DD')||'-01-1900','DD-MM-YYYY') <
    16                   to_date(to_char(c_start_date,'DD')||'-01-1900','DD-MM-YYYY') then 1 else 0 end)
    17         as months_between
    18        ,case when to_date(to_char(c_end_date,'DD')||'-01-1900','DD-MM-YYYY') >
    19                   to_date(to_char(c_start_date,'DD')||'-01-1900','DD-MM-YYYY') then
    20              (to_char(c_end_date,'DD')-to_char(c_start_date,'DD'))
    21         else 31-(to_char(c_start_date,'DD')-to_char(c_end_date,'DD'))
    22         end as days_between_approx
    23        ,(c_end_date-c_start_date) year(4) to month as interval_yyyy_mm
    24* from t
    SQL> /
    C_START_D C_END_DAT YEARS_BETWEEN MONTHS_BETWEEN DAYS_BETWEEN_APPROX INTERVAL_YYYY_MM
    17-NOV-06 21-JAN-08             1              2                   4 +0001-02
    21-NOV-06 17-FEB-08             1              2                  27 +0001-03
    21-JUN-06 17-JUL-08             2              0                  27 +0002-01
    SQL>This example shows that a manual calculation can determine the number of years and months ok, but the days have to be approximated; and the interval answer isn't giving the same result for the months as the manual calculation because it can't take account of the days at the same time.

  • I have paid for Creative Cloud - illustrator CC 1 year monthly plan, but it still show "Trial Expired". I have tried to sign in and sign out creative cloud many times, but still can't work. Please help!

    I have paid for Creative Cloud - illustrator CC 1 year monthly plan, but it still show "Trial Expired". I have tried to sign in and sign out creative cloud many times, but still can't work. Please help!

    Does your Cloud subscription show on your account page?
    https://www.adobe.com/account.html for subscriptions on your Adobe page
    Also,
    This is an open forum, not Adobe support... you need Adobe support to help
    Adobe contact information - http://helpx.adobe.com/contact.html
    -Select your product and what you need help with
    -Click on the blue box "Still need help? Contact us"

  • Release Date for Albums Year, MONTH DAY

    Why can't I enter the release date for albums (Year month and day)?   Itunes has a field for year but that's it.    I would have loved to be at the meeting where it was discussed.
    "Year, month and day? why the heck would any want that?"
    "Well a lot of us want to see our albums in chronological order and you can't do that with just the year, many albums come out every year"
    "Blah Blah Blah, music is just to dance to, no one cares about dates, besides it would four extra digit fields in each entry"
    But seriously, I would think that Itunes would aspire to be THE program for music lovers.
    Instead of being able to just enter the release dates I have had to come up with my own work around.  I put a the release date in the format yyyymmdd in fromt of each title and then sort by titles.
    Now all of my Beatle albums finally show up in chronological order by release date.   But why should I have to massage the data like this.   I can't imagine what goes on at Itunes planning  sessions.  I'm very unhappy about the loss of cover flow but that's another story.

    I'm glad to hear that I am not the only one who sees this as a problem.  And another Beatles fan too.
    This is so fundamental.  Every album has a release date and it's part of the data that is always associated with  that album.   Why did Apple look at the data available for an album and consciously decide to truncate it?
    What kind of music lover isn't aware of when albums are released?  I just don't get it.
    I like having the date yyyymmdd in front of each album.   It isn't pretty but it means the albums are chronological.   If you want, you could just put this in the sort field and leave the regular album title in the regular field.   Then the names would be right and they would sort correctly.   But again.  Why should we have to do all that? 
    Apple is busy constantly changing where the controls are on I tunes  rather than fixing something simple and important like this.
    Today I wanted to load some songs onto my ipod touch and it took me 10 minutes to figure out how to sync because the last itunes update got rid of the side bar.  
    How are you supposed to get comfortable using a product when they keep moving the controls around?   Just quit apple.   leave the controls where they are.  Add new controls if needed but stop moving them.  I know I'm ranting now but I am honestly angry and frustrated,

  • Unable to view the Calendar Year/Month in the Query

    Hi All,
    We are having a standard query on Customer InfoCube 0sd_c01_q0003.
    I was able to get the data. But I am unable to view the Calendar Year/month. In that place I am getting '#'.
    I am able to view the details in the InfoCube. There aren't any errors while executing the error.
    Regards
    YJ

    hi,
    U r Problem is not clear...if u r getting # for characteristic values means..u don't have data in Infoprovider...try to view data in InfoProvider with the same selections that u r executing the Query with.
    thnaks

  • Variables for calendar year/month

    Hi All,
    My requirement is to create a headcount report which has to display the number of employees for different time period. ´
    1) When user chooses calender day then the report should display total number of employees on that time period(01.01.2005)-(10.01.2009).
    2) If user chooses calyear /month then he should see the report for each calyear/month (like 01.2005 , 02.2005,02,2005....)in the columns.
    I tried dropping calyear/month in column and i got the result for my second scenario (like 01.2005 , 02.2005,02,2005....)
    But when the user chooses the calday it still shows the report by calmonth (bcoz of calyear/month in the column).
    I also tried text variable for calyear/moth(replacement path method) but i have the restriction in the interval (from date or to date - i have to choose one by default) so it shows only either date in the columns .
    The  two variables. 1) Calender Day (Interval,Optional)) 2) Calender Year /Month (Interval,Optional)
    I got four restricted key figure to restrict number of employees by business.
    Eg :
    When Cal Day is choosed then the report will be :(01.01.2005 -10.01.2009)
                   (01.01.2005 - 10.01.2009)
    Country  Sales Finance
    India        20      30        
    Denmark  30      50        
    When Calyear / Month is choosed then the report will be : (01.2005 - 02-2005) :
                        01.2005                    02.2005                                
    Country     Sales Finance      Sales Finance    
    India           24     70                70         45       
    Denmark    36      60               56        30         
    Regards
    A.Vasister
    Edited by: vasister a on Oct 9, 2009 11:10 AM

    Hello,
    This cannot be achived dynamically.
    I think the two ways you can work out is creating two different reports one to include daywise and the other to include montwise structure.
    Otherwise you can keep calday in free char and ask user to swap calmonth with calday as per requirement.
    Else you have to create a workbook report and make use of VB macros to calculate report dynamically which is a very complex approach.
    Regards,
    Shashank

  • FM to get the number of days in Year,month and days by giving number of day

    Hi ALL,
    This is quit differnt.
    I need to give input the 'start date' and the 'number of days' and get the total days from the start date in year,month and day format.
    for example.
    start date :01.01.2009
    number of days as 32
    then i should get
    years:0
    months :1
    days :1
    Pleas help me out.

    hi Anusha,
    first u pass the date and the days to the following fm you will get the result date....
    data:date type sy-datum,
          r_date(10) type c.
    date = sy-datum.
    CALL FUNCTION 'CALCULATE_DATE'
    EXPORTING
       DAYS              = '32'
       MONTHS            = '0'
       START_DATE        = date
    IMPORTING
       RESULT_DATE       = r_date
    write:/ r_date.
    then you need to pass the result date and the date to the following fm to get the required output...
    CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
        EXPORTING
          date1                   = r_date
          date2                   = date
        IMPORTING
          years                   = v_years
         months                 = v_months
        days                     = v_days
        EXCEPTIONS
          invalid_dates_specified = 1
          OTHERS                  = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    here u will get the difference in days,  months and year...
    i hope u wil get help from this...
    regards
    Ashu  Singh

  • Selective deletion based on Calendar Year/Month in process chains

    Hi all,
    I have a requirement from the business wherein I have to delete the past months data before I load the same data into 6 infocubes using a process chain.
    I checked the forums to understand how selective deletion is used in a process chain and I have come to know that RSDRD_DELETE_FACTS program or DELETE_FACTS Tcode can be used to generata a G* program that performs the deletion.
    I am to integrate this generated program in my process chain. I have 0CALMONTH(Calendar Year/Month) as the time characteristic in all my infocubes and therefore the only time characteristic available for selective deletion.
    My problem is that I am unable to create a dynamic selection for the Calendar Year/Month such that it takes the previous month.To be exact I am unable to use the "D" option in the Selection Variable column for this characteristic.
    Please can somebody help me out with this.

    Hi,
    Use this ABAP program code in your Process Chain...
    Type Pools
        TYPE-POOLS: rsdrd, rsdq, rssg.
    Local Internal Tables
        DATA: lit_msg     TYPE rs_t_msg,
                    lit_sel     TYPE rsdrd_thx_sel.
    Local Work Area
        DATA : lwa_sel_kf1     TYPE rsdrd_sx_sel,
                   lwa_range_kf1  TYPE rsdrd_s_range.
    Local Constants
        CONSTANTS :    lc_i(1)      TYPE c  VALUE 'I',
                                 lc_x(1)      TYPE c  VALUE 'X',
                                 lc_eq(2)     TYPE c  VALUE 'EQ',
                                 lc_kf1(11)   TYPE c  VALUE '0CALMONTH'.
        CONSTANTS :   lc_cube      TYPE rsddatatarget VALUE 'Z_C21'.
    Delete Existing cube records
    Key Field 1 (CALMONTH)
          lwa_range_kf1-sign    = lc_i.
          lwa_range_kf1-option  = lc_eq.
          lwa_range_kf1-high    = space.
          lwa_range_kf1-keyfl   = lc_x.
          lwa_range_kf1-low     = <Value of CALMONTH>.
          APPEND lwa_range_kf1 TO lwa_sel_kf1-t_range.
          CLEAR  lwa_range_kf1.
           lwa_sel_kf1-iobjnm = lc_kf1.
          INSERT lwa_sel_kf1 INTO TABLE lit_sel.
          CLEAR : lwa_sel_kf1.
    Selective Deletion through FM
          CALL FUNCTION 'RSDRD_SEL_DELETION'
            EXPORTING
              i_datatarget      = lc_cube
              i_thx_sel         = lit_sel
              i_authority_check = space
              i_mode            = lc_c
              i_no_enqueue      = lc_x
            CHANGING
              c_t_msg           = lit_msg
            EXCEPTIONS
              x_message         = 1
              inherited_error   = 2
              invalid_type      = 3
              OTHERS            = 4.
          IF sy-subrc = 0.
            REFRESH : lit_sel[],
                      lit_msg[].
          ENDIF.
    Thanks,
    Saru

  • How to get date difference in terms of years,months and also days

    Tool : Eclipse
    Framework : JSF & Springs
    JRE : jdk1.5.0_06
    Iam using oracle 10G DB as back end.I have two date fields in a table.
    1)premium_paying_start_date
    2)premium_paying_end_date
    Iam getting these two dates from the database and storing these values within a entity.Now in the delegate layer,
    i have to get the premium_term i.e, the difference between the two dates(premium_paying_end_date-premium_paying_start_date).
    The difference should show the year,month and no of days difference.
    For example :
    premium_paying_start_date : 14-10-1984
    premium_paying_end_date : 01-03-2008
    Difference should be : 23 Y : 4 M : 15 D (Y = years, M = months , D= days)
    So please give me the solution for this.

    Difference should be : 23 Y : 4 M : 15 D (Y = years, M = months , D= days)
    So please give me the solution for this.How did you determine what the difference should be?
    ~

Maybe you are looking for

  • Number of plays and last played date

    In the current version of iTunes, it no longer seems to update the number of plays for a song or the last played date. (Actually, it does update the date intermittently, but for the most part that feature is no lomger working.) Anyone know how to fix

  • Problem while defining Busiiness System

    Hi, We are using Xi 3.0 , CCM 2.0 , SRM 5.0 and we need to import material from SRM to CCM. while creating the Business System in SLD, where we have to specify the role of Business System As an Application System or Integration Server, we have to giv

  • Adding new page in WebTools 2007

    How can I create my own page in webtools 2007 that will inherit the theme? I was able to do this in 596 using the sample below but this doesn't work in WT. Am I inheriting from the wrong class now? <%@ Import Namespace="netpoint.classes" %> <%@ Page

  • My iTunes downloads okay but just won't install. Keeps telling me program is missing - what do I do? I need to link up my iPhone 4S

    My question is this - why won't iTunes install on my PC? Never had trouble in the past but now I have an iPhone it just won't install Can someone help me please? Thanks in advance KnitWit46

  • Custom colour swatches and analysing a photo

    hi! i have two questions. what i want to do is taking pictures of my patients teeth with a neutral grey on the photo to get the white balance right. then i would like to analyse areas of the photo. i was told that it is possible to generate a palette