Programming Logic required for pulling the records for past month /week

Hi All
I need help in the SQL programming logic.
Oracle Database Version: 10.2.0.3.0
Requirement
In a data warehouse environment, I need to programme for weekly and monthly automated batch jobs to insert the data from Data_tbl to Reporting_tbl for generating reports. Tables descriptions are given below.
Table1 - Data_tbl (Source table –this table gets updated everyday).
Record_dt     first_name     last_name
Table2 - Reporting_tbl_(Target table)
Cycle_dt     first_name     last_name
1. Monthly Report
In the SQL Query, I have where clause condition—
Where Record_dt >=’01-nov-08’ and record_dt<=’30-nov-08’
Using the above condition in development, I am pulling the data from source table for the past month data. This will be repeated every month and it should be automated.
i.e., if I run this report any time in dec 2008, it should pick records of dates from Nov 01st to Nov 30th 2008. if I run this report any time in Jan 2009, it should pick records of dates from Dec 01st to Dec 31st 2008.
Date Values should be assigned for past month. Value of Cycle_dt in target table should be end date of past month like 30-nov-2008, 31-dec-2008.
2. Weekly Report
In the SQL Query, I have where clause condition—
Where Record_dt >=’01-dec-08’ and record_dt<=’07-dec-08’
Here week start day is Monday and end day is Sunday.
If I run the report between Dec 08th to Dec 14th , it should pull records of dates from Dec 01st to Dec 07th 2008.
On Dec 15th, it should pick from Dec 08th to Dec 14th.
Value of Cycle_dt in target table should be end date of past week like 07-Dec-2008, 14-Dec-2008.
Please help me with the logics for both Monthly and Weekly reports.
Thanks

Hi,
For the monthly report, instead of
Where Record_dt >=’01-nov-08’ and record_dt<=’30-nov-08’say:
Where   Record_dt >= TRUNC (ADD_MONTHS (SYSDATE, -1), 'MM')
and     record_dt <  TRUNC (SYSDATE, 'MM')SYSDATE is the current DATE.
TRUNC (SYSDATE, 'MM') is the beginning of the current month. (Notice the condition above is less than this date, not equal to it.)
ADD_MONTHS (STSDATE, -1) is a date exactly one month ago, therefore it is in the previous month.
For the weekly report, instead of:
Where Record_dt >=’01-dec-08’ and record_dt<=’07-dec-08’say
Where   Record_dt >= TRUNC (SYSDATE - 7, 'IW')
and     record_dt <  TRUNC (SYSDATE, 'IW')TRUNC (dt, 'IW') is the beginning of the ISO week (Monday-Sunday) that contains dt. Again, notice the end condition is strictly less than the beginning of the current week.

