Create a field routine to calculate the number of days per month

Hi Experts,
I need to create a field routine to count the number of days per month based on 0CALMONTH. Could you give me some inputs on how to do it?
Thanks!

Hi,
Create InfoObejct and then insert it in InfoSource/InfoCube/DSO then write simp,e code for that based on your  0CALMONTH values.
You just copy and pas this in SE38 and see the result and implement for your requirements.
REPORT  ztest1.
Data: zsydt type sy-datum,
      zd(2) type n,
      zm(2) type n,
      zy(4) type n,
      zcmnth TYPE /bi0/oicalmonth,
      znds TYPE /osp/dt_day.
      zsydt = sy-datum.
      zd = '01'.
      zm = zsydt+4(2).
      zy = zsydt+0(4).
      CONCATENATE zy zm zd INTO zsydt.
      CALL FUNCTION '/OSP/GET_DAYS_IN_MONTH'
            EXPORTING
              iv_date = zsydt
            IMPORTING
              ev_days = znds.    "No.of days in month.
      write:/ zd.
      write:/ zm.
      write:/ zy.
      write:/ zsydt.
      write:/ znds.
Thanks
Reddy

Similar Messages

  • How do you show the number of days per month?

    How do you show the number of days per month?
    I am working on a budget.  I want to know how much to amortize each month to fund an investment.  Income comes monthly, but expenses leave in days, or weeks.  The number of days and weeks in months vary. 
    I want to figure out income and expenses per day, per month and per year, so I know how much can be invested each month, week or day.  For a start I would like a formula that shows how many days are in each month?

    thanks..
    I solve my problem as
    public class MyExample {
        public static void main(String a[]) {
            String stdate = "2009-03-01";
            java.sql.Date currentDate = new java.sql.Date(System.currentTimeMillis());
            java.sql.Date preDate = java.sql.Date.valueOf(stdate);
            System.out.println(currentDate);
            System.out.println(preDate);
    //        int dateCom = preDate.compareTo(currentDate);
    //        System.out.println(dateCom);
            long diff = currentDate.getTime() - preDate.getTime();
            int days = (int) Math.floor(diff / (24 * 60 * 60 * 1000));
             System.out.println(days);
    }

  • How to calculate the number of days worked for a given period

    I need to calculate the number of days worked by contractor employees for a time period to be entered by a user. I am building a query on an infoset which contains employee information including contract start date and contract end date for the employee.
    Ideally I'd like the user to enter the time period which should be reported on e.g. 01.08.2009 to 31.08.2009
    The report should then identify all the contractor employees which were working during this period and to work out how many days they worked during this period. Obviously the contract start and end dates could fall both inside and outside the reporting period.
    Can this be done and if so, do you have any suggestions as to how to do it?
    Thanks.

    hi
    So here you will first have to load the master data table employee in one internal table and read this table with the variables entries.
    Your code in the reporting exit should look like that.
    bye
    data : wa_employee type /bi0/pemployee.
    When 'ZDATE1'
    if i_step = 2.
    LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZDATE2'.
    clear l_s_range.
    clear wa_employee
    1- select the entries from table employees
    select single employee dateto datefrom
    from /bi0/pemployee
    into corresponding fields of wa_employee
    where dateto le loc_var_range-low
    and datefrom ge loc_var_range-high.
    if sy-subrc eq 0.
    CALL FUNCTION 'FIMA_DAYS_BETWEEN_TWO_DATES'
       EXPORTING
           i_datum_von  = wa_employee-datefrom
           i_kz_ult_von = 'X'
           i_datum_bis  = wa_employee-dateto
           i_kz_ult_bis = 'X'
           i_szbmeth    = '1'
       IMPORTING
          e_tage       = no_days.
           l_s_range-low  = no_days.
           l_s_range-sign = 'I'.
           l_s_range-opt  = 'EQ'.
          APPEND l_s_range TO e_t_range.
              ENDIF.
            ENDIF.
    endloop.
    ENDIF.
    Boujema

  • How to calculate the number of days until your next birthday. Only using current month, day and birth month and day.

    I'm trying to calculate the number of days until your next birthday. Only using current month, day and birth month and day. I can get close but i'm way off. When i enter in the next day, the amount of days is supposed to be 364. This is where I am having problems. I know my code is way off. I just need some guidance please!
    Attachments:
    D5.7_1.vi ‏8 KB

    I just had a little fun with the Time Record...
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    D5.7_1_BD.png ‏19 KB

  • I wanted to know how do you calculate the number of days between two dates

    i wanted to know how do you calculate the number of days between two dates in java ? i get both the dates from the database. i guess there are many issues like leap year and Febuary having diff no of months ..etc.

    thanks..
    I solve my problem as
    public class MyExample {
        public static void main(String a[]) {
            String stdate = "2009-03-01";
            java.sql.Date currentDate = new java.sql.Date(System.currentTimeMillis());
            java.sql.Date preDate = java.sql.Date.valueOf(stdate);
            System.out.println(currentDate);
            System.out.println(preDate);
    //        int dateCom = preDate.compareTo(currentDate);
    //        System.out.println(dateCom);
            long diff = currentDate.getTime() - preDate.getTime();
            int days = (int) Math.floor(diff / (24 * 60 * 60 * 1000));
             System.out.println(days);
    }

  • How to find the number of records per months  in cube

    Hi,
      how to find the number of records per months for my all cubes?
      Can i use the ListCube transaction to find totl number f records per cube monthwise ?
    Jimmy

    Hi,
    Here is a program to generate no of records and list of ODS and Cubes in Active version.Schedule this program in background and create a cube to load this information and schedule to the data from the file generated by the program. Schedule this all per you requirement.
    1.Copy the code into your Z<programname> from Se38.
    2.change the FILENAME in CALL FUNCTION 'GUI_DOWNLOAD' in the program to the location from where you can pick the information to load data to cube(eg Application server).
    3.Save program.
    4.Schedule the program in background as required
    5.Create cube with infoobjects to hold no of records and Infoprovider name
    6.Load this cube based on event after the program job is done.
    Hence you can report on this cube to see no of records in  CUBE or ODS in your box.
    Please find the code below.
    Cheers,
    Kavitha Kamesh.
    types: begin of itabs ,
          tabname type dd02l-tabname,
          end of itabs.
    data: itab type itabs occurs 0 with header line.
    data: counter type i.
    data: begin of itab1 occurs 0,
    tabname type dd02l-tabname,
    counter type i,
    end of itab1.
    DATA: ITABTABNAME TYPE STRING.
    DATA: LENGTH TYPE I.
    DATA: OBJECT(30).
    data: str(6) type c.
    select  tabname from dd02l into table itab where ( tabname LIKE  '/BIC/F%' or tabname LIKE  '/BIC/A%00' )
    and TABCLASS = 'TRANSP' and AS4LOCAL = 'A'.
    loop at itab.
      select count(*) from (itab-tabname) into counter.
      str = itab-tabname.
      if str = '/BIC/F'.
    LENGTH  = STRLEN( ITAB-TABNAME ).
      SHIFT  itab-tabname BY 6 PLACES LEFT.
    ELSEIf  str = '/BIC/A'.
      SHIFT  itab-tabname BY 6 PLACES LEFT.
      LENGTH  = STRLEN( ITAB-TABNAME ).
    LENGTH = LENGTH - 2.
    endif.
      itab1-tabname = itab-tabname(LENGTH).
      append itab1.
      itab1-counter = counter.
      clear itab-tabname.
      clear:  COUNTER.
    endloop.
    *********** itab1
    loop at itab1.
    write:/ itab1-tabname, itab1-counter.
    endloop.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
    *   BIN_FILESIZE                    =
        FILENAME                        = 'c:records.xls'
        FILETYPE                        = 'ASC'
    *   APPEND                          = ' '
        WRITE_FIELD_SEPARATOR           = ','
    *   HEADER                          = '00'
    *   TRUNC_TRAILING_BLANKS           = ' '
    *   WRITE_LF                        = 'X'
    *   COL_SELECT                      = ' '
    *   COL_SELECT_MASK                 = ' '
    *   DAT_MODE                        = ' '
    *   CONFIRM_OVERWRITE               = ' '
    *   NO_AUTH_CHECK                   = ' '
    *   CODEPAGE                        = ' '
    *   IGNORE_CERR                     = ABAP_TRUE
    *   REPLACEMENT                     = '#'
    *   WRITE_BOM                       = ' '
    *   TRUNC_TRAILING_BLANKS_EOL       = 'X'
    *   WK1_N_FORMAT                    = ' '
    *   WK1_N_SIZE                      = ' '
    *   WK1_T_FORMAT                    = ' '
    *   WK1_T_SIZE                      = ' '
    * IMPORTING
    *   FILELENGTH                      =
      TABLES
        DATA_TAB                        = itab1
    *   FIELDNAMES                      =
    * EXCEPTIONS
    *   FILE_WRITE_ERROR                = 1
    *   NO_BATCH                        = 2
    *   GUI_REFUSE_FILETRANSFER         = 3
    *   INVALID_TYPE                    = 4
    *   NO_AUTHORITY                    = 5
    *   UNKNOWN_ERROR                   = 6
    *   HEADER_NOT_ALLOWED              = 7
    *   SEPARATOR_NOT_ALLOWED           = 8
    *   FILESIZE_NOT_ALLOWED            = 9
    *   HEADER_TOO_LONG                 = 10
    *   DP_ERROR_CREATE                 = 11
    *   DP_ERROR_SEND                   = 12
    *   DP_ERROR_WRITE                  = 13
    *   UNKNOWN_DP_ERROR                = 14
    *   ACCESS_DENIED                   = 15
    *   DP_OUT_OF_MEMORY                = 16
    *   DISK_FULL                       = 17
    *   DP_TIMEOUT                      = 18
    *   FILE_NOT_FOUND                  = 19
    *   DATAPROVIDER_EXCEPTION          = 20
    *   CONTROL_FLUSH_ERROR             = 21
    *   OTHERS                          = 22
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  • Calculate the number of days in a year excluding Saturday and Sunday

    Hi All,
    I need to get the number of days in a year excluding Saturday and Sunday for HR module and then subtract the public holidays.
    Can some let me know how this needs to be done while loading data from one infocube to another.
    Is there any Function module for the same so that i can write any start routines.
    And also is there any table available for Tcode-SCAL with which i can write any start routines.
    Kindly help me as soon as possible.
    Regards,
    Kumar

    Hi Harish
    Refer to the screenshot for Import and Export parameters
    Code
    FUNCTION ZBI_FM_GET_HOLIDAYS .
    *"*"Local Interface:
    *"  IMPORTING
    *"    VALUE(DATE_FROM) TYPE  SCAL-DATE DEFAULT SY-DATUM
    *"    VALUE(DATE_TO) TYPE  SCAL-DATE DEFAULT SY-DATUM
    *"    VALUE(FACT_CAL) TYPE  SCAL-FCALID DEFAULT SPACE
    *"    VALUE(ONLYFACT_DAYS) TYPE  CHAR1 OPTIONAL
    *"  EXPORTING
    *"    REFERENCE(HOLIDAYS) TYPE  I
    *"  TABLES
    *"      DAY_ATTRIBUTES STRUCTURE  CASDAYATTR
    *"  EXCEPTIONS
    *"      FACTORY_CALENDAR_NOT_FOUND
    *"      HOLIDAY_CALENDAR_NOT_FOUND
    *"      DATE_HAS_INVALID_FORMAT
    *"      DATE_INCONSISTENCY
    DATA: LT_DAY_ATTRIBUTES TYPE TABLE OF  CASDAYATTR WITH HEADER LINE.
    DATA: LV_LINES TYPE SY-SUBRC.
    DATA: DATE1 LIKE DATE_FROM,
    DATE2 LIKE DATE_TO.
    *if from date is gt to date then interchange the dates and multiply the result with -1.
    IF DATE_FROM GT DATE_TO.
    DATE2 = DATE_FROM.
    DATE1 = DATE_TO.
    ELSE.
    DATE1 = DATE_FROM.
    DATE2 = DATE_TO.
    ENDIF.
    CALL FUNCTION 'DAY_ATTRIBUTES_GET'
    EXPORTING
    FACTORY_CALENDAR                = FACT_CAL
    *  HOLIDAY_CALENDAR                = ' '
    DATE_FROM                        = DATE1
    DATE_TO                          = DATE2
    LANGUAGE                        = SY-LANGU
    * IMPORTING
    *  YEAR_OF_VALID_FROM              =
    *  YEAR_OF_VALID_TO                =
    *  RETURNCODE                      =
    TABLES
    DAY_ATTRIBUTES                  = LT_DAY_ATTRIBUTES
    EXCEPTIONS
    FACTORY_CALENDAR_NOT_FOUND      = 1
    HOLIDAY_CALENDAR_NOT_FOUND      = 2
    DATE_HAS_INVALID_FORMAT          = 3
    DATE_INCONSISTENCY              = 4
    OTHERS                          = 5 .
    IF SY-SUBRC = 0.
    IF ONLYFACT_DAYS = 'X'.
    DELETE LT_DAY_ATTRIBUTES WHERE FREEDAY EQ SPACE.
    ELSE.
    DELETE LT_DAY_ATTRIBUTES WHERE WEEKDAY LT 6.
    ENDIF.
    DESCRIBE TABLE LT_DAY_ATTRIBUTES LINES LV_LINES.
    HOLIDAYS =  LV_LINES.
    *    IF DATE_FROM GT DATE_TO.
    *      HOLIDAYS = HOLIDAYS * -1.
    *    ENDIF.
    ELSEIF SY-SUBRC = 1.
    RAISE FACTORY_CALENDAR_NOT_FOUND.
    ELSEIF SY-SUBRC = 2.
    RAISE HOLIDAY_CALENDAR_NOT_FOUND.
    ELSEIF SY-SUBRC = 3.
    RAISE DATE_HAS_INVALID_FORMAT.
    ELSEIF SY-SUBRC = 4.
    RAISE DATE_INCONSISTENCY.
    ENDIF.
    ENDFUNCTION.

  • Calculate the number of days in a month

    I need to do a calculation in my query based upon the number of days in the month. The report is broken down by cal year / month.
    Is there an easy way of identifying these values in the query?
    Regards.

    Hi,
      This can be done by writing an user exit code to determine the number of days in the month.
    Sample Code :
    <
    CHECK i_step = 2.
      READ TABLE i_t_var_range WITH KEY vnam = 'XXXX'
                               INTO loc_var_range.
      IF sy-subrc EQ 0.
        beg_date(6) = loc_var_range-low(6).
        end_date(6) = loc_var_range-low(6).
        beg_date+6(2) = '01'.
        end_date+6(2) = '01'.
        ADD 1 TO end_date+4(2).
        IF end_date+4(2) = '13'.
          end_date+4(2) = '01'.
          ADD 1 TO end_date(4).
        ENDIF.
        no_days = end_date - beg_date.
        l_s_range-sign = 'I'.
        l_s_range-opt  = 'EQ'.
        l_s_range-low  = no_days.
        APPEND l_s_range TO e_t_range.
      ENDIF.
    >
    Hope this helps..
    Thanks & Regards,
    Pradeep

  • How to calculate the number of user connections in a report?

    Hi,
    I would like to have a report which automatically calculate the number of connections per user.
    Thanks for your answer.
    Regards

    Hi,
    What do you mean by number of connections? Do you mean how many times each user has run a specific report?
    Thanks

  • How do you work out the number of days difference between two dates?

    I'm running Crystal v12.
    We use a date field in our SQL database that we use to store the client's year end date.
    As the year end date (date and month) doesn't change for a client, the year end date field in all of our reports is set to just show the DD/MM part. Over the years as new clients are set up we just enter the date and month - the year part is irrelevant although as in all date fields the year is automatically entered.
    Doing it this way means that we don't have to adjust the year end year part each year. We just use the DD/MM part.
    I need to create a formula that works out the number of days there have been (i.e. the difference) from the current date to the year end date. It MUST EXCLUDE the year however.
    For example:
    Year End Date = 30/04/03
    Current Date = 25/05/10
    Days Difference (EXCLUDING year) = 25
    Days Difference (including year) = 2582
    Year End Date = 31/03/09
    Current Date = 25/05/09
    Days Difference (EXCLUDING year) = 55
    Days Difference (including year) = 420
    If you include the year part then working out day difference is simply a case of creating a formula that subtracts the year end date from the current date (CurrentDate - {tblClient.YearEnd}.
    HOWEVER I need to exclude the year part.
    Can anyone tell me the formula or best way to do this?
    Thanks in advance.
    Edited by: BadBoy House on May 25, 2010 3:15 PM
    Edited by: BadBoy House on May 25, 2010 3:15 PM

    Hi
    You can try this
    datevar e := date(year(currentdate),month({tblClient.YearEnd}),day({tblClient.YearEnd}));
    numbervar num_days := datediff("d",currentdate,e)
    Create a datevar called e that uses the original month and day numbers for {tblClient.YearEnd} but uses the year of the current date
    Then just datediff on e to get the number of days between the two dates
    I hope i understand your problem and that this helps
    Best regards
    Patrick

  • How to calcuate the number of days

    Hi Friends,
    can some one help me out .. how to dispaly the number of days depending upon the from and to date selected by the user.
    eg :-
    there is one self service form.. in which three fields are there, they are 1) From date
    2) To date
    3) No of days
    now my requirement is, user selects from date and to date and i need to calculate the number of days he is selected and display in No of days field. can some one help me out logic for this.
    how to retrive from date and to date dynamically to my function.
    apart from writing function .. can we use $FLEX$ becoz two dates are valuesets.
    seeking for a solution,
    thanks in advance

    This doesn't sound like something that will be easy to do.
    A few questions:
    1) What flexfield are you referring to?
    2) What Self Service page?
    3) Can the 'No of days' ALWAYS be calculated? Or do you just want to default it so the user can modify it?

  • How to set the number of rows per page dynamically

    Hello all,
    i urgent need the option to set the number of rows per page dynamically.
    I've got a parameter.
    In dependence of the value of this paramter i want to set the number of rows per page of a repeating frame.
    The Reports Builder version i use is 10.1.2.0.2
    I defined a report trigger.
    My code so far:
    function R_G_BEMERKUNGFormatTrigger return boolean is
    begin
    if :vYN_Display_one_per_page = 'Y' then
    --what i've to write right here??
    return (TRUE);
    else
         return (TRUE);
    end if;
    return (TRUE);
    end;
    Can anyone help me please??
    Best regards
    Florian

    Do you just need to change back and forth between 1 and some other number? If so, you can create two identical layouts, one with the "number of rows per page" preperty (on the repeating frame) set to 1 and the other layout set to whatever. You would have to have duplicate layouts for each group you wanted to do this with. Your format trigger on the outermost master group frame where num of rows was 1 would look like:
    function M_G_ename_GRPFRFormatTrigger return boolean is
    begin
      if :vYN_Display_one_per_page = 'Y'  then
        return (TRUE);
      else
        return (FALSE);
      end if;
    end;Your format trigger on the outermost master group frame where num of rows was whatever would look like:
    function M_G_ename_GRPFR1FormatTrigger return boolean is
    begin
      if :vYN_Display_one_per_page = 'N'  then
        return (TRUE);
      else
        return (FALSE);
      end if;
      return (TRUE);
    end;

  • Determine the number of days in a False period in a Temporal Boolean

    Hi all,
    I need to determiine the number of days based on a condition that lies on the gaps between the periods.
    My input consists of multiple periods. The length of the gap is the condition to determine the start date for summation. However, there can be multimple gaps between my instances that satisfy this condition and I need the last one that satisfies it.
    For example:
    period 1: 1-1-1990 until 31-12-1992
    period 2: 1-1-1994 until 31-12-1996
    period 3: 1-1-1998 until 31-12-1999
    period 4: 1-6-2000 until 31-12-2009
    The condition for the start date is the last gap greater than 1 year. In this example, the start date should be the start date of period 3: 1-1-1998, because this is the period after the last gap >= 1 year. Period 2 also has a previous gap of >= 1 year, but this period should NOT be selected.
    My first idea was to use a TBR function: to determine relevant periods (based on the gaps before and after), calculate the amount of days per relevant period and add those up. However, if I want to do that I need to calculate the number of days in the gaps and I don't see how to do that, since I cannot determine a day difference across periods (end date period 1 until start date period 2).
    Any help/ other solution ideas?
    Kind regards, Els

    This was an interesting puzzle which you can solve from a couple of different angles.
    Firstly, you can use inferred relationships to infer a relationship "the following periods" (ie. the periods that follow the current one). My rules looked like this:
    the period (the other period) is a member of the following periods if
       the other period start date > the period start date
    the period’s next start date = InstanceMinimum(the following periods, the period start date)From here it should be easy to see if there was a gap of more than a year, and find the most recent period after a year-long gap. Of course you need to deal with the situation of the last period, when there is no 'next' period, presumably you would use the date of assessment in that case, but I'll leave that as an exercise for the reader.
    A completely different way of doing it is to use the TemporalConsecutiveDays function to find a date where a gap of 365 days exists, then select periods in which there is a gap immediately before the start of that period. Here are some rules that :
    there is a period that applies if
       ExistsScope(the periods)
          TemporalOnOrAfter(the period start date) and
          TemporalOnOrBefore(the period end date)
    there is a year-long gap if
       TemporalConsecutiveDays(365, 365, there is not a period that applies)
    the period starts after a year-long gap if
       ValueAt(the period start date, there is a year-long gap)
    the start date for calculation = InstanceMaximumIf(the periods, the period start date, the period starts after a year-long gap)Hopefully one of these is suitable for your needs.
    cheers,
    Steve.

  • How to calculate the number of vowels from a txt file. Pls give me a hand!!

    Guys! How do i calculate the number of vowels from a txt file? I have to create a program to count the number of words, sentence, and vowels. So far I had managed to count the number of words. Now I need help on counting sentence and vowels! Pls give me a hand guys!

    I first have to read from the file not the string.I
    know how to read from a file. Now the problem ishow
    to compare a character from a txt file!You fail to understand, that you have read the data
    from the file into a string. Now loop over all
    characters in the string. Forget about the file.
    KajOr forget the scanners just as others have told you. Just read the file character by character using a FileReader.
    Kaj

  • How to calculate the number of sent/received emails of a certain domain

    Thank you for what you have helped me with!
    How to calculate the number of sent/received emails of a certain domain in a certain period? It is Messaging Server 5.2, Directory Server 4.2. Is there a log option for this?
    Thank you.

    Not sure where you find, "LOG_MESSSAGE_ADD". I don't actually find this option in the documentation.
    The domains that mails are coming from and being sent to are certainly logged in the normal mail.log, so why mess with additional logging options? If you're talking about "LOG_CONNECTION", I actually see no additional data that is useful to you.
    If you decide to change the option.dat, you do indeed need to
    imsimta cnbuild (note, it's not cnrebuild)
    imsimta restart
    If I were facing the same issue, I'd be looking at the log parsing perl script, and simply modifying it to do what I wanted.

Maybe you are looking for

  • Where can i find the easy cap application for my macbook pro

    i need to connect my xbox 360 to my macbook pro i was told to buy the easy cap cord and plug it into my mac and then i have to download the app which i couldn't find at all i found one but after i downloaded it it didn't let me open it it says that t

  • Why won't YouTube play on my new Macbook Air?

    I recently just purchased a brand new Macbook Air for work. 4th Gen. It's awesome. However, I also recently discovered that almost no videos will play from YouTube. I'm using Safari. After finding this out, I went through all the troubleshooting step

  • Cannot fix error in Tomcat 5

    When I run my program at school using Tomcat 4 it works fine and everything runs properly. However, when I run that same program at home in Tomcat 5 i get an error that i don't know how to fix. I've tried everything and nothing works. Everything is e

  • Pl/sql questions

    can anyone provide me exact answers for the questions below.....I urgently require them 4 my exams.....my email is [email protected] ques1 what is Index organized tables ? ques2 what are enforced & deferred Constraints? ques3 what are SQL*plus develo

  • A tiny dead pixel on my ipad mini what should I do?

    A dead pixel on my ipad mini .which is in warranty . I went to the shop but they refused to replace it . Any other solution ?