+ Start a Discussion
test269test269 

Urgent:System.LimitException: Too many script statements: 200001

System.LimitException: Too many script statements: 200001

crop1645crop1645

This problem is readily debuggable using the following:

 

  • Use within your main loop a System.debug(Limits.getScriptStatements()); statement
  • Use the same for preamble and post processing steps

This will  let you see how many script statements you execute per line read from your CSV(?) file as well as any setup or cleanup.

 

Then, you need to look to see where you can optimize.  

  • For example, what does ImportFunction() do?
  • Are there any triggers executed?  They will count against script limits
  • If there are triggers, are they bulkified?  Are the inserts/updates don ein a single DML statement?

 

That said, CSV processing can easily exceed script limits; The way around this is to use a batchable class where each 'batch scope' is limited in size (# lines). Batch execution has a much higher script limit. You'll need to review APEX batchable classes and espcially the custom iterables/iterators that will provide n file lines to each batch scope

 

test269test269

Hi

 Thank you for your reply.How to batch apex class for the above class.Can u please help me.

 

Thanks in advance.