Batch job ran twice with in recurrence

Hi

I got a problem which is:

A batch job for AIF to export some data, it sets to run once daily, but sometimes it runs twice a day, after the first run, following by the second just a few minutes later.

AX 2009, AIF job!

Any reply would be appreciated!

Rosa

What does the batch job contain (tasks)? Class with custom code? what is the recurrence pattern?

It would be difficult to say what went wrong, without knowing the details of the batch job.

Hi Kranthi,

Thanks for your reply!

The batch job exports item transactions status , it is a custom code. It runs every day in the morning! A few days ago, it ran twice in that morning in five minutes.

How you are saying that it ran twice? By looking at the batch job history or the does the data exported twice?

Look at the batch job history and its details, see if they are triggered by same batch job. (to check if someone hasn’t requested the data export by the running a different batch job). Also look at the AIF history.

Hi Kranthi,

There are two output files from AX, when i checked the batch history, the job only ran once. AIF history: there are the same messages twice showed. Noboby has touched this batch job.

Then there is no issue with the recurrence as such.

If the batch was not ran twice and only the data exported twice then you need to check with your code.

Hi Kranthi,

It happens not often. I am going to check the code, see if i can find anything!

Thanks!

Hi Kranthi,

Could you explain me what the queryRun.reset() method does?

Thanks!

It will help to reuse the queryRun object (multiple times). Example - If you have already looped through the records returned by the queryRun and again if you want to loop thorugh the same records for a different purpose, then you need to call reset. It takes the queryRun to the initial position so that you can traverse thourgh the records.

Try the below example in a job,

Query query;
QueryRun qr;
InventTable table;

query = new Query(‘InventTable’);

qr = new QueryRun(query);

while (qr.next())
{
table = qr.getNo(1);
info(table.ItemId);
}

info(‘Test’);

qr.reset(); //Try by removing and adding this line of code.
while (qr.next())
{
table = qr.getNo(1);
info(table.ItemId);
}