Posting date calculation

If a transaction attempts to post in SAP on the Wed. through Sat. of a financial period close, the SAP posting date should be set to the first day of the next financial period
pl. provide details of teh FM that can be used to solve the above mentioned scnerio.
I only have SY_DATUM as input.

Try this code. There is no easy way to do this. Let me know if my understanding is wrong.
Please close the thread if answered.
REPORT zreport NO STANDARD PAGE HEADING MESSAGE-ID zfi
                                        LINE-COUNT 65
                                        LINE-SIZE 120.
DATA: v_poper                      LIKE t009b-poper,
      v_bdatj                      LIKE t009b-bdatj,
      v_next_poper                 LIKE t009b-poper,
      v_next_bdatj                 LIKE t009b-bdatj,
      v_first_day_of_next_period   LIKE sy-datum,
      v_last_day_of_current_period LIKE sy-datum,
      v_monday                     LIKE sy-datum,
      v_tuesday                    LIKE sy-datum,
      v_sunday                     LIKE sy-datum,
      v_wotnr                      TYPE p,
      v_posting_date               LIKE sy-datum.
PARAMETERS: p_date  LIKE sy-datum DEFAULT sy-datum,
            p_periv LIKE t009b-periv.
START-OF-SELECTION.
*-- get the current date's period and year
  CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
       EXPORTING
            i_date               = p_date
*           I_MONMIT             = 00
            i_periv              = p_periv
       IMPORTING
            e_buper              = v_poper
            e_gjahr              = v_bdatj
       EXCEPTIONS
            input_false          = 1
            t009_notfound        = 2
            t009b_notfound       = 3
            OTHERS               = 4.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
*-- get the last day in the current period
  CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
       EXPORTING
            i_gjahr        = v_bdatj
            i_monmit       = '00'
            i_periv        = p_periv
            i_poper        = v_poper
       IMPORTING
            e_date         = v_last_day_of_current_period
       EXCEPTIONS
            input_false    = 1
            t009_notfound  = 2
            t009b_notfound = 3
            OTHERS         = 4.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
*-- Get week info of the last day of the current period
  CALL FUNCTION 'GET_WEEK_INFO_BASED_ON_DATE'
       EXPORTING
            date   = v_last_day_of_current_period
       IMPORTING
*           week   =
            monday = v_monday       " First day of period closing week
            sunday = v_sunday.      " Last day of period closing week
  v_tuesday = v_monday + 1.
  IF p_date <= v_tuesday.
*-- entered date is before or equal to the tuesday of the week of
*   current period's last date, allow posting to the current period
    v_posting_date = p_date.
  ELSE.
*-- get the next period
    CALL FUNCTION 'CKML_F_GET_NEXT_PERIOD'
         EXPORTING
              input_period = v_poper
              input_year   = v_bdatj
              input_periv  = p_periv
         IMPORTING
              next_period  = v_next_poper
              next_year    = v_next_bdatj.
*-- get the first day in next period get
    CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'
         EXPORTING
              i_gjahr        = v_next_bdatj
              i_monmit       = '00'
              i_periv        = p_periv
              i_poper        = v_next_poper
         IMPORTING
              e_date         = v_first_day_of_next_period
         EXCEPTIONS
              input_false    = 1
              t009_notfound  = 2
              t009b_notfound = 3
              OTHERS         = 4.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    v_posting_date = v_first_day_of_next_period.
  ENDIF.
  WRITE:/ v_posting_date.

