Function module to determine the date for the nth weekday of the mth month

Hey folks,
Is there a function module which determines the date for the mth weekday of the nth month in the pth year.
For instance, if I input 2nd thursday of the 4th month in 2008, it should return me, 04/10/2008  (MM/DD/YYYY).
Thanks and Best Regards,
Puja.

Hi Ravi,
Hadn't been able to work on this lately...You solution was quite close, but did not work for a few scenarios....I tweaked the logic a bit to take care of them as well...
So here goes the code:
================================================
  DATA first_day_of_month TYPE datum.
  DATA day TYPE p.
  CONCATENATE year month '01' INTO first_day_of_month.
  CALL FUNCTION 'DAY_IN_WEEK'
    EXPORTING
      datum = first_day_of_month
    IMPORTING
      wotnr = day.
  DATA day_number TYPE numc2.
  IF day = weekday.
    IF recur = 1.
      DATA ls_date(10) TYPE c.
      CONCATENATE month '/01/' year INTO ls_date.
      CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
        EXPORTING
          date_external                  = ls_date
       IMPORTING
         date_internal                  = date.
    ELSE.
      day_number =  ( ( recur - 1 ) * 7 )  + 1.
    ENDIF.
  ELSEIF day < weekday.
    day_number = ( ( recur - 1 ) * 7 ) + ( weekday - day ) + 1.
  ELSE.
    day_number = ( ( recur - 1 ) * 7 ) + ( 7 - day ) + weekday + 1.
  ENDIF.
  IF date IS INITIAL.
    CONCATENATE year month day_number INTO date.
  ENDIF.
====================================
There still could be some loopholes in this....am not sure....but it sure did seem to work for a couple of random checks that I performed.
Brownie points to you for giving me a direction.
Thanks,
Puja.

