Hi Folks,
I have been working with a batch job which is running from weeks. I want to restrict the execution time so that it will end after executing some no. of records at a time and than continue again.
Please help to resolve this issue.
Thanks in Advance!!!
Hi Martin,
Thanks, I ended with this solution only where I added a new parameter in the batch job which give the number of hours a batch job should be run.
Simultaneously counting the number of record and after reaching a specific time under that time interval, I m ending the batch job.
Or even simpler, you can just use TimeNow(). I cannot tell you without knowing more information about the batch job. How to stop it depends on the batch job. Need more info about it.
Hi Anton,
Yes, I needed something like this only. Thanks for your response. Could you please let me know can I debugg it without in running it in batch process?
and how can I stop the batch job through after specific seconds?
You can use System.Diagnostics.Stopwatch to figure out how long the batch process has been running and stop it when it has exceeded the max duration.
Here is a simple example of how to use it.
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); //do something info(strFmt("Done. Duration %1s.", sw.ElapsedMilliseconds/1000));
First of all, decide what you actually want. The number of records, as you asked before, or time, as you're asking now.
Yes, as It has millions of records to process.
I was thinking to add a parameter of "Number of hours to execute the job" in the batch job. And to convert it into seconds and when it reaches more than no. of hours mentioned in the parameter it will end.
So I want to know can we do through this? And is there is any function in X++ which returns seconds from current date and time.
It's not clear to me what you need from us.
Simply count processed records in your batch job and end when you reach the limit.
André Arnaud de Cal...
292,074
Super User 2025 Season 1
Martin Dráb
230,900
Most Valuable Professional
nmaenpaa
101,156