Question
Davidson Espindola · Mar 3, 2017

zen report

Hi, all

I have the following problem in generating a PDF report in ZEN, which has many items, a general total of approximately 30,000 items, but gives an error, I can generate a report with a maximum of 8,000 items, which may be wrong.

==========

See the error log:

6. "Error rendering: OS code=1 Use $LOG=1 to check : CSP Error"  at 11:13 am.   $I=|TCP|1972|10644   ($X=325  $Y=513)
     $J=10644  $ZA=24576   $ZB=$c(0)   $ZS=262144 ($S=267997176)

=========
Class Ideal.ListaEstoquePDF Extends %ZEN.Report.reportPage
{

Parameter APPLICATION = "Ideal";

Parameter DEFAULTMODE As STRING [ Constraint ",html,pdf,xml"Flags = ENUM ] = "pdf";

Parameter REPORTXMLNAMESPACE;

Parameter XSLTMODE = "server";

XData Style
{
<style type="text/css">
/* style for title bar */
#title {
    colorgreen    ;
    font-familyVerdana;
    font-size2.0em;
    font-weightbold;
    padding20px;
    border-bottom1px solid black;
    text-aligncenter;
}
#folha {
    page-break-afteralways;
}

</style>
}

/// ReportDefinition is a placeholder. ///callArgument='zenPage.DtEnvio'
XData ReportDefinition [ XMLNamespace "http://www.intersystems.com/zen/report/definition]
{
<report xmlns="http://www.intersystems.com/zen/report/definition"
    name="MyReport" call="CriaXML"  
   
</report>
}

XData ReportDisplay [ XMLNamespace "http://www.intersystems.com/zen/report/display]
{
<report xmlns="http://www.intersystems.com/zen/report/display"
   name="MyReport">
   
<document width="21cm" height="29.7cm"  
  marginLeft="1cm" marginRight="1cm"  marginTop="1cm" marginBottom="1cm"
   orientation="portrait" ></document>


 <body>
<group 
name="GrSelect" 
width="100%" 
style="text-align:left" 
xslfostyle="fill:yellow; font-family:Arial; font-size:9pt;" 
>

<group 
name="GrCliente"  
pagebreak="true" 
width="100%" 
style="text-align:left"  
>
<header
<!-- REPORT HEADER -->
<table orient="col" width="6cm" >
<item literalSpaces="true" field="Orcamento" xslfostyle="text-align:right; font-size:13pt" width="11cm" />
</table>
</header>



<group              
name="GrCabItens"  
pagebreak="false" 
width="100%" 
style="text-align:left"  
>
<table class="table2"
width="100%" orient="col" xslfostyle="border:1pt solid black; background-color:silver; text-align:center; font-family:Arial; font-size:10pt;"  >
    <item literalSpaces="true" field="CabCod" xslfostyle="text-align:left; font-size:8pt" width="1.2cm"/>
    <item literalSpaces="true" field="CabDesc" xslfostyle="text-align:left; font-size:8pt" width="7.3cm"/>
    <item literalSpaces="true" field="CabQuant" xslfostyle="text-align:right; font-size:8pt" width="1.1cm" />
    <item literalSpaces="true" field="CabUnid" xslfostyle="text-align:right; font-size:8pt" width="0.9cm" />
    <item literalSpaces="true" field="CabUnit" xslfostyle="text-align:right; font-size:8pt" width="1.8cm" />
    <item literalSpaces="true" field="CabTotal" xslfostyle="text-align:right; font-size:8pt" width="1.9cm" />
    <item literalSpaces="true" field="CabFab" xslfostyle="text-align:right; font-size:8pt" width="4.5cm" />
    <item literalSpaces="true" field="CabSeq" xslfostyle="text-align:right; font-size:8pt" width="1.0cm" />
</table>
</group>
<group              
name="GrItens" pagebreak="false" width="100%" style="text-align:left"  
>

<group              
name="GrSeqItem" pagebreak="false" width="100%" style="text-align:left"  
>

<table class="table2" width="50%" orient="col" style="color: black; border:none" 
    <item literalSpaces="true" field="CodProduto" xslfostyle="text-align:left; font-size:8pt" width="1.2cm" />
    <item literalSpaces="true" field="NomeProduto" xslfostyle="text-align:left; font-size:8pt" width="7.3cm" />
    <item literalSpaces="true" field="QuantProduto" xslfostyle="text-align:center; font-size:8pt" width="1.1cm"/>
    <item literalSpaces="true" field="UnidProduto" xslfostyle="text-align:right; font-size:8pt" width="0.9cm"/>
    <item literalSpaces="true" field="ValorUnit" xslfostyle="text-align:right; font-size:8pt" width="1.8cm"/>
    <item literalSpaces="true" field="ValorTotal" xslfostyle="text-align:right; font-size:8pt" width="1.9cm"/>
    <item literalSpaces="true" field="Fabr" xslfostyle="text-align:right; font-size:8pt" width="4.5cm"/>
    <item literalSpaces="true" field="Seq" xslfostyle="text-align:right; font-size:8pt" width="1.0cm"/>
</table>

</group>
</group>

<group
name="GrTotal" pagebreak="false" width="100%" style="text-align:left"
>
<fo><line pattern="empty"/></fo>

<table 
width="100%" 
orient="col" 
xslfostyle="border:1pt solid black; background-color:silver; text-align:center; font-size:12pt;"  >
    <item literalSpaces="true" field="TotalBruto" xslfostyle="font-size:10pt" width="4.5cm"/>
</table>


<fo><line pattern="empty"/></fo>


</group>
</group>
</group>
</body>
</report>
}

ClassMethod CriaXML(ByRef params)
{
    set data="Data: "_$ZD(+$H,4),dc="|"
    MSG="",contitem=1,cont=8000
 
    !,"<GrSelect>"
            !,"<GrCliente>"
            !,"<Orcamento>",!,"LISTA ESTOQUE DE PRODUTOS",!,"</Orcamento>"
        
             !,"<GrCabItens>"
             !,"<CabCod>",!,"Codigo","</CabCod>"
             !,"<CabDesc>",!,"Descricao Produto","</CabDesc>"
             !,"<CabQuant>",!,"Quant","</CabQuant>"
             !,"<CabUnid>",!,"Unid","</CabUnid>"
             !,"<CabUnit>",!,"Pr.Unitario","</CabUnit>"
             !,"<Cabtotal>",!,"Total","</Cabtotal>"
             !,"<CabFab>",!,"Fabr","</CabFab>"
             !,"<CabSeq>",!,"Seq","</CabSeq>"
             !,"</GrCabItens>"

            !,"<GrItens>"      ; tem q criar l?? em cima o grupo dos itens 
FABR="",CEMP=1,CEST=1,DC="|",TOTPESO=0,TOTAL=0,CONT=1
;
            FABR=$o(^NEFAL(CEMP,FABR)) ; busca o 1o item do pedido 
            while FABR'=0 {
            q:contitem=cont
            nfab=$p($g(^NEGRO(FABR)),DC,1)
            DIVI=0
            DIVI=$o(^NEFAL(CEMP,FABR,DIVI))
            while DIVI'=0 {
            LINHA=0
            LINHA=$o(^NEFAL(CEMP,FABR,DIVI,LINHA))
            while LINHA'=0 {
            NOME=""
            NOME=$o(^NEFAL(CEMP,FABR,DIVI,LINHA,NOME))
            while NOME'="" {
            CPRO=18,DC="|"
            CPRO=$o(^NEFAL(CEMP,FABR,DIVI,LINHA,NOME,CPRO))
            while CPRO'=0 {
            REG=$G(^MEPRO(CEMP,CPRO)),UNID=$P(REG,DC,4)
            X=$G(^MEPRO(CEMP,CPRO,1)),SALD1=+$P(X,DC,1)
            VUNI=$P($G(^MEPRO(CEMP,CPRO,0)),DC,2)
            ValorUnit=$fn(VUNI/100,".",2)
            VTPR=VUNI*SALD1
            ValorTotal=$fn(VTPR/100,".",2)
            TOTAL=TOTAL+VTPR
             q:contitem=cont
            !,"<GrSeqItem>"
            !,"<CodProduto>",!,CPRO,!,"</CodProduto>"
            !,"<NomeProduto>",!,NOME,!,"</NomeProduto>"
            !,"<QuantProduto>",!,SALD1,!,"</QuantProduto>"
            !,"<UnidProduto>",!,UNID,!,"</UnidProduto>"
            !,"<ValorUnit>",!,$j(ValorUnit,10),!,"</ValorUnit>"
            !,"<ValorTotal>",!,$j(ValorTotal,10),!,"</ValorTotal>"
            !,"<Fabr>",!,FABR_"-"_$e(nfab,1,20),!,"</Fabr>"
            !,"<Seq>",!,contitem,!,"</Seq>"
            !,"</GrSeqItem>"
            set CPRO=+$o(^NEFAL(CEMP,FABR,DIVI,LINHA,NOME,CPRO))
            set contitem=contitem+1
            }
            set NOME=$o(^NEFAL(CEMP,FABR,DIVI,LINHA,NOME))
            }
    set LINHA=+$o(^NEFAL(CEMP,FABR,DIVI,LINHA))
    }
