This seems like an odd way to trigger this. I think that this might be better to put the code into Ubaq and then schedule the BAQ to run using the BAQ Export process. Data directives can be problematic when running code in them. Plus it will be easier to test in the BAQ, AND, you can return all of your data needed to find the lines to close in the BAQ then run the code after so you don’t have to do the lookup in the code. (both ways work though)