Help in  getting Headcount for a month from a flatfile

Hi All,
I am need one help regarding i need to load data from a flat file like for eg
empno  Location     joiningdate     releivingdate
123       USA         11/3/2008        12/9/2008
345       Mexico     14/4/2008         13/11/2008
376       USA         12/2/2008          Null
and the condition is if the releving date  have some value it should taken  employee left the company
i need to create a cube and also on top of the cube need to create a report also
in the query  the formula is
for eg if the user is giving i/p like 05.2008( what ever the user is giving i/p it should automatically taken from current finanacial year ie april)
and in the report i need to write a formula for
%YTD for attrition =( (opening headcount of april 1st+ closing heda count of april end)/2 +opening head count on may 1st + closing head count of may end/2))/n*100
i am getting stuk up with how to get the opening headcount for month and also the closing head count for a month.
VR

There's actually an example of this in the business content in the 0papa_c02 cube:
Re: Head Count
There's also some info about this cube in note 336229.
Similarly, for your data, you might have something like this:
headcount_vc is the change in headcount on the calday.
empno      Location      calday        headcount_vc
123      USA      11/3/2008         1
345      Mexico      14/4/2008         1
376      USA      12/2/2008         1
123      USA      12/9/2008         -1
345      Mexico      13/11/2008   -1
There would be another key figure in the cube headcount_nc which is the cumulation of headcount_vc.
When aggregated together up to a certian day, you will have the correct headcount.
It can get fancier if need be for example if you want a count of retired employees or something:
Anything you want counts by should be time dependant though.
empno      Location      calday        headcount_vc        status
123      USA      11/3/2008         1          active
345      Mexico      14/4/2008         1          active
376      USA      12/2/2008         1          active
123      USA      12/9/2008         -1          active
345      Mexico      13/11/2008   -1          active
123      USA      12/9/2008         1          retired
345      Mexico      13/11/2008   1          retired