Similar Messages

  • Function Module to determine due date in BI form Payment Terms

    Hi to all,
    Can any one tell me what is the Function Module to determine due date in BI, form ZTERM ( Payment Terms ).
    I am working on Accounts Receivable (AR). and need to calculate Due date.
    I shall be thankful to you for this.
    Regards
    Pavneet Rana

    Thanks For reply,
    I have to do aging for Receivables and report format is like that.
                    1 - 10      11 - 30        31 - 60         61 - 90       > 90     Notoverdue   Overdue
    North
    East
    south
    West
    According to client requirement in first 5 bucket i need to display Receivables according to aging
    and for  Notoverdue   Overdue  bucket condition is like that.
    if sy-datum - vbrk-fkdat  > 0NETDUEDATE then it is under Overdue bucket
    if sy-datum - vbrk-fkdat  < 0NETDUEDATE then it is under notOverdue bucket
    there i have created 2 DSO , one for sales which have North,East,south,West and vbrk-fkdat using 2LIS_13_VDHDR,2LIS_13_VDITM
    and other  DSO which will have 0NETDUEDATE from 0FI_AR_4 .
    for Notoverdue   Overdue how i will calculate aging at query level.
    also is 0p_keydt is variable for 0CALDAY which will take user entery and should i applied offcet, to get firts 5 bucket Receivables data for aging.
    i shall be thankful to you for this.
    Regards
    Pavneet Rana

  • Function Module Error In Uploading Data for Basic Pay Infotype

    Hi All,
    I'm trying to upload data into Basic Pay Infotype 0008 Using LSMW Subtype 0(Basic Contract). While we are trying to input values into ANSAL(Annual Salary) field directly using default wage type as 1000.
    We are gettting a error in function module RP_ANSAL_FROM_WAGETYPES.
    and eventhough we are inputting values into ANSAL field it is taking it as 0.00 by default .
    Kidly suggest me solution.
    Thanks,
    Vasanth

    Hi ..
    check this
    765785
    673372
    730976
    note 1032950
    http://help.sap.com/saphelp_nw2004s/helpdata/en/8d/3e4ec2462a11d189000000e8323d3a/content.htm
    Message was edited by:
            hari kv

  • Function module  to determine the credit balance or if there is an open ite

    Hi All ,
    Can anyone please let me is there any function module  to determine the credit balance orr if there is an open standing request / open standing request /paid but not yet refunded security deposit .
    Requirement :
    Purpose -This report shows a list of u201Cinactiveu201D contract accounts and the amounts to be refunded (credit balance, paid security deposit) to customers.  This report also shows any open standing requests in customersu2019 contract accounts.
    Note:  SAP does not have a concept of u201Cinactiveu201D contract accounts.  All contract accounts are active in SAP.   
    We do have customers who pay several months in advance (when they are out of town and donu2019t want to have their services disconnected). 
    Logic to retrieve the u201Cinactiveu201D accounts:
    The inactive accounts can be identified by the Move-In/Out dunning procedure. If the mov-in/out dunning procedure is not empty, that means this account has moved out and the account is inactive.
    Business Logic and Flow
    For each contract account
    Go through each installation and check if it is disconnected
         If (one is active)
    move to the next contract account
    else (all is disconnected)
         check to see if there is a credit balance or if there is an open standing request
         If (credit balance)
    {Display contract account, customer number and information, and credit balance for refund}
    If (open standing request)
    {Display contract account, customer number and information, standing request number to be closed}
    If (paid but not yet refunded security deposit)
    {Display contract account, customer number and information, current balance and security deposit amount}
    Thanks in advance
    Rahul

    Hi Rahul,
    To find out the credit balance relating to security deposits you can use BAPI_ACCOUNT_GETBALANCES. On execution of this BAPI with BP and Contract Account Number, it will return the net balance with different segments like open, due, credit and likewise security deposit amount.
    To find out if there is any open standing request standing against the customer you can use BAPI_CTRACCONTRACTACCOUNT_GOI. You have to execute this BAPI by providing BP or Contract Account number in Main Selections  table and Main and Sub Transaction of Security Deposit Request transaction in Value Selection table. This BAPI will fetch all open items with the main and sub transactions specified and display.
    Thanks
    Ganesh

  • Function Module to determine the number of pages in a pdf file

    Hi All,
    Is there any standard function module to determine the number of pages in a pdf file?
    Thanks,
    Sai

    Hi unk2,
    There's no functionality in the Acrobat.com online services to do a character count. But, you could use ExportPDF to convert your PDF file to Word format, and then do your character count in Word.
    Please let us know if you need additional assistance.
    Best,
    Sara

  • Function module WWW_ALV_CALL is not released for the Internet

    Hi
    I am facing this error Function module WWW_ALV_CALL is not released for the Internet and Only user SAP can release the function module.
    Best Regards
    GAGAN

    hi,
    This Web based calls are not available anymore in Netweaver 2004s/7.0. 
    More information in SAP-Note: 910202
    Hope this helps
    regards
    Tobias

  • Unable to see the data for the hierarchy in rsa3

    Hi Gurus,
    i am trying to check the data for the standard hierarchy in rsa3,but it is showing an  error message saying that error 6 in functional module rss_program_generate.Please help me out.
    thanks
    bhaskar

    Check if this helps seemed relevant
    Error 6 in function module RSS_PROGRAM_GENERATE
    Error 6 in function module RSS_PROGRAM_GENERATE
    error Error 6 in function module RSS_PROGRAM_GENERATE

  • Tables or fm to fetch the data for idoc type WMMBID01

    hi
    i have to create function module in whish i have to fill segments of  idoc type
    WMMBID01.
    is there any fm which can fetch the data for the required fields of segment based on the document no.
    or which tables i can use to fetch the required data for goods issued ie transaction migo.
    regards
    vijay

    HI
    GOOD
    TRY WITH THESE FM
    DYNP_VALUES_READ Read the values from a dynpro. This function can be used to read the values from a report's selection screen too (Another example).
    HELP_START Display help for a field. Useful for doing AT SELECTION SCREEN ON VALUE REQUEST for those fields that do not provide F4 help at the DDIC level.
    RPY_DYNPRO_READ Read dynpro, including screen flow
    RPY_TRANSACTION_READ Given a transaction, return the program and screen or given a program and screen, return the transactions that use the program and screen.
    THANKS
    MRUTYUN

  • Getting the data for last month of every year

    Hi,
           How to declare the date if we want to pull the data from the December of every year.
    For example if the query is run in march 2015 and they want the historical data it should pull only the data from dec 2014.
    In the same way if they ran the query in future jun 2016 and if they want to historical data it should pull only data from dec 2015.
    It should not coded manually. Please help me with date format that need to used.
    BALUSUSRIHARSHA

    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
    to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for: 
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    A table has to have a key to be table.  Here is my guess at a repair job: 
    CREATE TABLE Test_Data
    (pu_id INTEGER NOT NULL
      REFERENCES PU(pu_id),
     pu_date DATE DEFAULT CURRENT_TIMESTAMP NOT NULL,
     PRIMARY KEY (pu_id, pu_date),
     x_count INTEGER,
     y_count INTEGER);
    Identifiers are not numeric in a good schema. What math do you do with them? They are also the key in the table that models the entity they identify. Where is the PU table (and what is a PU anyway)? 
    INSERT INTO Test_Data
    VALUES
    (28, '2014-01-01', 10, 20), -- crap! No key in this mess!! 
    (28, '2015-01-01', 30, 20), -- 
    (28, '2014-12-12', 10, 20), 
    (28, '2015-02-02', 10, 20);
    A PIVOT is not a query and not even part of SQL. It is how Microsoft programmers who do not know RDBMS or have a report writer violate the tiered architecture of SQL. We also do not use XML mixed in SQL. It is a bitch to maintain, has poor performance and again
    violates the tiered architecture principle. 
    A query is not sorted because it is a table. A file in COBOL can be sorted and that seems to be what you really want to write. 
    Old COBOL love the Sybase CONVERT() string function to avoid SQL temporal data. 
    We never use SELECT * in production code; Google it. Not only are you generating code, you are generation bad code. 
    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 Month_Periods
    (month_name CHAR(10) NOT NULL PRIMARY KEY
       CHECK (month_name LIKE <pattern>),
     month_start_date DATE NOT NULL,
     month_end_date DATE NOT NULL,
      CONSTRAINT date_ordering
        CHECK (month_start_date <= month_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'
    This will port and waste time calling string function row by row. 
    --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

  • Problem while refreshing the data for the second time using excel services in sharepoint 2013...

    Hi,
    I have migrated my Sharepoint from 2010 to 2013.I am able to get the data at the first time of refresh when I click on refresh for the second time I am getting the empty the sheet.
    below find the flow of refresh
    First Refresh
    On Click of refresh open the workbook with excel services and return the session id.
    Using that session I am invoking RefrehAsync method of excel services
    After refresh completed I am setting the calculation of workbook as automatic(to calculate the formulas) using the same session id
    After setting the calculation as Automatic I am setting the calculation type as full(recalculate) using the same session id.
    Now I am able to see the data
    Second Refresh
    After clicking on refresh instead of opening the workbook I am using the session id(already opened workbook) and setting the calculation type as manual
    I am following the same process from refresh(RefreshAsync) as I have followed in first refresh.
    This time my formulas are not getting calculated because of that I am not able to see the data.
    Could you please let me know that am I missing anything here?
    Is this know issue in Sharepoint2013 excel services as same code is working fine with Sharepoint2010.
    If I close the workbook(session id null) and opens(new session id) for all the refreshes it is working and I am able to see the data.
    Thanks,
    Meenakshi Nagpal
    N.Meenakshi

    I am able to see the data for the second refresh  if I change the data source.If I use the same data source which is used in the first refresh I am not getting the data.Excel services will contact the cubes and calculate the formulas in my workbook.
    Could you please let me know what could be the problem at second refresh while contacting the same data source with same session id?
    Please help me asap.
    Thanks,
    Meenakshi Nagpal
    N.Meenakshi

  • How to get the date for the first monday of each month

    Dear Members,
    How to get the date for the first monday of each month.
    I have written the following code
    SELECT decode (to_char(trunc(sysdate+30 ,'MM'),'DAY'),'MONDAY ',trunc(sysdate+30 ,'MM'),NEXT_DAY(trunc(sysdate+30 ,'MM'), 'MON')) FROM DUAL
    But it look bith complex.
    Abhishek
    Edited by: 9999999 on Mar 8, 2013 4:30 AM

    Use IW format - it will make solution NLS independent. And all you need is truncate 7<sup>th</sup> day of each month using IW:
    select  sysdate current_date,
            trunc(trunc(sysdate,'mm') + 6,'iw') first_monday_the_month
      from  dual
    CURRENT_D FIRST_MON
    08-MAR-13 04-MAR-13
    SQL> Below is list of first monday of the month for this year:
    with t as(
              select  add_months(date '2013-1-1',level-1) dt
                from  dual
                connect by level <= 12
    select  dt first_of_the_month,
            trunc(dt + 6,'iw') first_monday_the_month
      from  t
    FIRST_OF_ FIRST_MON
    01-JAN-13 07-JAN-13
    01-FEB-13 04-FEB-13
    01-MAR-13 04-MAR-13
    01-APR-13 01-APR-13
    01-MAY-13 06-MAY-13
    01-JUN-13 03-JUN-13
    01-JUL-13 01-JUL-13
    01-AUG-13 05-AUG-13
    01-SEP-13 02-SEP-13
    01-OCT-13 07-OCT-13
    01-NOV-13 04-NOV-13
    FIRST_OF_ FIRST_MON
    01-DEC-13 02-DEC-13
    12 rows selected.
    SQL> SY.

  • How to set the filter on a report to show the data for the Current Month

    Hi all,
    I am working on a report, which currently has this filter: Date First Worked is greater than or equal to 10/01/2010. This reports show the data for the current month, so at the beginning of each month we have to remember to change the date on the filter.
    Does anyone know what the criteria should say, so that it automatically changes and shows the information for the current month, without us having to go in and change anything?
    Any help would be greatly appreciated!
    Thanks,
    AA

    You need to add a session variable to date fir worked assuming that this is a date field.
    To do this open up the filter on the field then at then press add Variable then "session" and enter the following CURRENT_MONTH into the Server Variable section.

  • I just bought a brand new iPhone 4s from a Three store. When I used the cloud restore to put the data from my old 3gs onto the device, it's prompting me for an Apple ID login with an email address that isn't mine!

    I just got a brand new iPhone 4S on a contract from my local Three store. When I used the cloud restore to put the data from my old 3GS onto the device, it's prompting me for an Apple ID login with an email address (hotmail) that isn't mine! My old phone has NEVER had any Apple ID other than mine log into it, and the new one's a sealed box that I've opened and set up from scratch. Can anyone please explain this? I'm worried there's some kind of problem with my iCloud data being mixed with someone else's or something... Since I logged in with my own ID, it's downloaded the data perfectly fine, but I just got the Apple ID prompt again a moment ago with this same hotmail address in it... I'd be very grateful for any explanation!

    In iTunes on your computer, select the Purchased section under STORE in the left column. Click on the first track and choose "Get Info" from the "File" menu.
    In the "Summary" tab you'll see details of the purchaser of the track. Click Next to go through all your purchased music one by one until you find the ones you need to get rid of.
    Unfortunately, there are no smart playlist rules that can filter tracks by the purchaser that I know of.

  • How do I perform a trigger that collect the data for every rising edge continuously and then automatically put the data in a .xls file??

    I need to collect the data for every rising edge a trigger perfoms. So far I could collect the data but it seems that it only collect the data in the start of triggering, but not continuously. I also want to put the data in an excel spreadsheet and automatically add new set of data when the next rising edge occur. Please help.
    thanks a lot.

    LabWindows/CVI actually ships with a comprehensive set of examples for just about every area of programming you can use it in, including triggered analog data acquisition and ActiveX control of Microsoft Excel for data logging. Go to the following two directories on your computer to find respective examples for the two areas you are inquiring about:
    1) C:\MeasurementStudio\CVI\samples\DAQ\Ai\DAQsingleBufExtTrig.PRJ
    2) C:\MeasurementStudio\CVI\samples\activex\excel\excel2000dem.prj
    Just make sure to study the examples carefully so that you fully understand the processes followed for triggered analog acquisition and the process of launching an ActiveX automation server for control, and then you should be able to merge the concepts shown in both of the example
    s to make the application you desire.
    Jason F.
    Applications Engineer
    National Instruments
    www.ni.com/ask

  • How to populate the data for additional fields in custom report of fbl5n tr

    hallo friends,
    i ha ve to add some fields to the output of custome report of transaction FBL5N.
    Till now i have only added the fields to the output.
    Now i have to write the code to populate the data for those fields in the program.
    1.     Customer Credit Group(ACM/RCM): (Table: KNKK; Field Name: VKORG )
    2.     Credit Representative Group: (Table: KNKK; Field Name: SBGRP)
    3.     Customer Account Number(CAN#): (Table: KNKK; Field Name: KNKLI)
    4.     Alternative Payer(ALTP#) : (Table: KNA1; Field Name: KUNNR)
    5.     Risk Category: (Table: KNKK; Field Name: CTLPC)
    6.     Credit Info Number: (Table: KNKK; Field Name: KRAUS)
    7.     Rating: (Table: KNKK; Field Name: DBRTG)
    8.     Payment Index: (Table: KNKK; Field Name: DBPAY)
    9.     Credit control area: (Table: KNKK; Field Name: KKBER)
    10.     Company code: (Table: KNB1; Field Name: BUKRS)
    11.     Sales Organization: (Table: KNVV; Field Name: VKORG)
    These are al fields i have to populate in the program..
    MY ATTEMPTS:
    I tried getting the data for KNKK table by GET KNKK ,but it is giving some garbage values...
    And Logical database used here is DDF,and i have to add the VKORG of KNVV too...but KNVV is not there in DDF...
    Can anybody tell me how should i proceed..
    thanks in advance.

    Thnx Andreas,
    i have following doubts again..
    I have to add sales organisation field to the selection screen...(this is given in the req.)
    now if i will say GET KNKK...it would not keep account of this 'sales organisation' field...so how should i fetch the data with these input data( i.e. 'compny code' and 'customer' are the fields given by LDB and 'sales oraganisation' is the field i put it on the selection screen)
    And what about the KNVV-VKORG ,because the KNVV is not present in the LDB.

Maybe you are looking for