Automatically Change Posting Dates in General Ledger Setup

gadzilla1gadzilla1 Member Posts: 316
Hello all,

I was wondering if it was possible to change the field values of Allow Posting From and Allow Posting To to the date of the following business day automatically at 11pm every evening.

Currently we are manually changing this date in those fields every evening in the General Ledger Setup form.

If anyone has any ideas they would be greatly appreciated.

Thank you and have a great day. gad1

Comments

  • SavatageSavatage Member Posts: 7,142
    FYI
    we change our date range monthly ie.7/1/2008 to 7/31/2008

    you run a tight ship over there.
    The simple code of
    if "Posting Date" <> WORKDATE then "Posting Date" := Workdate;

    on most of our posting fields. We have noticed a dramatic descrease (if any) posting date errors.
  • gadzilla1gadzilla1 Member Posts: 316
    Thanks Harry!

    One clarification please...where do I insert that line of code. I'm looking forward to putting this in place and testing.

    Have a great day - gad1
  • Alex_ChowAlex_Chow Member Posts: 5,063
    gadzilla1 wrote:
    Hello all,

    I was wondering if it was possible to change the field values of Allow Posting From and Allow Posting To to the date of the following business day automatically at 11pm every evening.

    Currently we are manually changing this date in those fields every evening in the General Ledger Setup form.

    If anyone has any ideas they would be greatly appreciated.

    Thank you and have a great day. gad1

    You can setup the job scheduler to do so.
  • SavatageSavatage Member Posts: 7,142
    edited 2008-07-18
    check this
    http://www.mibuso.com/forum/viewtopic.php?t=25021

    post 6 - add code to CU1
    post 12 - add code to form
    Post 13 - create a report & use job scheduler
  • gadzilla1gadzilla1 Member Posts: 316
    Thanks for the reply Alex. We will be purchasing job scheduler sometime in the future...is that what you are referring to?

    For the short term I'd like to implement Harry's suggestion in test. Do you happen to know the optimal location to place the code?

    Thanks! gad1
  • SavatageSavatage Member Posts: 7,142
    where do you want it to happen? everywhere? or specific forms like sales & purchase orders? Journals? Did you see the link listed above?
  • gadzilla1gadzilla1 Member Posts: 316
    Thanks for the reply Harry. I did nor see your reference to the link http://www.mibuso.com/forum/viewtopic.php?t=25021
    prior to sending my last post.

    I'd like to change those dates only from the General Ledger Setup form because that's where it's being manually changed now.
  • SavatageSavatage Member Posts: 7,142
    well if you add code to CU1 it will be based on whomever logs in last, I would say a specific user but what if that user doesn't come in that day?
    so...

    Say someone changed there computer date to 3/12/2005 and they are the last one to log in then the date will be changed to that!

    I like having a month range and having the field update when I enter the form. This way it's user specific.

    If you wanted to go the CU1 route you could
    first add a field to GlSetup table called Auto Update Posting Range.
    Add it to the gl setup form. CHeck it! you can uncheck it to TURN IT OFF!

    Then Add to LogInStart() around the lines
    LogInDate := TODAY;
    LogInTime := TIME;
    //Mod Start
    IF (GLSetup."Auto Update Posting Range") AND
       (GLSetup."Allow Posting From" <> TODAY) AND
       (GLSetup."Allow Posting To" <> TODAY)
     THEN BEGIN
       GLSetup."Allow Posting From" := TODAY;
       GLSetup."Allow Posting To" := TODAY;
       GLSetup.MODIFY;
      END;
    //mod end
    

    **Caveat emptor!!** - Greg Brady :mrgreen:
  • garakgarak Member Posts: 3,263
    you can use the Sheduler and NAS for automatic jobs. Search the forum for this or / and read the manuals

    Regards
    Do you make it right, it works too!
  • SavatageSavatage Member Posts: 7,142
    gadzilla1 wrote:
    We will be purchasing job scheduler sometime in the future
  • gadzilla1gadzilla1 Member Posts: 316
    Thanks Harry - I will try your code example. Much appreciated!
  • mvdvalkmvdvalk Member Posts: 9
    //Mod Start
    IF (GLSetup."Allow Posting From" <> TODAY) AND
    (GLSetup."Allow Posting To" <> TODAY)
    THEN BEGIN
    GLSetup."Allow Posting From" := TODAY;
    GLSetup."Allow Posting To" := TODAY;
    GLSetup.MODIFY;
    END;
    //mod end

    If I use this code (so without creating and using the extra field in the GLSetup table) in a report, I loose all other settings in the GL Setup table exept the "Allow posting From" and "Allow posting To" values.

    Does anyone have an idea why?
    Marion van der Valk
  • mvdvalkmvdvalk Member Posts: 9
    No, I did not. I used only the code as suggested.
    Should this make the difference?
    Marion van der Valk
  • Alex_ChowAlex_Chow Member Posts: 5,063
    mvdvalk wrote:
    No, I did not. I used only the code as suggested.
    Should this make the difference?

    Yes it will. Since GLSetup is blank.
  • SavatageSavatage Member Posts: 7,142
    that sample code is just a addition to a section that has other coding already there in a CODEUNIT. I assume your REPORT does not have all that coding. The standard codeunit already calls upon the setup table that's why it hasn't been added again.

    anyway try this.
    add a variable to your report called GLSetup
    type= Record
    Subtype= General Ledger Setup

    add a GLSETUP.GET; to the beginning of the code.
  • Alex_ChowAlex_Chow Member Posts: 5,063
    Cool... Thanks for spelling it out Harry. Just assumed he knew... :wink:
  • mvdvalkmvdvalk Member Posts: 9
    No, I did not know (I am a she by the way).

    Thanks, it works perfectly know.
    Marion van der Valk
  • gadzilla1gadzilla1 Member Posts: 316
    Thanks to everyone for the valuable assistance and dialogue.

    Unless there are any objections I'll put 'SOLVED' in the title.

    Have a great day - Chris

    Ps. We're getting Job Scheduler after all! :D
  • ayhan06ayhan06 Member Posts: 210
    gadzilla1 wrote:
    Thanks to everyone for the valuable assistance and dialogue.

    Unless there are any objections I'll put 'SOLVED' in the title.

    Have a great day - Chris

    Ps. We're getting Job Scheduler after all! :D

    Altough It has been solved by recommendations here, I would like to tell a different approach.

    Add two fields in User setup table:Allow Posting From Formula,Allow Posting To Formula.
    Add this function In User Setup table.
    CalculateAllowedPostingDate()
    // 6GENCore1.0 Ayhan Özbay 03.03.2008 Task:80300
    IF FORMAT("Allow Posting From Formula") <> '' THEN BEGIN
      "Allow Posting From" := CALCDATE("Allow Posting From Formula",TODAY);
      "Allow FA Posting From" := CALCDATE("Allow Posting From Formula",TODAY);
    END;
    
    IF FORMAT("Allow Posting To Formula") <> '' THEN BEGIN
      "Allow Posting To" := CALCDATE("Allow Posting To Formula",TODAY);
      "Allow FA Posting To" := CALCDATE("Allow Posting To Formula",TODAY);
    END;
    

    Change codeunits (which check allowed posting dates). here are two example:

    cu 11 Gen. Jnl.-Check Line :
    DateNotAllowed(PostingDate : Date) : Boolean
    IF (AllowPostingFrom = 0D) AND (AllowPostingTo = 0D) THEN BEGIN
      IF USERID <> '' THEN
        IF UserSetup.GET(USERID) THEN BEGIN
    
          // 6GENCore1.0 Ayhan Özbay 03.03.2008 Task:80300
          UserSetup.CalculateAllowedPostingDate;
    
    
          AllowPostingFrom := UserSetup."Allow Posting From";
          AllowPostingTo := UserSetup."Allow Posting To";
        END;
      IF (AllowPostingFrom = 0D) AND (AllowPostingTo = 0D) THEN BEGIN
        GLSetup.GET;
        AllowPostingFrom := GLSetup."Allow Posting From";
        AllowPostingTo := GLSetup."Allow Posting To";
      END;
      IF AllowPostingTo = 0D THEN
        AllowPostingTo := 31129999D;
    END;
    

    cu 21 Item Jnl.-Check Line:
      IF (AllowPostingFrom = 0D) AND (AllowPostingTo = 0D) THEN BEGIN
        InvtSetup.GET;
        GLSetup.GET;
        IF USERID <> '' THEN
          IF UserSetup.GET(USERID) THEN BEGIN
    
            // 6GENCore1.0 Ayhan Özbay 03.03.2008 Task:80300
            UserSetup.CalculateAllowedPostingDate;
    
            AllowPostingFrom := UserSetup."Allow Posting From";
            AllowPostingTo := UserSetup."Allow Posting To";
          END;
        IF (AllowPostingFrom = 0D) AND (AllowPostingTo = 0D) THEN BEGIN
          AllowPostingFrom := GLSetup."Allow Posting From";
          AllowPostingTo := GLSetup."Allow Posting To";
        END;
        IF AllowPostingTo = 0D THEN
          AllowPostingTo := 31129999D;
      END;
    
    

    in this way, you needn't job scheduler etc. Allowed posting dates are calculated on the fly by user based calculation formula..

    hope this helps.
  • slmaluwaslmaluwa Member Posts: 366
    In the line of the same question here, has anyone noticed that

    Even if we have allowed posting range set in user setup table and current posting date is well within that range, NAV sometime doesn't allow it to post. I have seen this in some occasions where the NAV try to go back and forth in transaction table and tries to adjust the remaining quantities of lines with date beyond the filter set (a erroneous date of invoice in a future date).

    I will try to simulate one and try my best post the scenario here soon.
    "A bove maiore discit arare minor"-"From the old ox, the young one learns to plow."
  • themavethemave Member Posts: 1,058
    not that you asked, but just a word of warning the user setup table takes priority over the glsetup posting to and from dates. So when I need to accomplish the same thing I did it on the user table, that way you know you only have to do it once. I used the job schedular and a non-printing report to accomplish it.
Sign In or Register to comment.