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.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CA Neeraj Kumar 2,257
André Arnaud de Cal... 913 Super User 2025 Season 2
Sohaib Cheema 611 User Group Leader