Similar Messages

  • In the middle of the installation processing, this has appeared: "There is a problem with the windows installer package. A program is required for this install to complete could not be run." my question is, what is that specific program?

    in the middle of the installation processing, this has appeared: "There is a problem with the windows installer package. A program is required for this install to complete could not be run." my question is, what is that specific program?

    Let's try the following user tip with that one:
    "There is a problem with this Windows Installer package ..." error messages when installing iTunes for Windows

  • Required Condtion to pull the record in ABAP

    Hai Experts-
    I have a requirement in which i need to pull the record with only numeric value.
    for example.
    if v_variable CS 0 or
      v_variable CS 1 or
      v_variable CS 2 ........like this all numeric values 0 to 9.
    v_variable = batchadm.
    endif.
    Is there any other way to achieve this apart from checking all the numerics.
    Cheers,
    ~Srini.....

    Use
    IF v_ variable CO '0123456789'
    <Use select query>
    ENDIF.
    Reward Pts if helpful!

  • Program ID Required for RFC Connection

    Hi All,
    I'm trying to create a RFC Connection betwen SAP BI and SSIS (SQL Server Integration Services). In SM59 screen i'm unable to get the appropriate Program ID required for the connection. Could someone please help me in knowing how to get it.

    Yogesh,
    While creating TCP\IP type RFC destination, when you select Radio button "Registered server program", there you have to provide Program Id there. So for your information:
    Program Id is a string which can be anything even your name.
    i know only R3 and XI integration and in that case you will make your RFC communication channel active first with a program Id(ant thing) and with logon credentials of other system + gateway host and service.
    then use that program id in RFC destination and test it.
    If get empty request then RFC destination is ok.
    BR,
    Alok

  • Is any Programming knowledge require for SAP MDM people ??

    Hi,
    My name is Balu completed Mechanical Engineering. Am Interesting to learn SAP MDM. Is there any Programming Knowledge require for to learn SAP MDM. Please reply my Question.
    Thanks In Advance,
    Best Regards,
    Balu

    My name is Balu completed Mechanical Engineering. Am Interesting to learn SAP MDM. Is there any Programming Knowledge require for to learn SAP MDM. Please reply my Question.
    Thanks In Advance,
    Best Regards,
    Balu
    Hi Balu,
    It all depends on the kind of role you aim at or how you want to sell yourself.
    I dont think programming knowledge is required for core SAP MDM related work but it all depends on the role in hand,project requirement,landscape,customization etc.
    I will like to add that SAP NetWeaver Master Data Management (SAP NetWeaver MDM) can provide a single version of master data for supplier, product, customer, or user-defined data objects in heterogeneous environments.
    It is not only a tool but a part of strategy.It has to interact various SAP as well as legacy systems for data related operations.
    SAP provides its users with set of APIs which one can use to achieve customization as per their requirement.
    There are ABAP,JAVA and .NET APIs provided by SAP for this purpose.
    In all,having a coding experience in any of the above languages would certainly be a plus.
    Hope it help!
    Thanks,
    Ravi

  • Age not getting updated for past months

    Hi all,
    I have loaded the cube 0PA_C01 for HR data regarding Personal Administration.
    Since I have loaded the cube in April,therefore in the cube when I see I get the correct Age of an employee for April.But for March,Feb and Jan I am not getting the Age as it is not getting updated.I checked the update rule 0HR_PA_0 and 0HR_PA_1,according to me it calculates the age based on system date.
    The data in my cube looks as below:
    AGE             CALMONTH                   HEADCOUNT
                     012006                         2679
                      022006                         2694
                      032006                         2694
    15                042006                            1
    20                042006                            1
    and so on.
    Could you please suggest how to get the Age for past months?
    Thanks in advance.
    Best Regards,
    Yogesh

    Is the update rule for age,a customized one?
    If so it could happen that routine was setup after the data load of March.So April load is correct while the other older loads are not.
    Try deleting and reconstructing the data requests of months older than April,in the cube.See if this corrects the age.
    Another thing confused me.
    AGE CALMONTH HEADCOUNT
    012006 2679
    022006 2694
    032006 2694
    15 042006 1
    20 042006 1
    Does datasource send 1 record for each employee?Looks so as it has employee age(which must be calculated by difference between date of birth and system-date).Then how come each record has HEADCOUNT field?
    cheers,
    Vishvesh

  • Call for past 2 weeks.

    How do I find calls/numbers for past 2 weeks of usage. I can find the calls that were listed on my last bill but I need more recent information due to a non-functioning phone.

        Hi community!
    When you first login to My Verizon (www.vzw.com) you will need to make sure to login with the "Account Owner" registered number for the site. On the main page that loads after login, you will see "Usage Details" under the section it displays the number of minutes, messages and data. Click that link and you will see graphs for all the different usage sections. Click "View Detail" under minutes and the calls for the current cycle will load. I'm confident everyone will succeed in viewing these calls.
    Thank you,
    MariaC_VZW
    Please follow us on Twitter @VZWSupport

  • Very slow broadband for past few weeks?

    Hi for past few weeks my broadband speeds and ping been all other the place rasied a fault with bt, and the woman on the phone said interleaving with on, thats why my ping times up and down and it would take upto 48hrs to turn off.
    I got the bt home hub 2 and also got a spare dlink router but the problem is well worse with the homehub ping times 30 to 50 ms higher with the homehub and speeds around 380kbs that not even 0.5mb.
    Anyways to cut a long story short i dont see any where on the hub that tells me about if the interleaving is on or not, i have been with bt since last aug and i never asked for interleaving to be on.
    On my dlink that says its on fast so i no interleaving aint on, 2 weeks later and its even worse now its slow all the time no matter what time of day or night and i phoned bt the other day to say to them, and was told they would phone back today but no call, my profile is 7150 my connection never drops unless i reboot the router or disconnects its self heres a tracert i just done :
    Tracing route to bbc.co.uk [212.58.224.138]
    over a maximum of 30 hops:
      1    <1 ms    <1 ms    <1 ms  192.168.1.1
      2  2331 ms  1149 ms  1571 ms  217.47.106.250
      3  2295 ms  2105 ms  2009 ms  217.47.105.161
      4  2212 ms  1880 ms  1835 ms  213.1.69.74
      5  1889 ms  1812 ms  1808 ms  213.120.157.18
      6  2046 ms  2231 ms  2247 ms  213.120.157.178
      7  1823 ms  1898 ms  1731 ms  109.159.250.94
      8  1912 ms  1871 ms  2058 ms  core1-te0-3-5-0.ealing.ukcore.bt.net [109.159.25
    0.13]
      9  2217 ms  2266 ms  2410 ms  core1-pos5-0-0.telehouse.ukcore.bt.net [194.74.6
    5.122]
     10  1930 ms  1495 ms  1179 ms  194.74.65.42
     11  2011 ms  1682 ms  1740 ms  212.58.238.153
     12  1814 ms  1752 ms  1994 ms  virtual-vip.thdo.bbc.co.uk [212.58.224.138]
    i have tried both my hub and my dlink and its nearly the same the dlink being a bit better if you could say that.
    And heres a test i dont on bt speed tester site this was done a little early around 10:11pm tonight
    Start Test Image not loaded
    The Performance Tester is now testing Broadband connection. Your configured download throughput speed for this service is 7150 k
    Please do not move away from this page and do not start any other download activity on your computer.
    FAQ
    Results Image not loaded
    This Test comprises of Best Effort Test: -provides background information.
        Download  Speed
        357 Kbps
    0 Kbps    7150 Kbps
    Max Achievable Speed
     Download speedachieved during the test was - 357 Kbps
     For your connection, the acceptable range of speeds is 600-7150 Kbps.
     Additional Information:
     Your DSL Connection Rate :8128 Kbps(DOWN-STREAM), 448 Kbps(UP-STREAM)
     IP Profile for your line is - 7150 Kbps
    And that speed its showing there i have been getting for past 2 weeks straight maybe up and down a little but not much It was great for months then this any time i done a speed test then allways a strong 6.9mb no matter what time off day am my exchange is showing green.

    Hi
    Have you checked the link out here this will take you through a step by step guide to ensure the problem is not in your premises, as the fault could be in your own wiring or a faulty ADSL filter.
    Although looking at your speed test results it looks like you have a good speed, what time of the day did you do the ping test? It maybe worth tring it to a number of sites and you can then maybe get an avarege, also avoid the internet peak period.
    (If I have helped you in any way to say "Thank You" please click on the star next to the message. Thank You)
    If I have solved your Issue please click the "Mark as accepted solution" button.

  • Trying to get safari search history for past 3 weeks.  Way to change one week default setting?

    trying to get safari search history for past 3 weeks.  Way to change one week default setting?

    trying to get safari search history for past 3 weeks.  Way to change one week default setting?

  • HT1338 I have installed osx mountain lion, it worked great for past months but recently, my mac takes lots of time to startup and sometimes gets stuck.. what should i do??

    I have installed osx mountain lion, it worked great for past months but recently, my mac takes lots of time to startup and sometimes gets stuck.. what should i do??

    Repair Disk
    Steps 2 through 8
    http://support.apple.com/kb/PH5836
    System Preferences > Startup Disk
    Select your Startup Disk

  • Logic required  for Sort in ALV

    Hi All,
    I am dowloding the ALV report layout in excel sheet thorough mailing functionality.
    I want to implenemnt the dynamic sort. Here I am writing this.but i want the logic for below code.
          CALL FUNCTION 'LT_DBDATA_READ_FROM_LTDX'
            EXPORTING
      I_TOOL             = 'LT'
              IS_VARKEY          = W_VARKEY_EU
            TABLES
              T_DBFIELDCAT       = IT_DBFIELDCAT_EU
            T_DBSORTINFO       =  IT_DBSORTINFO
             T_DBFILTER         = IT_FILTER_LAYOUT
             T_DBLAYOUT         = IT_DB_LAYOUT.
    LIT_DBSORTINFO[] = IT_DBSORTINFO[].
        SORT LIT_DBSORTINFO[] BY KEY1.
        DELETE ADJACENT DUPLICATES FROM LIT_DBSORTINFO[] COMPARING KEY1.
        LOOP AT LIT_DBSORTINFO[].
          CLEAR: LW_SPOS,
                 LW_UP,
                 LW_DOWN,
                 LW_SUBTOT,
                 LW_COMP,
                 LW_EXPA,
                 LW_GROUP.
          CLEAR IT_DBSORTINFO[].
          READ TABLE IT_DBSORTINFO WITH KEY
                                    KEY1  = LIT_DBSORTINFO-KEY1
                                    PARAM = 'SPOS'.
          IF SY-SUBRC = 0.
            LW_SPOS = IT_DBSORTINFO-VALUE.
          ENDIF.
          CLEAR IT_DBSORTINFO.
          READ TABLE IT_DBSORTINFO WITH KEY
                                    KEY1  = LIT_DBSORTINFO-KEY1
                                    PARAM = 'UP'.
          IF SY-SUBRC = 0.
            LW_UP = IT_DBSORTINFO-VALUE.
          ENDIF.
          CLEAR IT_DBSORTINFO.
          READ TABLE IT_DBSORTINFO WITH KEY
                                    KEY1  = LIT_DBSORTINFO-KEY1
                                    PARAM = 'DOWN'.
          IF SY-SUBRC = 0.
            LW_DOWN = IT_DBSORTINFO-VALUE.
          ENDIF.
          CLEAR IT_DBSORTINFO.
          READ TABLE IT_DBSORTINFO WITH KEY
                                    KEY1  = LIT_DBSORTINFO-KEY1
                                    PARAM = 'SUBTOT'.
          IF SY-SUBRC = 0.
            LW_SUBTOT = IT_DBSORTINFO-VALUE.
          ENDIF.
          CLEAR IT_DBSORTINFO.
          READ TABLE IT_DBSORTINFO WITH KEY
                                    KEY1  = LIT_DBSORTINFO-KEY1
                                    PARAM = 'COMP'.
          IF SY-SUBRC = 0.
            LW_COMP = IT_DBSORTINFO-VALUE.
          ENDIF.
          CLEAR IT_DBSORTINFO.
          READ TABLE IT_DBSORTINFO WITH KEY
                                    KEY1  = LIT_DBSORTINFO-KEY1
                                    PARAM = 'EXPA'.
          IF SY-SUBRC = 0.
            LW_EXPA = IT_DBSORTINFO-VALUE.
          ENDIF.
          CLEAR IT_DBSORTINFO.
          READ TABLE IT_DBSORTINFO WITH KEY
                                    KEY1  = LIT_DBSORTINFO-KEY1
                                    PARAM = 'GROUP'.
          IF SY-SUBRC = 0.
            LW_GROUP = IT_DBSORTINFO-VALUE.
          ENDIF.
          LOOP AT IT_ALV_DATA FROM W_LOOP_FROM_EU TO W_LOOP_TO_EU.
            LW_TABIX = SY-TABIX.
            READ TABLE IT_FIELDCAT INTO LW_FIELDCAT WITH KEY
                               FIELDNAME = LIT_DBSORTINFO-KEY1.
            IF SY-SUBRC = 0.
              ASSIGN COMPONENT SY-TABIX OF
                         STRUCTURE IT_ALV_DATA TO <LFS>.
              IF SY-SUBRC = 0.
                CLEAR LW_CHAR.
                LW_CHAR = <LFS>.
                  IF LW_SPOS= 'SPOS'.
                  LOGIC Required
                    ENDIF.
                  ELSEIF LW_OPTION = 'DOWN'.
                 LOgic required
                    ENDIF.
                        ENDIF.
          ENDLOOP.
        ENDLOOP.
    regards,
    Ajay reddy

    Hai,
    Let
    1)general data
    2)all customers
    3)company code data
    4)sales organization data
    are the check box names,Then
    Just use the piece  of code below:
    <b>IF general data = 'X'.
       COUNT = COUNT + 1.
    ENDIF.
    IF all_customers = 'X'.
       COUNT = COUNT + 1.
    ENDIF.
    IF company_code_data = 'X'.
       COUNT = COUNT + 1.
    ENDIF.
    IF sales_organization_data = 'X'.
       COUNT = COUNT + 1.
    ENDIF.</b>
    Now check whether more than one Check Boxes are selected or not
    <b>IF COUNT GT 1.
    "* Do the oprations  what ever you want here  
    ENDIF.</b>
    <b>Reward points if it helps you.</b>
    Regds,
    Rama chary.Pammi

  • Logic required for my normal report

    Hi,
    my report output  is below .
    docu #               material no.           quantity       net price  
    55467488          12376                        10                5
    55467488          12376                         20             10
    55467489           12376                        30             12
                                                                 60             27
    55347388             34567                        56            8
    55347387            34567                          12           12
                                                                      68           20
    grand total                                     ________________
                                                                     128           47
    My requirement is now user  wants for same  material instead of individual lines it should come only one line  with addition operation.please help me how to do it ??In my int. table all the records availavle but ho
    ex.    55467488              12376                        60               27
              55347388             34567                        68               20
    Please search for available information before turning to the forums for help.
    Edited by: kishan P on Sep 3, 2010 11:00 AM

    Hi,
       Use AT NEW and AT END OF control statements for ur requirement. Search SCN how to use AT NEW and AT END OF statement or press F1.
    Regards,
    Selva

  • ABAP programming in BW for past date calculation

    Dear BWGurus,
    the requirement in BW is to calculate past date depending on number of months entered by user.
    1.  is there any FM available in BW .
    2.  I have tried fo FM 'CCM_GO_BACK_MONTHS' but it is not available in BW.
    3.  will this logic work properly.
    DATA : l_mon(2) TYPE n,
           l_days(1000) TYPE n,
           l_udate LIKE SY-DATUM,
           l_frmdate LIKE SY-DATUM.
    get number of days from months
    GETTING THE FROM DATE
    l_frmdate = l_udate - l_days.
    4. is it possible in BW to debug the userexit for
    with regards,
    Rajesh c

    Hi,
    This FM is available in BI7, but Iam not sure abt 3.x....if it is not available in 3.X find the below logic in FM:
    FUNCTION SEPA_MANDATE_ADD_MONTH_TO_DATE.
    ""Lokale Schnittstelle:
    *"  IMPORTING
    *"     VALUE(MONTHS)
    *"     VALUE(OLDDATE) LIKE  SY-DATUM
    *"  EXPORTING
    *"     VALUE(NEWDATE) LIKE  SY-DATUM
      DATA:       BEGIN OF DAT,
                  JJJJ(4) ,
                  MM(2) ,
                  TT(2) ,
                  END OF DAT,
                  BEGIN OF HDAT,
                  JJJJ(4) ,
                  MM(2) ,
                  TT(2) ,
                  END OF HDAT,
                  NEWMM TYPE P,
                  DIFFJJJJ TYPE P.
      WRITE:  OLDDATE+0(4) TO DAT-JJJJ,
              OLDDATE+4(2) TO  DAT-MM,
              OLDDATE+6(2) TO  DAT-TT.
      DIFFJJJJ =   ( DAT-MM + MONTHS - 1 ) DIV 12.
      NEWMM    =   ( DAT-MM + MONTHS - 1 ) MOD 12 + 1.
      DAT-JJJJ = DAT-JJJJ +  DIFFJJJJ.
      IF NEWMM < 10.
        WRITE '0' TO  DAT-MM+0(1).
        WRITE NEWMM TO  DAT-MM+1(1).
      ELSE.
        WRITE NEWMM TO  DAT-MM.
      ENDIF.
      IF DAT-TT > '28'.
        HDAT-TT = '01'.
        NEWMM   = ( DAT-MM  )  MOD 12 + 1.
        HDAT-JJJJ = DAT-JJJJ + ( (  DAT-MM ) DIV 12 ).
        IF NEWMM < 10.
          WRITE '0' TO HDAT-MM+0(1).
          WRITE NEWMM TO HDAT-MM+1(1).
        ELSE.
          WRITE NEWMM TO HDAT-MM.
        ENDIF.
        IF DAT-TT = '31'.
          NEWDATE = HDAT.
          NEWDATE = NEWDATE - 1.
        ELSE.
          IF DAT-MM = '02'.
            NEWDATE = HDAT.
            NEWDATE = NEWDATE - 1.
          ELSE.
            NEWDATE = DAT.
          ENDIF.
        ENDIF.
      ELSE.
        NEWDATE = DAT.
      ENDIF.
    ENDFUNCTION.

  • I have iPhone 5 IOS 8.1.2; for past 13 weeks I get message that my phone has not backed up on the cloud. Every night however the wifi is on, phone is connected to power, and screen is locked. Any idea why back-up is not happening ?

    I have an iPhone 5 IOS 8.1.2;
    for the past 13 weeks I get the message that "this phone has not been backed up on the cloud". However, every night it is connected to wifi, phone is connected to power, and the screen is locked. Any idea why back-up is not happening ? By the way, I do not have the "back up now" option in Setting / iCloud.. Help anyone ?

    Try deleting an other icloud backup and see if it will automatically backup.

  • ATP Qty for past months

    Hi,
    For the current (overall at this time) ATP qty, I am using BAPI_MATERIAL_AVAILABILITY
    Is there any way to get the ATP qty for previous months?
    Thanks,
    John

    Is the update rule for age,a customized one?
    If so it could happen that routine was setup after the data load of March.So April load is correct while the other older loads are not.
    Try deleting and reconstructing the data requests of months older than April,in the cube.See if this corrects the age.
    Another thing confused me.
    AGE CALMONTH HEADCOUNT
    012006 2679
    022006 2694
    032006 2694
    15 042006 1
    20 042006 1
    Does datasource send 1 record for each employee?Looks so as it has employee age(which must be calculated by difference between date of birth and system-date).Then how come each record has HEADCOUNT field?
    cheers,
    Vishvesh