Similar Messages

  • I purchased a monthly pack and havent been able to use it. I have been getting charged for 3 months now and I still get an error message saying "unable to load all your plans". How do I re-install or dowload and get my last 3 payments reimbursed?

    I purchased a monthly pack and havent been able to use it. I have been getting charged for 3 months now and I still get an error message saying "unable to load all your plans". How do I re-install or dowload and get my last 3 payments reimbursed?

    Link for Download & Install & Setup & Activation problems may help
    -Online Chat http://www.adobe.com/support/download-install/supportinfo/
    or
    Adobe contact information - http://helpx.adobe.com/contact.html

  • Customer Exit for 13 month from current month

    Hi Gurus,
    I need a customer exit for 13 months from current month. Based on the requirement I have written following code
    When 'VPI_13CALYRMON'.
        IF i_step = 1.
          l_s_range-sign = 'I'.
          l_s_range-opt = 'BT'.
          l_s_range-low = sy-datum+0(6).
          l_s_range-high = sy-datum+0(6) + 13.
          append l_s_range to e_t_range.
        endif.
    Please could you guide me the code.
    Thanks
    Ganesh Reddy.

    Hi,
    I think you can do it in below way.
    When 'VPI_13CALYRMON'.
    IF i_step = 1.
    temp1 = sy-datum+0(4).
    temp1 = temp1 +1. (because adding 13 months would take year to next year)
    temp2 = sy-datum+4(2).
    temp2 = temp2 + 1. (after adding 13 months, the month would be one more than of previous year)
    concatenate temp1 temp2 into temp3.
    l_s_range-sign = 'I'.
    l_s_range-opt = 'BT'.
    l_s_range-low = sy-datum+0(6).
    l_s_range-high = temp3.
    append l_s_range to e_t_range.
    endif.
    Hope this helps.

  • Customer Exit for 15 month from current month

    Hi Gurus,
    I have a requirement to write customer exit for 15 months from current month based on todays day.
    if current day is less than 10 then we have to get 15 months from current month other wise from next month to 15 months.
    this exit I am writing on calendar year/month.
    Please assist for logic.
    Thanks
    Ganesh Reddy.

    I hope this code will do the trick.
    DATA: L_S_RANGE TYPE RSR_S_RANGESID,
    LOC_VAR_RANGE LIKE RRRANGEEXIT,
    zcalmonth(6) type c.
    zcurrentmonth(6) type c.
    zyear(4) type n,
    znextyear(4) type n,
    zyear1(4) type c,
    znextyear1(4) type c,
    zmonth(2) type n,
    zmonth1(2) type n,
    zmonth2(2) type c,
    zmonth3(2) type n,
    zmonth4(2) type c,
    IF i_step = 2.
    CASE i_vnam.
    WHEN '<VARNAME>'.
    zyear = sy-datum+0(4).
    znextyear = zyear + 1.
    zyear1 = zyear.
    znextyear1 = zlastyear.
    zmonth = sy-datum+4(2).
    if sy-datum+6(2) LE 10.
    zmonth1 = zmonth + 2.
    if zmonth1 GT 12.
    zmonth1 = zmonth1 - 12.
    zmonth2 = zmonth1.
    zcurrentmonth = sy-datum+0(6).
    endif
    concatenate znextyear1 zmonth2 into zcalmonth.
    else.
    zmonth1 = zmonth + 3.
    ZMONTH3 = ZMONTH + 1.
    if zmonth1 GT 12.
    zmonth1 = zmonth1 - 12.
    zmonth2 = zmonth1.
    endif
    if zmonth3 GT 12.
    zmonth3 = zmonth3 - 12.
    zmonth4 = zmonth3.
    endif
    concatenate znextyear1 zmonth2 into zcalmonth.
    concatenate znextyear1 zmonth4 into zcurrentmonth.
    endif.
    l_s_range-low = zcurrentmonth.
    l_s_range-high = zcalmonth.
    l_s_range-sign = 'I'.
    l_s_range-opt = 'BT'.
    APPEND l_s_range TO e_t_range.
    ENDIF.
    ENDIF.
    rgds, Ghuru

  • HT4009 having trouble getting purchases for candy crush from the iTunes Store, any suggestions ?

    I am having trouble getting purchases for candy crush from the iTunes Store, any suggestions ?

    The problems being ? Does the 'buy' button not work, do you get any error messages ... ?
    If you are getting a message to contact iTunes Support then you can do so via this link and ask them for help (on these forums we won't know why the message is appearing) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption
    If it's a different problem ... ?

  • Why I can only download 20 photos for last month from the photostream while I have more than 3GB photos kept in iCloud? Many thanks.

    Why I can only download 20 photos for last month from the photostream while I have more than 3GB photos kept in iCloud? My iPhone was stolen and the photos in it are very precious to me. Many thanks.

    On a new device you can only download what is currently stored in "My Photo Stream" in iCloud. iCloud keeps up to the last 1000 photos, but only the photos, that have been added during the last month. Older photos may be removed, when the time is up. On other devices you may be seeing older photos as well in "My Photo Stream", that will depend on the available storage on those devices, and when the Photo Stream has been enabled on those devices, see:  My Photo Stream FAQ - Apple Support
    If you are seeing other photos in the Photo Stream on other devices, that you want to save, mail them to you from the other devices.
    Have you tried to restore your iPhone from the last iCloud backup of the old phone? The backup will contain the photos in the Camera Roll, but not the photos in Photo Stream.   iOS: Back up and restore your iOS device with iCloud or iTunes

  • Min date for each month from list

    Hi all,
    I need to select only minimal date for each month from this sample query:
    select date '2011-01-04' as adate from dual union all
    select date '2011-01-05' as adate from dual union all
    select date '2011-01-06' as adate from dual union all
    select date '2011-02-01' as adate from dual union all
    select date '2011-02-02' as adate from dual union all
    select date '2011-02-03' as adate from dual union all
    select date '2011-10-03' as adate from dual union all
    select date '2011-10-04' as adate from dual union all
    select date '2011-10-05' as adate from dual So the result should be:
    04.01.2011
    01.02.2011
    03.10.2011How do I perform it?

    WITH dates
         AS (SELECT DATE '2011-01-04' AS adate FROM DUAL
             UNION ALL
             SELECT DATE '2011-01-05' AS adate FROM DUAL
             UNION ALL
             SELECT DATE '2011-01-06' AS adate FROM DUAL
             UNION ALL
             SELECT DATE '2011-02-01' AS adate FROM DUAL
             UNION ALL
             SELECT DATE '2011-02-02' AS adate FROM DUAL
             UNION ALL
             SELECT DATE '2011-02-03' AS adate FROM DUAL
             UNION ALL
             SELECT DATE '2011-10-03' AS adate FROM DUAL
             UNION ALL
             SELECT DATE '2011-10-04' AS adate FROM DUAL
             UNION ALL
             SELECT DATE '2011-10-05' AS adate FROM DUAL)
    SELECT TO_CHAR (MIN (adate), 'DD.MM.YYYY') adate
      FROM dates
      GROUP BY to_char(adate, 'YYYY.MM')
    ADATE
    03.10.2011
    01.02.2011
    04.01.2011

  • TS1424 Where and how can i cancel a app on my iphone? I keep getting billed for it monthly.

    Where and how can i cancel a app on my iphone? I keep getting billed for it monthly.

    There are instructions on this page for managing and stopping auto-renewing subscriptions : http://support.apple.com/kb/HT4098
    e.g. if doing it on your phone then go to the bottom of the Featured tab in the App Store app, tap on your id, tap 'view apple id' on the popup and sign in, and on your account's page there should be subscriptions section.

  • Error -50 when opening itunes....PLEASE HELP - been this way for 2 months

    Hi Everyone...I have had this issue for 2 months now and even when I have been talking to apple support team they are unable to fix the problem.
    When I try to open my itunes i get the error message -50...I am running the 64 version of the itunes when its working, with my operating system of Windows 7...Apple technical support thought that it might be my anti-virus program - which is systems mechanic pro (an all in one program for cleaning out my computer)
    I have tried un-installing and then re-installing, over and over again. I have also tired deleting file and installing older versions and I again get the same error. If anyone has any ideas or solutions that would be greatly appreciated as I have been without my itunes for 2 months - and I'm sure you all can understand that your not able to do anything without this program...PLEASE HELP

    I resolved an issue of this description just 2 nights ago. I am guessing the error number is a 'General' error number not a specific one, becasue from reading I see many reasons or fixes for the same error code and as in my case possibly a different underlying causes.
    My (it was my wifes iTunes ) that would not open on her work provisioned laptop. Being a server admin I am the luccky one at home that get to fix it.
    The System side scenario of my (-50) is this:-
    1. Work provide (Windows Vista ) laptop.
    2. Work distribute Software to laptop via networked Windows Distribution services.
    3. My wife uses Quicktime to listen to medical audio off the net that requires Quicktime.
    4. Quicktime installed from said Windows distribution services All works no problem.
    5. Son visits us from USA with an iPad.
    6. Wife buy's an ipad the week released in Australia.
    7. I install Itunes to her laptop so we can 'register iPad'and she can manage her Apps, Doc's and Tunes.
    8. All works good.
    9. iTunes 10 is released and updates her iTunes.
    10. I get called (not sure if same day tho) Help me I don't want to loose or reset my IPad to fix this.
    11. I as she had tried several uninstalls and reinstalls of iTunes.
    12 No change.... still (-50) on loading iTunes.
    13. I call Apple Support (after all we pay for the additional support pack).
    14. Apple check a number of services such as 'MobileDeviceHelper' is loaded and they appear to be.
    15. Apple guide me through an orderly uninstall of ALL Apple Apps that are hooked into iTunes. (order of uninstall is specific to be done properly I will post apps removal orde at bottom of this thread).
    16. I get to Quicktime and I note the Windows distribution of Quicktime 7 and additional Quicktime 10 application installed in 'Windows7 Control Panel 'Programs and Features).
    17. I as an Admin at my wifes work (no I have nothing to do with the desktop Builds) realise I need to go in to my wifes work and (yes) reinstall the vesion 7 Quicktime from our Application Distribution service then Uninstall it.
    18. I do just that Work provisioned Quicktime 7 is uninstalled.
    19. I then set about uninstalling the remainder of the Apple applications that are 'connected to iTunes and for good measure two others that are not.
    20. All is now gone
    21. I reinstall iTunes7
    22. 'Voila' it opens now.
    I seems to me that the update to Itunes introduced an additional install of Quicktime and messed things up. if software is 'distributed' to the laptop as ours is Updates like Quicktime cannot happen unless distributed by work. Neither can you uninstall work distributed apps unless connected to the work network. (Oh we do have (Local Admin) permissions on the work provided laptop to do what we did) Obviously Work provisioned Quicktime will not go on again..
    Oh the Order of uninstalling the Apple apps from a Windows 7 Laptop as provided by the Apple Support Guy is.
    1. iTunes
    2. Quicktime (where I saw the 2 Quicktime installs)
    3. Apple Software Update
    4. Apple Mobile Device Support
    5. Bonjour
    6. Application Support
    For good measure I also uninstalled
    7. Mobile Me Control Panel
    8. Safari
    Restarted the Machine and presto it was working again. I did not manually go and delete the Folders left behind if any were after the uninstall. I noted all my wifes stuff Apps, Tunes, Doc's etc came back when iTunes loaded and the iPad was not connected (which I did first). iPad was connected and sync performed normally.
    Thankfully the marriage is on an even keel again.
    I now have my oWn iPad
    and I now am ******* after a MacBook Pro
    Rachel at work still says ... Get a Mac
    Work still resisting.
    May be MazzBritt not uninstalling in the right order. the Apply guy was adamant it needed to be done so.
    Hope this helps some one........

  • Customer Exit to get last day of month from Year/month

    Hi Experts,
    I need to create a customer exit to get the last day of month from Cal Year month input variable.
    Examples
    1)
    User input period: 12.2008
    I need from the customer exit: 31.12.2008
    2)
    User input period: 02.2009
    I need from the customer exit: 28.02.2009
    Can someone help me with the ABAP code to achieve this with a customer exit?
    Help will be appreciated.

    Hi,
    Please use the following code,
    Second one is the suitable solution for you, I can understand that, if it leafe year then you have the problem so use the secon one.
    First one is using Period i.e. 010.2008 (December 2008).
    Secodn one is based on Date/Month.
    Note: Insted of SY-DATUm, you give your variable name
    *******To get the Last day of the Fy Period entered by User in ZFYP***
        WHEN 'ZLDAY_FI'.
          LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZFYP'.
            zbdatj = loc_var_range-low+0(4).
            zbuper = loc_var_range-low+4(3).
            CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
              EXPORTING
                i_gjahr = zbdatj
                i_periv = 'V3'
                i_poper = zbuper
              IMPORTING
                e_date  = zzdate.
            CLEAR: l_s_range.
            l_s_range-low = zzdate.
            l_s_range-sign = 'I'.
            l_s_range-opt = 'EQ'.
            APPEND l_s_range TO e_t_range.
          ENDLOOP.
    Note: in the below code I given SY-DATUM, so you change to your Month Variable like using  
    LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'XXXX'.
    ** Last Day of Current Calendar month
          zzdate = sy-datum.
          CALL FUNCTION '/OSP/GET_DAYS_IN_MONTH'
            EXPORTING
              iv_date = zzdate
            IMPORTING
              ev_days = znum.
          CLEAR: l_s_range.
          l_s_range-low+6(2) = znum.
          l_s_range-low+0(4) = sy-datum+0(4).
          l_s_range-low+4(2) = sy-datum+4(2).
          l_s_range-sign = 'I'.
          l_s_range-opt = 'EQ'.
          APPEND l_s_range TO e_t_range.
    Thanks
    Reddy
    Edited by: Surendra Reddy on Jan 27, 2009 2:47 PM
    Edited by: Surendra Reddy on Jan 28, 2009 6:12 AM

  • Need help with SQL retrieval for previous month till current date

    Hi ,
    Need help generating statistics from previous month from date of enquiry till current date of enquiry.
    and have to display it according to date.
    Date of enquiry : 03/02/2012
    Application Type| 01/01/2012 | 02/01/2012 | 03/01/2012 |...... | 31/01/2012 | 01/02/2012 | 02/02/2012 | 03/02/2012 |
    sample1 20 30 40
    sample 2 40 40 50
    sample 3 50 30 30
    Hope you guys can help me with this.
    Regards

    Hi,
    932472 wrote:
    Scenario
    1)If i run the query at 12 pm on 03/2/2012. the result i will have to display till the current day.
    2)displaying the count of the application made based on the date.
    Application type 01012012 | 02012012 | 03012012 | ..... 01022012| 02022012|03022012
    sample 1 30 40 50 44 30
    sample 2 35 45 55
    sample 3 36 45 55Explain how you get those results from the sample data you posted.
    It would help a lot if you posted the results in \ tags, as described in the forum FAQ. {message{id=9360002}
    SELECT     application_type as Application_type
    ,     COUNT (CASE WHEN created_dt = sysdate-3 THEN 1 END)     AS 01012012 (should be getting dynamically)
    ,     COUNT (CASE WHEN created_dt = sysdate-4 THEN 1 END)     AS 02022012
    ,     COUNT (CASE WHEN created_dt = sysdate-5 THEN 1 END)     AS 03022012
    , COUNT (CASE WHEN created_dt = sysdate-6 THEN 1 END)     AS 04022012
    FROM     table_1
    GROUP BY application_type
    ORDER BY     application_typeThat's the bais idea.
    You can simplify it a little by factoring out the date differences:WITH got_d     AS
         SELECT     qty
         ,     TRUNC ( dt
              - ADD_MONTHS ( TRUNC (SYSDATE, 'MON')
                        , -1
              ) AS d
         FROM table1
         WHERE     dt     >= ADD_MONTHS ( TRUNC (SYSDATE, 'MON')
                        , -1
         AND dt     < TRUNC (SYSDATE) + 1
    SELECT     SUM (CASE WHEN d = 1 THEN qty END)     AS day_1
    ,     SUM (CASE WHEN d = 2 THEN qty END)     AS day_2
    ,     SUM (CASE WHEN d = 62 THEN qty END)     AS day_62
    FROM     got_d
    See the links I mentioned earlier for getting exactly the right number of columns, and dynamic column aliases.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • When do I get credit for the month of service I had to purchase with my phone upgrade?

    I have been a Verizon wireless customer for years.  I upgraded my phone last month on 10/18 on the Verizon website.  During checkout for my new phone, the cost for my plan for one month was added to the checkout total.  I paid it assuming I would see a credit for this on my next month's bill, but I received my next month's bill with a billing date of 10/28/2013 and it was the normal monthly bill I always get.  When I look at my bill online, it is also the normal monthly bill with no credits.  When do I get credit back for the month I paid for during the phone purchase?   

        serenityn0w, congratulations on your recent upgrade to a new device. When ordering a new device online and charging it to your account; the cost of your calling plan is not included in this purchase. You are billed for the price of the device, accessories, and one time $30.00 upgrade fee.
    Once you activate your device, you are moved to the plan that you selected online during your order transaction. Plan changes during your billing cycle, will create partial and prorated charges on your next bill.
    Proration is an adjustment that is made to your bill when you make a change to your account in the middle of your billing cycle. When proration occurs, this is what you're going to see on your bill:
      • A credit for the portion of your monthly access charge that was billed in advance on the previous number from today's date through the end of the current bill cycle.
      • A charge for the portion of the monthly access for the new number from today's date through the end of the current bill cycle.
      • A charge for the monthly access for the new number for the next month.
      • The monthly allowances associated with your plan may also be prorated, and overage charges may occur.
    I hope that this information is helpful to you.
    LasinaH_VZW
    Follow us on Twitter @VZWSupport

  • Calculations for 6 months from todays date

    Need to calculate the total of all the months starting from today's date for the next 6 months from the current date.
    For ex
    Month              Total
    01.07.2008         10
    01.08.2008         20     
    01.09.2008         50          
    01.10.2008         72
    01.11.2008         85
    01.12.2008         15
    Please advice how to work on this.
    Can we use ranges?
    Thanks in advance.

    Hi dolly,
    Ref this code.....
    TYPE-POOLS  :
                  slis.
    TABLES      :
                  pernr.
    INFOTYPES   :
                  0000,
                  0001,
                  0002.
    TYPES       :
                  BEGIN OF t_final,
                    srlno  TYPE i,                "Serial No
                    pernr  TYPE p0000-pernr,      "Employee No
                    vorna  TYPE p0002-vorna,      "First Name
                    nachn  TYPE p0002-nachn,      "Last Name
                    btrtl  TYPE p0001-btrtl,      "PERSONAL SUB AREA / SEGMENT
                    btext  TYPE t001p-btext,      " SEGMENT DESC
                    begda  TYPE p0000-begda,      " JOINING DATE
                    pdate  TYPE p0000-begda,      " Probation period date.
                  END OF t_final,
                  BEGIN OF t_t001p,
                    btrtl TYPE t001p-btrtl,
                    btext TYPE t001p-btext,
                  END OF t_t001p.
    DATA        :
                  v_year(4) TYPE n,
                  v_year1 TYPE i,
                  count   TYPE i,
                  v_mont(2) TYPE n,
                  v_dt(2) TYPE n,
                  v_date(8),
                  it_final TYPE STANDARD TABLE OF t_final,
                  it_temp  TYPE STANDARD TABLE OF t_final,
                  it_t001p TYPE STANDARD TABLE OF t_t001p,
                  wa_t001p TYPE t_t001p,
                  wa_temp  TYPE t_final,
                  wa_final TYPE t_final.
    ALV Grid Declarations                                               *
    DATA : it_fieldcat TYPE slis_t_fieldcat_alv,
           wa_fieldcat LIKE LINE OF it_fieldcat,
           wa_layout TYPE slis_layout_alv,
           it_sortcat TYPE slis_t_sortinfo_alv,
           wa_sortcat LIKE LINE OF it_sortcat.
    START-OF-SELECTION.
      PERFORM fill_itabs.
    GET pernr.
      rp-provide-from-frst p0000 space '18000101' '99991231'.
      IF pnp-sw-found = 1.
        IF p0000-stat2 = 3.    " Checking for status.
          MOVE  :
                p0000-begda TO wa_temp-begda,
                p0000-pernr TO wa_temp-pernr.
          rp-provide-from-last p0001 space pnpbegda pnpendda.
          IF pnp-sw-found = 1.
            MOVE  :
                    p0001-btrtl TO wa_temp-btrtl.
            CLEAR : wa_t001p.
            READ TABLE it_t001p INTO wa_t001p WITH KEY btrtl = wa_temp-btrtl.
            IF sy-subrc = 0.
              MOVE : wa_t001p-btext TO wa_temp-btext.
            ENDIF.
          ENDIF.
          rp-provide-from-last p0001 space pnpbegda pnpendda.
          IF pnp-sw-found = 1.
            MOVE  :
                    p0002-vorna TO wa_temp-vorna,
                    p0002-nachn TO wa_temp-nachn.
          ENDIF.
          APPEND wa_temp TO it_temp.
          CLEAR : wa_temp.
        ENDIF.  "if p0000-stat2 = 3.
      ENDIF.  "if pn-sw-found = 1.
    END-OF-SELECTION.
      PERFORM process_data.
      PERFORM build_catalog.
      PERFORM display_data.
    *&      Form  PROCESS_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM process_data .
      LOOP AT it_temp INTO wa_temp.
        IF wa_temp-begda+4(2) >  6.
          v_year = wa_temp-begda(4) + 1.
          v_mont = wa_temp-begda+4(2) + 6.
          v_dt   = wa_temp-begda+6(2).
          IF WA_TEMP-BEGDA+4(2) = '08'.
            IF wa_temp-begda+6(2) = '29' OR
               wa_temp-begda+6(2) = '30' OR
               wa_temp-begda+6(2) = '31'.
              v_dt = '28'.
            ENDIF.
          ENDIF.
            IF v_mont > 12.
              v_mont = v_mont - 12.
              CONCATENATE v_year v_mont v_dt INTO v_date.
              MOVE : v_date TO wa_temp-pdate.
            ENDIF.
          ELSE.
            v_mont = wa_temp-begda+4(2) + 6.
            CONCATENATE wa_temp-begda(4) v_mont wa_temp-begda6(2) INTO v_date.
            wa_temp-pdate = v_date.
          ENDIF.
          MODIFY it_temp FROM wa_temp .
          CLEAR : v_date, v_year, v_mont.
        ENDLOOP.
        LOOP AT it_temp INTO wa_temp WHERE pdate BETWEEN pnpbegda AND pnpendda.
          MOVE : wa_temp-pernr TO wa_final-pernr,
                 wa_temp-vorna TO wa_final-vorna,
                 wa_temp-nachn TO wa_final-nachn,
                 wa_temp-begda TO wa_final-begda,
                 wa_temp-btrtl TO wa_final-btrtl,
                 wa_temp-btext TO wa_final-btext.
          CASE wa_temp-pdate+4(2).
            WHEN '04' OR '06' OR '09' OR '11'.
              IF wa_temp-pdate+6(2) > '30'.
                CONCATENATE wa_temp-pdate(4) wa_temp-pdate4(2) '30' INTO v_date.
                MOVE : v_date TO wa_final-pdate.
              ELSE.
                MOVE wa_temp-pdate TO wa_final-pdate.
              ENDIF.
            WHEN '02'.
              v_year1  = wa_temp-pdate+(4) MOD 4.
              IF v_year1 = 0 AND wa_temp-pdate+6(2) > '29'.
                CONCATENATE wa_temp-pdate(4) wa_temp-pdate4(2) '29' INTO v_date.
                MOVE : v_date TO wa_final-pdate.
              ELSEIF v_year1 NE 0 AND wa_temp-pdate+6(2) > '28'.
                CONCATENATE wa_temp-pdate(4) wa_temp-pdate4(2) '28' INTO v_date.
                MOVE : v_date TO wa_final-pdate.
              ELSE.
                MOVE wa_temp-pdate TO wa_final-pdate.
              ENDIF.
            WHEN OTHERS.
              MOVE wa_temp-pdate TO wa_final-pdate.
          ENDCASE.
          count = count + 1.
          MOVE : count TO wa_final-srlno.
          APPEND wa_final TO it_final.
          CLEAR : wa_final, v_year1 , v_date.
        ENDLOOP.
      ENDFORM.                    " PROCESS_DATA
    *&      Form  BUILD_CATALOG
    FORM build_catalog .
      DEFINE m_fieldcat.
        add 1 to wa_fieldcat-col_pos.
        wa_fieldcat-fieldname = &1.
        wa_fieldcat-tabname = 'IT_FINAL'.
        wa_fieldcat-seltext_m = &2.
        wa_fieldcat-outputlen = &3.
        append wa_fieldcat to it_fieldcat.
      END-OF-DEFINITION.
      m_fieldcat 'SRLNO' 'S No' '8' .
      m_fieldcat 'PERNR' 'Employee No' '15'.
      m_fieldcat 'VORNA' 'First Name' '15' .
      m_fieldcat 'NACHN' 'Last Name' '15' .
      m_fieldcat 'BTRTL' 'Segment' '15' .
      m_fieldcat 'BTEXT' 'Segment Desc' '15' .
      m_fieldcat 'BEGDA' 'Date of Joining' '15'.
      m_fieldcat 'PDATE' 'Probation End Date' '15' .
    ENDFORM.                    " BUILD_CATALOG
    *&      Form  DISPLAY_DATA
    FORM display_data .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
       is_layout = ls_layout
          it_fieldcat = it_fieldcat
       it_sort = it_sortcat
      TABLES
        t_outtab = it_final.
    ENDFORM.                    " DISPLAY_DATA
    *&      Form  FILL_ITABS
    FORM fill_itabs .
      SELECT btrtl
             btext
          FROM t001p
          INTO TABLE it_t001p.
    ENDFORM.                    " FILL_ITABS

  • How to get count for missing month

    I created a view as follows:
    CREATE OR REPLACE FORCE VIEW "Vinfection1" ("MONTH", "COUNT") AS
    select "MONTH","COUNT" from (
    select to_char(s.pdate,'Mon-yyyy') as month, count(*) as count
    from surproc s, diagnosis_surproc d
    where s.surprocid = d.surprocid and d.diagnosisid in ('506', '507', '508', '509', '510')
    group by to_char(pdate,'Mon-yyyy'))
    order by to_date(month,'Mon-yyyy')
    Some months are missing in the view. I want to put that month and 0 in the view. How to do it?
    Thanks,
    Jennifer

    Hi, Jennifer,
    You need to outer-join to some table or result set (such as all_months, below) that has one roe per month.
    Here's one way:
    CREATE OR REPLACE FORCE VIEW Vinfection1 (month, month_s, cnt) AS
    WITH    all_months     AS
         SELECT  ADD_MONTHS (first_month, LEVEL - 1)     AS month
         FROM     (
                  SELECT  TRUNC (MIN (pdate), 'MONTH')     AS first_month
                  ,         TRUNC (MAX (pdate), 'MONTH')     AS last_month
                  FROM    surproc
         CONNECT BY     LEVEL <= 1 + MONTHS_NETWEEN (last_month, first_month)
    SELECT  a.month
    ,     TO_CHAR (a.month, 'Mon-yyyy')     AS month_s
    ,     COUNT (*)                 AS cnt
    FROM              all_months      a
    LEFT OUTER JOIN      (     surproc               s
                   JOIN   diagnosis_surproc      d  ON   s.surprocid     = d.surprocid
                                          AND  d.diagnosisid     IN ('506', '507', '508', '509', '510')
               )     ON  a.month     = TRUNC (s.pdate)
    GROUP BY  a.month
    /Avoid table- and column names that are non-standatrd (such as names that need double-quotes), or are built-in function names (such as COUNT).
    Don't use ORDER BY in a view. Almost anything you do with the view will cause the ordering to be lost anyway.
    Even if you do have an ORDER BY clause in the view, you'll often want to ORDER BY month. Rather than call TO_DATE whenever you need to sort, I suggest having two month columns; month (whcih is a DATE) for sorting, filtering and joining, and month_s (whcih is a VARCHAR2) for displaying.
    Use ANSI join syntax, especiallly for outer joins.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.
    Edited by: Frank Kulash on Mar 20, 2012 12:03 PM
    Added outer join condition

  • How to get name of the month from current date.

    Hi,
       How to get the name of the month from current date.
    Thanks,
    Senthil

    Sethil,
    Use your date(let us say Date1) instead of sy-datum.
    CALL FUNCTION 'MONTH_NAMES_GET'
    EXPORTING
    LANGUAGE = SY-LANGU
    IMPORTING
    RETURN_CODE =
    TABLES
    MONTH_NAMES = itab_month
    EXCEPTIONS
    MONTH_NAMES_NOT_FOUND = 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.
    READ TABLE itab_month
    WITH KEY MNR = date1+4(2).
    itab_month-LTX will contain the value you are looking for
    Good luck
    Raghava

Maybe you are looking for