My colleague Tom Stumpf and I were recently discussing running processes in batch that require schedules that the batch framework does not provide out of the box. For instance the business scenario we discussed was running a process only on the last day of the month. I took a look at the SRSReportServerWarmup class to get an idea what a class that fulfils this requirement might look like. Here were my steps:
1. Create a new class named LastDayOfMonth.
2. LastDayOfMonth extends RunBaseBatch class.
3. Create the following methods:
4. Here is what the code looks like for each method in the LastDayOfMonth class:
public void run()
public serverstatic LastDayOfMonth construct()
return new LastDayOfMonth();
public staticvoid main(Args _args)
LastDayOfMonth lastdayofmonth = LastDayOfMonth::construct();
private void DoWorkIfLastDayOfMonth()
if (LastOfMth == today())
//Perform some work here based on if today is the last day of the month.
//Exit gracefully since this is not the last day of the month.
5. Right click on the LastDayOfMonth class in the AOT and choose to open it. You will be presented with the batch scheduler form. In this example we would schedule the batch to execute once per day.
The logic in the DoWorkIfLastDayOfMonth method will determine what logic is executed.
This is an example of using an AX method endmth() and a small bit of creativity to schedule something to batch in a way the scheduler does not allow. Here are some date time methods that could also be used:
Thanks for reading.