set DIVI=+$o(^NEFAL(CEMP,FABR,DIVI))
            }
set FABR=+$o(^NEFAL(CEMP,FABR))
}
            !,"</GrItens>"
            TOTAL=0
            !,"<GrTotal>"
            !,"<TotalBruto>",!,"Total Bruto.:",$j($FN(TOTAL/100,".",2),15),!,"</TotalBruto>"
            !,"</GrTotal>"
            !,"</GrCliente>"
           

    !,"</GrSelect>"
    2
}

ClassMethod %OnPreHTTP() As %Boolean
{
        Set %response.Timeout=900
        Quit 1
}

}
 
10
0 4 909 2

Replies

  1. Try setting RenderTimeOut and PrintTimeOut properties for the report.
  2. Check logfile (you can determine directory in which it gets created by instantiating the report and calling GetRootDir method, but usually it's a value of the ^%SYS("TempDir") global, unless you specify ReportDir property or parameter).

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.

Hi how do you solve it?

Regards

Did you ever run the $LOG=1 option to see what additional error details there are? This would be the first step because it might not be a timeout issue but maybe an issue with the actual data itself (invalid xml characters for example).  When running a zen report directly, the data retrieval and data display processes need to complete within the CSP gateway timeout setting. Sometimes this isn't possible, that's why Zen reports supports the split/merge option as well as having a number of Generate to file methods (because they are being written to a file, these methods are not impacted by the timeout).