Running a existing batch job automatically....

ritz
ritz Member Posts: 25
Hi All,

This question is bit country specific but in terms of technique it goes like this:

We have a batch job(Daily Stock Account Generator) which we need to run for every single day(when you run this report it ask for the date you want to run this batch job for). And as you all know clients do not want to do that they want it to be automatic.

I was thinking of giving the date range but got stuck as there are some complexities with it.

I have not tried it with the job scheduler,

any ideas??


Thanks and Regards,
Ritesh
Thanks,

Ritesh

Comments

  • David_Cox
    David_Cox Member Posts: 509
    Is this a Report or Dataport?

    OnPreReport you can populate the Date Filter like this

    OnPreReport()
    Customer.SETRANGE("Date Filter",0D,WORKDATE);
    or
    MyDate := WORKDATE;
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • ritz
    ritz Member Posts: 25
    Hi David,

    There is a problem with this report. This report is bit stiff in terms of Date filtering.
    This batch job takes only one date and evaluates the stock on that particular date.

    for example.
    i run this report on say 10th of Dec and again i run it on the 15th of Dec, it will only tell me the status of the 10th and the 15th of dec not for the 12,13 or 14. (Hope i am able to explain what i want to.).

    Thanks
    Thanks,

    Ritesh
  • David_Cox
    David_Cox Member Posts: 509
    The report returns the Quantity at date, this means the sum of all entries from 0D to the Entered Date.

    You could show the "Net Change" for a Date period, but that only shows the movement postings within the period.

    What do you really want to show?
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • ssingla
    ssingla Member Posts: 2,973
    Dear Friend,

    As I can guess this report is for Excise puprose. This report must be (as per my experience with this report) shows the days opening balance + receipt - issues = closing stock. The report only runs for the item on which excise is levied.

    As per ur statement the report needs to be run automatically. :-k :-k

    Normally the user when ever needs the report , runs it and prints its. Do you want to automate the process so that every morning the report is run and the print is available to the concerned person or are you storing the data of the report in some table or exporting it.

    Please clarify
    CA Sandeep Singla
    http://ssdynamics.co.in
  • mukesve
    mukesve Member Posts: 28
    Hi Ritesh

    Lets try this -

    Create a table Batch Execuation Status in the database with field - Date, Batch Execuation Status

    Add the code in function LogInStart() in CU1 Application Management. The code should check the data in the Batch Execuation Status table for the status of the execuation for today and if there is no entry, it should execute the code to run the batch job.

    Modify the Batch Job, If it runs successfully. It should add a line in Batch Execuation Status table.

    Mukesh Verma :D
  • themave
    themave Member Posts: 1,058
    If you have the job scheduler licensed it would work perfect for this, I use it to run daily requisitions, ect.

    I set the datefilter with code like explained above.

    here is part of my code, I use slightly different dates then you,

    Report - OnInitReport()
    OrderDate := TODAY +20;
    ToDate := TODAY +20;
    CurrTemplateName := 'REQ';
    CurrWorksheetName := 'SF';

    Report - OnPreReport()
    Counter := 0;
    MaxDate:= 12319999D;
    IF OrderDate = 0D THEN
    ERROR(Text002);
    IF ToDate = 0D THEN
    ERROR(Text003);
    PeriodLength := ToDate - OrderDate + 1;
    IF PeriodLength <= 0 THEN
    ERROR(Text004);

    Anyways setting the date in the code is straight forward, the job schedulers runs the report every day at 10 pm, the branch manager come in the morning and have a stock requisition ready.
  • ritz
    ritz Member Posts: 25
    Thank You Very much to all of you i got the answer

    Thank you Mukesh Sir!
    Thanks,

    Ritesh