If I was asked to do this the one change I would do/have done in the past is implement the class method with sql code vs object code.  Whether you are using a storage strategy based on CacheSQLStorage or CacheStorage when you open an object all of the properties that are stored in the global are "swizzled" into memory and allocated a memory location so that later on when you do object.property you have the value.  In your specific question, you want the total of all charges from the parent.  I would do something like

 

&sql(select sum(Amount) into :Total FROM FreightChargesDetail where Freight=:currentID)

in truth when I have done this I've actually not used a class method at all but rather in my SQLComputeCode I would do something like

 { 
  New ParentId,Total Set ParentId={%%ID} &SQL(SELECT SUM(Amount) into :Total FROM FreightChargesDetail where Freight=:ParentId) Set {*}=$Get(Total)}, SqlComputed, Transient ];
 

A couple of reasons.

  • I do not see a reason to expose an interface/classmethod that gets the total as it's already satisfied by the property definition.
  • I do not believe SQLCompute code is implemented inside of a procedure  so any local variable should be New'ed so that do not flow out of the stack.

If you are scripting you may want to consider setting your process as a "Batch User".  This is found in IDX DBMS system settings.   If you go down this path in your script code 

1. your process will not be sent any extended escape sequences but you will instead be sent terminal prompts which your script can react to

2. If your script is on a dbms form/selector you can use commands to interact with the dbms form/selector such as

|FILE|

|QUIT|

etc.  Those may not be the exact commands from my memory but I believe the extended help for the Batch Users field will show you all of the commands you script can send.

You may want to consider reading up on SPLITANDMERGE http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=... which is designed to address large reports.  

"The PDF output for a very large report may exceed the memory restrictions of the FOP rendering engine. In this case, you can split the report into several smaller sections. Each section is written to disk as a separate temporary file, and merged into a single PDF file once the entire report has been processed. "

Looking at your xml structure you may be able to define the repeating element to be <GrItems>.  Note while I do not believe you are including page numbers in your ReportDisplay, but if you do I do believe it does not produce the desired result when using SPLITANDMERGE.