Similar Messages

  • Interest Calculation on posting date and due date

    Hi
    I want vendor interest calculation on due date as well as posting date. Let me know how to get it. According to me only its possible on the basis of one date only.

    HEllo!
    In the report RFINTITAR, you use the interest indicator customizing:                                                                               
    IMG   > Prepare Item Interest Calculation   > Ref. Date                                                                               
    (table V_T056UX)   >  field Ref.                                                                               
    (FI Item Interest Calculation: Reference Date)                                                                               
    You have the possibility to define what You need to be considered as 
    incoming payment due date, choosing between:                                                                               
    1 Value Date (or Baseline Date for Net Payment)                      
    2 Document Date                                                      
    3 Posting Date                                                       
    4 Payment Baseline Date                                                                               
    As you can use one interest indicator per customer/vendor you can use only of the dates is used. But, in this
    program you can use the BADI FI_INT_CUS01. Please, check if you can meet your business requirements using the methods
    of the BADI.
    REgards,
    REnan

  • Calculation of unrestricted stock on posting date

    Hello,
    In a certain report that we developed for our customer one of the data
    Is "unrestricted stock on posting date".
    Is there a function that calculate this data, and if not what is the best way to do it?
    Thank you in advance,
    Haim Gimelfarb

    Thank you,
    But this is not the answer that I looked for.
    Mb5b is a transaction, and I need a function that can Calculate unrestricted stock on posting date.
    Becaus the stock in posting date is only part of the information in the report.
    Thank you in advance
    Haim Gimelfarb

  • Restrict goods issue if stock on posting date is zero

    Requirement:
    Current Inventory period : July 2011
    Stock of a material from 01.07.2011 to 30.07.2011 is zero(in MB5B report)
    I upload stock of material  or GRN occur on 31.07.2011. Say Quantity u2013 100
    Now stock as on 31.07.2011 is 100 in MB5B
    Still, Stock of a material from 01.07.2011 to 30.07.2011 is zero(in MB5B)
    Now, If I do goods issue of a material quantity 100 on 15.07.2011. System allows goods issue. though opening and closing stock as on 15.07.2011 is zero.
    After goods issue transaction if I check stock of material on any date between 16.07.2011 to 30.07.2011 , The opening stock and closing stock shows negative.
    I want to restrict goods issue if stock on posting date is zero or less then stock available on posting date.
    Please suggest

    Hi,
    This is not the way SAP is designed. As the previous speakers wrote (and as you noticed yourself), SAP maintains stock figures in the database per month rather than per day. MB5B makes complex calculations in order to find out how much stock you had on a specific date - as you probably noticed on the response time. Performing such calculations every time you do a GI would be unfeasibly heavy task for the system - remember there are organisations that perform hundreds of inventory movements a minute!
    An alternative solution I suppose would be to maintain the daily stock figures in the database. This would make the finding of the stock figure very quick, but on the other hand, the maintenance of such table would be unfeasible - if you post today a GI on say July 1st, you would need to calculate 36 stock figures and update 36 database records!
    Hope this explains the technical issue.
    BR
    Raf

  • Month Year values based on Posting Date

    In my super huge extra large InfoCube (0CFM_C10) I got a lot of data. I take Posting Date, some KFG and CalMonth/Year. Unfortinally CalMonth/Year duplicates records, if I drop it off the columns/rows I get valid data by Posting Date.
    My question is this - is it possible to create some MonthYear Calculated KFG/field/formula or smthng. based on Posting Date? In other words I need Month/Year in rows/ columns or free characteristics...
    Edited by: Gediminas Berzanskis on Mar 18, 2008 10:18 AM

    Dear,
    When canceling a payment which was created in previous posting periods,
    we  get system message "Date deviates from permissible range",so
    the workaround is changing back the posting period to the previous one
    and try to cancel the payment.
    However,another system message pops up when we try to cancel payment
    after changing back the posting period,which is the "creation date" or
    "posting date".
    In this scenario, you should select the second option from the
    cancellation options window, which is the 'Creation date'. I would like
    to explain more below.
    Posting Date- means the posting date of the cancellation document, it's
    not the posting date of the incoming payment that you wanna perform the
    cancellation. In your case, selecting this 'posting date' option, system
    deems that you want to post this cancellation document on its own
    posting date.
    Creating Date- means the posting date/creation date of the incoming
    payment, it makes sense that the system works fine if you select this
    option. If you cancel the incoming payment and check the JE generated,
    you will find that the posting date of this cancellation document is
    actually recorded as the posting date of the incoming payment.
    Wish it helps you.If you have any problems,please kindly let me know.
    Thanks and best regards,
    Apple

  • VAT should post based on PO date or GR date not based on MIRO posting date

    Hi,
    Based on posting date in Invoice(MIRO) & condition record validity period, VAT is calculated & posting on invoice posting.
    Condition record for VAT condition type with tax code(T9):
    01.01.2011 to 31.01.2011-------> 4%
    01.02.2011 to 28.02.2011------->12%
    01.03.2011 to 31.03.2011------->14.5%
    PO created and GR done on February & invoive done on March and syatem calculated VAT amount perfactly based on validity period maintained in condition recod and invoice posted.
    But requirement is  system should post invoice VAT amount as mentioned in the PO ( based on PO date) or GR date to post during Invoice posting in MIRO
    Regards,
    Biju K

    Hi,
    Any other input?
    Regards,
    Biju K

  • Issue with the Posting Date of the Purchase Order.

    Hi All,
    There are fields in BW like SSL1: Time OK, SSL2: Qty OK, SSL3: Time & Qty Ok, SSL4: Days Late (Routines are written to calculate). These fields will indicate whether the delivery against a GR is OK or not with respect to Time, Quantity and the No. of Days..
    But here the issue I am facing is
    If there is only1 delivery/ GR against a single item the calculation in BW are correct - i.e. for a particular PO if there is only one delivery the above fields like SSL1: Time Ok, SSL2: Qty OK will show like the delivery is done within the specified time and everything is OK (in case if it is delivered within the allotted time)
    But if there are multiple deliveries or multiple GR's  posted for one PO item, the calculations are going wrong i.e. even if the delivery is done well within the specified time it is showing the wrong calculations like it is delievered too late. Because in this case the earlier dates are overwritten.
    Can anyone throw me some light on how can I go about solving this issue.
    I am thinking of declaring the Posting Date as the KeyField of the DSO as of now it is a Data field  I also want to know the impact of assigning this as a Keyfield.
    Thanks in advance,
    Prasapbi

    Hi,
    As I understand, you have a DSO based on Purchase Order and your key field is PO and its line item. The problem as you stated will always be there if you have multiple deliveries/GRs created for a single line item because the system will overwrite the entries for same key.
    Problem with adding Posting date as keyfield will be that then your key will be PO-PO Lineitem-Date. When PO will be created, the Posting date will be blank(correct me here if I am wrong), therefore you will have one entry for same PO-line item combination. One without date and other with date, which again would be incorrect. If my assumption about Posting date was wrong, even then your data may not be correct because then you may have many entries with same posting date which again would overwrite each other.
    If there is any direct link between PO line item and number of deliveries that will get created for them, then you can bring that field in DSO as keyfield. But I don't think there is any such field.
    Looking at your report requirement, I would suggest that you make a DSO based on Goods Receipts and then calculate these keyfigures by comparing the dates between GR posting date and PO line item date.
    Else you can change the way your datasource works(if its generic one based on function module). Since your main requirement is to check whether the GR posting date has met your SLA or not, you should fetch all the details only when GR is created and make your key field as PO-PO Line item-GR

  • Exchange rate coefficient on the basis of latest posting date in invoice.

    Hi,
    I have one query on posting date(picking of exchange rate coefficient from TCURR table) in invoice verification.  Please help.
    Conditions are--
    vender and company code are not in same currencies(ex-USD and INR). exchange currencies are maintained perfectly on every month 1st ie co-efficients in TCURR table ie OB08
    Query---
    1.At the time of parking invoice suppose i enter the date 20th august and i have posted that invoice as parking. It is converting the local currency as per 8th month exchange rate.
    2.And at the time of final posting the invoice supose i posted that date as 10th September. Business wanted that converting the local currency as per 9th month exchange rate But now local currency is converting on the basis of initial entry of posting date ie 8th month only.
    Please advise and guide what configeration that i have to set for picking the exchange rate coefficient on the basis of latest posting date in invoice verification.
    Thanks & Regards,
    MadhuBabu.

    Hi
    I dont think it is possible as once you enter posting date while in parking invoice screen, on that date exchange rate will be calculated and it wil not be different at time of posting invoice. Instead of parking, you have to directly post with current posting period.
    Thanks

  • FA-retirement-Asset value date and posting date are not in same fisc year

    Hello,
    I would like to post retirement in the new fiscal year but with asset value date in the previous year so that NBV is calculated correctly. It is not possible neither in ABAON nor in ABAVN with any transaction type.
    I always get message 'Asset value date and posting date are not in same fiscal year'.
    Is there any way how to handle this?
    Thank you,
    Jan

    Hi,
    I have tried this but the settings of our Depr keys works in the way. That if you use asset value date in the new month it will calculate depreciation for the whole month.
    This means if I retire with asset value date 31.12.2008 - NBV will be calculated as at 31.12.2008.
    If I retire with asset value date 1.1.2008 - NBV will be calculated as at 31.1.2009.
    Thank you anyway!

  • Recurring document - FBD1 with incorrect due-date calculation for AP

    Hi Gurus,
    in our ECC 6.0 system we are creating with F.14 FI-documents (SAPF120) based on recurring documents (created with FBD1) for various purposes (e.g. Recurring entries for IC-business).
    Therefore it's important that the system provides in the final processing of the recurring documents the correct net-due-date in the AP-document based on the document date and the payment term included in the AP-masterdata (LFB1-ZTERM).
    Problem:
    The processed FI-document contains the correct payment term but the calculated net-due-date with regards to the document date (BKPF-BLDAT) isn't correct. A Dummy-Update of the FI-document with FB02 on field BSEG-ZTERM provides finally the correct net due date but this a not recommended solution.
    Any ideas how to solve that issue???
    Thanks for replies.
    BR, Bernd

    Hi Vishnu,
    the defined payment term is
    fix day: 15
    additional month: 1.
    Default for baseline date is posting date
    Therefore the expectation is that net due date is calculated for posting date
    e.g. : 01.02.2012 to 15.03.2012.
    The line item after processing in FI-document shows :
    Posting Date : 01.02.2012
    Bline Date:   01.02.2012
    Days/percent: 35
    Net due date: 07.03.2012 (dd.mm.yyyy)
    That's wrong according to my understanding of the payment term definition.
    BR, Bernd

  • Show SQL issue on Posting Date and Aging Date

    Hi Folks,
    When I am running a report >>> the report pops up with the some parmeters >>
    In my scenario u201CAging Dateu201D forumla is calculated as the last day of the every month.
    if month (currentdate) = 1 then date((year(CurrentDate)-1),12,31) else
    date(year(currentdate),month(CurrentDate),1)-1
    Example : if 9( 23 sep 2010 ) = 1 then date ((2010(23 Sep 2010)-1),12,31) else date(2010(23 sep 2010),9( 23 Sep 2010),1)-1.
    Issues :
    For some reports the Aging Date parameter is poping up but for some of the reports the Aging Date forumla is calculating in the behind based on the u201CPost Dateu201D.
    Here is my Record Selection :
    (not isnull({CLARITY_TDL.SERV_AREA_ID}) and {CLARITY_TDL.SERV_AREA_ID}
    in {?Service Area} or 0 in {?Service Area}) and
    (not isnull({CLARITY_DEP.SPECIALTY}) and {CLARITY_DEP.SPECIALTY} in {?Specialty} or {?Specialty} =
    "Specialty(s)" or {?Specialty} = "NONE") and
    (not isnull({CLARITY_TDL.PERFORMING_PROV_ID}) and {CLARITY_TDL.PERFORMING_PROV_ID} in {?Service Provider} or
    {?Service Provider} = "Provider(s)" or {?Service Provider} = "NONE") and
    {CLARITY_TDL.POST_DATE} = {@Aging Date}and
    [color=darkred]{CLARITY_TDL.DETAIL_TYPE} in [60, 61] and
    {CL_EMP_CLARITY.USER_ID} = CurrentCEUserName
    Moreover when I check Show SQL for the where clause
    CLARITY_TDL"."SERV_AREA_ID" IS NOT NULL AND "CLARITY_TDL"."SERV_AREA_ID"=10 AND "CLARITY_TDL"."POST_DATE">={ts '2010-08-31 00:00:00'} AND "CLARITY_TDL"."POST_DATE"<{ts '2010-09-01 00:00:00'})
    AND ("CLARITY_TDL"."DETAIL_TYPE"=60 OR "CLARITY_TDL"."DETAIL_TYPE"=61) AND "CL_EMP_CLARITY"."USER_ID"=''
    I donu2019t know why the post date is going in between the date/time ranges. I am scrating my head to understand the things to work. Please help me out.

    Not sure what you are trying to do here
    (not isnull({CLARITY_TDL.SERV_AREA_ID}) and {CLARITY_TDL.SERV_AREA_ID}
    in {?Service Area} or 0 in {?Service Area}) and
    (not isnull({CLARITY_DEP.SPECIALTY}) and {CLARITY_DEP.SPECIALTY} in {?Specialty} or {?Specialty} =
    "Specialty(s)" or {?Specialty} = "NONE") and
    (not isnull({CLARITY_TDL.PERFORMING_PROV_ID}) and {CLARITY_TDL.PERFORMING_PROV_ID} in {?Service Provider} or
    {?Service Provider} = "Provider(s)" or {?Service Provider} = "NONE") and
    Probably better to right these on these lines
    (If {?Service Area} not equals 0 then not isnull({CLARITY_TDL.SERV_AREA_ID}) and {CLARITY_TDL.SERV_AREA_ID}
    in {?Service Area}  else true) and
    NB Typed not equals as symbols disappear
    This means nothing in SQL and will cause whole clause to be evaluated locally and not on database
    or {?Specialty} =
    "Specialty(s)" or {?Specialty} = "NONE")
    I am not sure what you are trying to do so can not offer an alternative.
    Ian

  • Post date and due date

    Hi all,
    can any  tell me what you mean by 'posting date' and 'net due date' and' clearing date'?
    what is the difference between them?
    Table is-BSID
    BUDAT-posting date
    ZFBDT-Baseline date for due date calculation
    AUGDT-clearing date.
    thank u
    sunny.

    BUDAT-posting date
    -> to determine the book-period (bkpf-monat)
    ZFBDT-Baseline date for due date calculation
    -> determine date when an obligation becomes due
    due date = zfbdt + bsik-zbd1t (or ZBD2t or ZBD3t)
    AUGDT-clearing date
    -> date when open-item becomes a cleared item
    by payment or reversal or...
    A.

  • Autonomous transactions not seeing posted data

    I want to add a button to a form to call a report. The users want to update data in the form, run the report then decide if the data is to be committed. I can post the changed data but the report doesn't see the posted data as Oracle starts a new session.
    The report performs various calculations and before it is run, the calculations are performed and data extracted to separate tables, the report then runs on the extracted data then the temporary table data is deleted.
    I thought autonomous transactions would be my solution. The data is posted within forms, the form then calls a database procedure which has the autonomous procedure declared, data extracted and committed to the temporary tables within the autonomous transaction (form data stays uncommitted), report runs using the extracted data. User could then decide if the amended data could then be committed to the database.
    The autonomous transaction does not seem to see the posted data. The procedure picks up the data 'pre post'. Any ideas on what I can do to get round this?
    Thanks in advance
    Karen Stalker

    Thanks for all the replies.
    My form that will call the report can call up to 12 other forms with data always posted and never committed until the user is prompted to on leaving the main form, or the user presses the commit key. I liked the idea of writing to a temporary table but the way this application is designed, this would mean a big rewrite of a lot of complicated forms. I would rather leave them alone as they work!!
    I could pass the record groups into the report - this would mean about 15 groups but that shouldn't be a problem except that there are a few child queries which I read can't be done that way. This may be a daft question but can I pass the record groups into the report and the record groups be then used in the after parameter trigger. There I could do all the necessary complications, write to my extract tables and then carry on as normal - i.e. the report gets the data from these extract tables.
    My best solution would be to get the reports and forms to run in the same session but how can I do this? As far as I'm aware, RUN_REPORT_OBJECT starts a new session. Hopefully someone knows how to get them in the same session.
    Thanks again
    Karen

  • Baseline date calculation in Invoice verification (MIRO)

    Dear experts,
    I need to set baseline date after 40 days from document date in MIRO.
    Baseline date calculation of "Terms of Payment" in IMG has two parameters:
      &#12539;Fixed day
      &#12539;Additional months
    We cannot set 40 days in these parameters.
    Can anybody tell me how to set baseline date not month but date(not fixed day) ?
    Please advise me on the settings SPRO>MM>Purchasing>Vendor Master>Define terms of Payment.
    Thanks & Regards
    Ken

    Hi,
    You can't do this.
    The baseline date is the date on which the calculations are made.
    So if you have 40 days to pay, this will be 40 days from the baseline date.
    This will either be the document date or another date, but you can't (in standard SAP) have the baseline date as "X" days after "Y".
    So the baseline date is the date of an event (e.g. the date that the Invoice was posted) not a calculation.
    Is it possible that you have misunderstood the use of this date?
    If you just want to ensure that the payment date is 40 days after invoice recipt, then set you just have to enter the number of days in the payment terms and the baseline date stays as the invoice date (etc.)
    Steve B

  • Baseline Date for Due Date Calculation required for S/L indicators

    Hello,
    Iu2019m facing the following problem
    Iu2019m trying to insert an invoice (using a customer master record) but the system blocks me because the field ZFBDT (Baseline Date for Due Date Calculation) is a Required entry.
    The strange thing is  that if I use a S/L indicators the field is mandatory, if not the date may be defaulted.
    I checked in OB41 but there are non differences between Special PK and normal PK.
    Any ideas?
    Thanks in advance
    Alberto

    Dear Alberto,
    the field "Due On (BSEG-ZFBDT)" cannot be controlled with field status.
    It is controlled by field attribute of screen painter (Tcd: SE51).  If
    you look at element attribute for "Due On" field, a flag for required
    entry is activated.  In this case, field status has no control over
    the field.
    As of release 3.1G, field BSEG-ZFBDT is hardcoded in most FI screens
    to be mandatory and cannot be influenced by any field status
    changes. This situation is only valid when posting with special G/L
    indicator (ie PK 29/39).
    SAP development team has determined that this is a critical field.  The
    reason behind this is that this special GL screen and the data entered
    here are very important to many other programs. This data affects
    liabilities and receivables where due date is necessary almost
    everytime. Thus, we changed this field in this screen in order to
    prevent problems in many other areas. The reason is explained further
    in note 95079.
    I hope this helps You.
    mauri

Maybe you are looking for

  • Purchase order Condition control tab?

    Hi, Here in the purchase order condition control tab I need to get Price Date and Price date category. Presently they are not appearing in my purchase orders. When I go to screen layout, I am not able to get those fields to configure. Could please an

  • UPLOADING DATA  IN A NON STANDARD TABLE

    I have a non standard table.I want to upload data in that table using SCAT.So,how Test case can be created for uploading the data in that table? Edited by: Debasish Behera on Mar 17, 2008 1:02 PM

  • Photos don't import

    i tunes syncs my music correctly, imports cds, etc but MY PICTURES will not import, even though boxes are checked under PHOTOS. using latest itunes 8.1

  • Anyone heard or seen an apple hardware error code 4MOT/4/40000003:HDD-1255 ?

    i just did an apple hardware test and this is what i got. my imac running slow. it hangs and stutters often.

  • IMovie 11 footage freezing when picture-in-picture applied

    I have an iMovie project. and have a clip in the project. I take a picture, saved to my "Downloads" folder, drag it into the iMovie project browser, on to the clip in the project, and click on the "Picture-in-Picture" setting. It applies the effect,