Maybe you are looking for

  • Why can't I download Windows Support Software

    For just over 60 hours I have been attempting, unsuccessfully, to download Windows support software for Boot Camp. I have mad 71 attempts, at all hours of day and night and have received the following message each and every time: "Can't install Windo

  • Flex 3: Does Google Ignore URLs with # in Sitemaps?

    Hi, I'm making a sitemap for my Flex 3 site. Does Google ignore everything after the # in a url listed in a sitemap. For example, if my sitemap lists: www.brainpinata.com/# www.brainpinata.com/#view=2 www.brainpinata.com/#view=12 www.brainpinata.com/

  • Date condition in IR

    Hi, Iam working on IR 11 version. There is a scenario in writing a query where i need to calculate the values for example actual==previous-current for current::: iam using date function between '01-01-08 to 06-06-08'(current) by this iam getting curr

  • How do I copy songs from my iPhone to iTunes and how do I "refresh" my iTunes library?

    I had a HTC and switched over to iPhone, so I deleted the HTC Manager and all of it's contents, so it erased all of my music and now every song in iTunes has the little ! icon next to it and I cant get rid of them. Also, is there a way to copy the so

  • Call function module from BSP0 (Parameter group)

    Hello All, I am trying to call a FM by changing the parameter group of a planning profile (BSP0) as shown:          CALL FUNCTION Z_BW_CLEAR_VAR. The name of the function module is already entered in table RSPLF_FDIR. In the above FM there is DB dele