1 Introduction

Axional Studio incorporates components to develop high quality PDF documents whose features include:

  • Used for presentations, formal publications.
  • Integration of tables, graphs, maps, etc.
  • Easy navigation between reports (through links).
  • Production in different formats (html, PDF, etc).

The report component is based on a very common concept in the definition of reports: the reports are composed of "sections", and each section is a horizontal space on the page. There are several types of sections, for example:

  • Start, appears on the left side of the page.
  • Page header, appears at the top of all pages.
  • Detail: the most important. At run time, one of these sections is generated for each line (record) in the database.
  • Footer, appears at the bottom of every page. End, appears on the right side of the page.

In the beginning, all the reports present these five sections. Other sections are optional, such as:

  • Group header, this block is printed when the group starts.
  • Group footer, this block is printed when the group ends.



There can only be a single hierarchy of groups, that is, only the data can be grouped in one way (one group nested within the other and so on) and this grouping defines the structure of the entire report. There are a series of design elements, tables, rows, cells, lines, etc., that allow each of them to define their own grouping options.

It is also possible to insert some elements inside others (for example insert an image inside a table). So that the design of a report with a complex structure can be elaborated directly in a very simple way.

The data used to produce the report are obtained from a single flow, so each tuple of the flow must contain the data that you want to print in the report, except for the calculation fields with aggregation functions (sum, count, max, min , avg, etc).

 

2 Organization

The organization of the tags is done in container structure:

Copy
<document>
    <page>
        <data>
            <select>
            </select>
        </data>
        <start>
            <region.static>
                <report.block>
                    <report.table>
                        <body>
                            <report.row>
                                <report.column>
                                    <static>
                                    <tupples>
                                    <aggregate>
                                </report.column>
                            </report.row>
                        </body>
                    </report.table>
                </report.block>
            </region.static>
        </start>
        <before>
            <region.static>
                <report.block>
                    ...
                </report.block>
            </region.static>
        </before>
        <body>
            <region.flow>
                <before>
                    <report.block>
                        ...
                    </report.block>
                </before>
                <detail>
                    <report.block>
                        ...
                    </report.block>
                </detail>
                <after>
                    <report.block>
                        ...
                    </report.block>
                </after>
            </region.flow>
        </body>
        <after>
            <region.static>
                    <report.block>
                        ...
                    </report.block>
            </region.static>
        </after>
        <end>
            <report.block>
                ...
            </report.block>
        </end>
    </page>
</document>

The main container is the <document>, the document contains a <page>. The <page> object contains a data source <data>, and a region <start>, a region <before>, a <body>, an <after> and an <end>. Each of these regions contains blocks, which contain tables. These tables have rows and are composed of columns.

 

3 Data origin

The data source of a report can be an SQL statement or static data within the same script. For the following example, the static data will be used within the same script. It is based on the example in the previous section.

 

3.1 Static data

When the data source is a static data within the script, you have to create a <vtable> and insert data on the vtable.

  • Declare the <vtable> with a name.
  • Make the insertion of the vtable with the tag vtable.insert.
  • Make reference within the page to the data source.
Copy
<vtable name='rows'>
    <column name="ejerci" type='smallint' />
    <column name="period" type='char'  />
    <column name="cuenta" type='decimal'  />
    <column name="nombre" type='char' />
    <column name="debe"   type='decimal'  />
    <column name="haber"  type='decimal'  />
    <column name="saldo"  type='decimal'  />
</vtable>

<vtable.insert name='rows'>
    <matrix>
            {"2007", "Enero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "12345.45", "0", "12345.45"},
            {"2007", "Enero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "0", "346789.00", "346789.00"},
            {"2007", "Enero", "4751.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "5392.88", "0", "5392.88"},
            {"2007", "Enero", "4720.00000", "IVA SOPORTADO", "98734.00", "0", "0"},
            {"2007", "Enero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "0", "3445.670", "0"},
            {"2007", "Enero", "6000.00001", "COMPRAS LINEA ESQUI", "500.00", "5943.23", "0"},
            {"2007", "Enero", "6221.00000", "GASTOS FINANCIEROS", "288834.33", "0", "0"},
            {"2007", "Enero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "0", "12.34", "0"},

            {"2007", "Febrero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "9834.34", "399945.21", "0"},
            {"2007", "Febrero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "6634.34", "346789.00", "0"},
            {"2007", "Febrero", "4720.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "12.23", "2993.34", "0"},
            {"2007", "Febrero", "4751.00000", "IVA SOPORTADO", "2993.88", "0", "0"},
            {"2007", "Febrero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "2394.23", "3445.670", "0"},
            {"2007", "Febrero", "6000.00001", "COMPRAS LINEA ESQUI", "0", "5943.23", "0"},
            {"2007", "Febrero", "6221.00000", "GASTOS FINANCIEROS", "0", "39993.45", "0"},
            {"2007", "Febrero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "0", "233345.35", "0"},

            {"2007", "Marzo", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "0", "7374.34", "0"},
            {"2007", "Marzo", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "2834.45", "183774.00", "0"},
            {"2007", "Marzo", "4720.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "0", "233.45", "0"},
            {"2007", "Marzo", "4751.00000", "IVA SOPORTADO", "5392.88", "0", "0"},
            {"2007", "Marzo", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "0", "3445.670", "0"},
            {"2007", "Marzo", "6000.00001", "COMPRAS LINEA ESQUI", "500.00", "5943.23", "0"},
            {"2007", "Marzo", "6221.00000", "GASTOS FINANCIEROS", "2993.33", "23345.65", "0"},
            {"2007", "Marzo", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "129734", "33.34", "0"}

            {"2008", "Enero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "134.45", "0", "12345.45"},
            {"2008", "Enero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "233.345", "3489.00", "346789.00"},
            {"2008", "Enero", "4751.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "592.00", "3945", "5392.88"},
            {"2008", "Enero", "4720.00000", "IVA SOPORTADO", "98734.00", "23.45", "0"},
            {"2008", "Enero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "100.23", "345.670", "0"},
            {"2008", "Enero", "6000.00001", "COMPRAS LINEA ESQUI", "0.00", "1999234.23", "0"},
            {"2008", "Enero", "6221.00000", "GASTOS FINANCIEROS", "334.33", "2344", "23"},
            {"2008", "Enero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "292", "1234.34", "0"},
    </matrix>
</vtable.insert>
 

3.2 SQL statement

The flow of data in a report can come from an SQL statement: in this case the SQL statment is directly written inside the <data> within a <page>.

 

3.2.1 SELECT

SELECT statement.

Copy
<report.document name='report_doc' type='html' html-debug='false' html2fo-font-correction='3'>
  <report.page name='r_page' group='nivel1' margin-left='0.25' margin-right='0.25' margin-bottom='0.5' margin-top='0.5'>
      <data>
        <select>
            <columns>
                ejerci, period, cuenta,
                nombre, debe,   haber,
                saldo
            </columns>
            <from table='saldos'>
                <join table='ccuentas'>
                    <on>saldos.cuenta = ccuentas.codigo</on>
                </join>
            </from>
        </select>
      </data>
      ....
  </report.page>
</report.document>
 

3.2.2 UNION

The UNION statement is used to combine the result-set of two or more SELECT statements.

Copy
<report.document name='report_doc' type='html' html-debug='false' html2fo-font-correction='3'>
  <report.page name='r_page' group='nivel1' margin-left='0.25' margin-right='0.25' margin-bottom='0.5' margin-top='0.5'>
      <data>
        <union>
            <select>
                <columns>
                    ejerci, period, cuenta,
                    nombre, debe,   haber,
                    saldo
                </columns>
                <from table='saldos'>
                    <join table='ccuentas'>
                        <on>saldos.cuenta = ccuentas.codigo</on>
                    </join>
                </from>
            </select>

            <select>
                ....

            </select>
        </union>
      </data>
      ....
  </report.page>
</report.document>
 

3.2.3 NATIVE SQL

Execute one or more native SQL statements.

Copy
<report.document name='report_doc' type='html' html-debug='false' html2fo-font-correction='3'>
  <report.page name='r_page' group='nivel1' margin-left='0.25' margin-right='0.25' margin-bottom='0.5' margin-top='0.5'>
      <data>
        <nativesql>
            SELECT ejerci, period, cuenta,
                   nombre, debe,   haber,
                   saldo
              FROM saldos,ccuentas
             WHERE saldos.cuenta = ccuentas.codigo
        </nativesql>
      </data>
      ....
  </report.page>
</report.document>
 

4 Header of the report

 

4.1 Document Tag

Define the <document> tag. Indicate a name, a type (html in this case), if you want to debug and a correction factor for the sources in fo.

Copy
<report.document name='report_doc' type='html' html-debug='false' html2fo-font-correction='3'>
 

4.2 Page Tag

Inside the <document> tag the <page> tag will be delicate, as attributes of this tag are give a name, one or more columns for which the page is to be broken (when it changes the contents of this column the system will write the following record in a new page) and the margins of the page.

Copy
<report.page name='r_page' group='nivel1' margin-left='0.25' margin-right='0.25' margin-bottom='0.5' margin-top='0.5'>

Within the <page> tag you start to define the components: first the data source where you could place a <select> tag. In this example it will be used the vtable that was defined above.

Copy
<data>
    <in>
        <rows />
    </in>
</data>
 

5 Adding Region Flow

Another thing that is needed to define a report is a region region.flow and within it, a <detail> area.

The region region.flow represents the body of the page and will be the one that will mark the flow of data.

The following example is the simplest case, only with a report.region.flow that contains only a detail.

Copy
<report.document name='report_doc' type='fo' html-debug='true' html2fo-font-correction='3'>
            <report.page name='r_page' group='ejerci' margin-left='0.25' margin-right='0.25' margin-bottom='0.5' margin-top='0.5'>
                <data>
                    <in>
                        <rows />
                    </in>
                </data>

                <body>
                    <report.region.flow name='detail' extent='0.0' >
                        <detail>
                            <column flow='true'>
                                <report.block>
                                    <report.table name='t_detail'>
                                        <head>
                                            <report.row>
                                                <report.column start='0' width='4'>
                                                    <static type='text'><string /></static>
                                                </report.column>
                                                <report.column start='4.25' width='1' style='font-family:sans-serif;font-size:8pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;'>
                                                    <static type='text'>Cuenta</static>
                                                </report.column>
                                                <report.column start='5.5' width='8' style='font-family:sans-serif;font-size:8pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;'>
                                                    <static type='text'>Nombre</static>
                                                </report.column>
                                                <report.column start='13.75' width='2' style='font-family:sans-serif;font-size:8pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Debe periodo </static>
                                                </report.column>
                                                <report.column start='16' width='2' style='font-family:sans-serif;font-size:8pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Haber periodo </static>
                                                </report.column>
                                                <report.column start='18.25' width='2' style='font-family:sans-serif;font-size:8pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Saldo</static>
                                                </report.column>
                                            </report.row>
                                        </head>
                                        <body>
                                        <report.row>
                                            <report.column start='0' width='4' >
                                                <static type='text'><string /></static>
                                            </report.column>
                                            <report.column start='4.25' width='1' style='font-family:sans-serif;font-size:7pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>cuenta</tupple>
                                            </report.column>
                                            <report.column start='5.5' width='8' style='font-family:sans-serif;font-size:7pt;text-align:left; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>nombre</tupple>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='13.75' width='2' style='font-family:sans-serif;font-size:7pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>debe</tupple>
                                                 <style match='#debe &lt; 0' value='color:#c67985;font-weight:bold;' />
                                                    <style match='#debe &gt;  0' value='color:#8493b3;font-weight:bold;' />
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='16' width='2' style='font-family:sans-serif;font-size:7pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>haber</tupple>
                                                 <style match='#haber &lt; 0' value='color:#c67985;font-weight:bold;' />
                                                    <style match='#haber &gt; 0' value='color:#8493b3;font-weight:bold;' />
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='18.25' width='2' style='font-family:sans-serif;font-size:7pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>saldo</tupple>
                                            </report.column>
                                        </report.row>
                                    </body>

                            </report.table>
                        </report.block>
                    </column>
                </detail>
            </report.region.flow>
        </body>
    </report.page>
</report.document>
 

5.1 Run

There are several ways to run an Axional Studio XSQL-Script. For now, the script will be executed from the system console:

  • From the command line of an application server Axional Studio. Using the file ws-dbscript (batch (.bat) on Windows platforms or shellscript (.sh) on Unix / Linux platforms), and specifying through the -file option, the path and name of the XML document that contains the Axional Studio XSQL-Script, execution can be carried out.

Assuming that the system has it in a Windows environment:

  • Connect to the Axional Studio machine.
  • Move to the directory where the system is located; in our example c: \ jas.


  • Create a text file in the same directory with the name report_doc.xml.
  • Paste the following code into this file:
Copy
<xsql-script name='report_doc'>

<body>

    <vtable name='rows'>
        <column name="ejerci" type='smallint' />
        <column name="period" type='char'  />
        <column name="cuenta" type='decimal'  />
        <column name="nombre" type='char' />
        <column name="debe"   type='decimal'  />
        <column name="haber"  type='decimal'  />
        <column name="saldo"  type='decimal'  />
    </vtable>

    <vtable.insert name='rows'>
        <matrix>
            {"2007", "Enero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "12345.45", "0", "12345.45"},
            {"2007", "Enero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "0", "346789.00", "346789.00"},
            {"2007", "Enero", "4751.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "5392.88", "0", "5392.88"},
            {"2007", "Enero", "4720.00000", "IVA SOPORTADO", "98734.00", "0", "0"},
            {"2007", "Enero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "0", "3445.670", "0"},
            {"2007", "Enero", "6000.00001", "COMPRAS LINEA ESQUI", "500.00", "5943.23", "0"},
            {"2007", "Enero", "6221.00000", "GASTOS FINANCIEROS", "288834.33", "0", "0"},
            {"2007", "Enero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "0", "12.34", "0"},

            {"2007", "Febrero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "9834.34", "399945.21", "0"},
            {"2007", "Febrero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "6634.34", "346789.00", "0"},
            {"2007", "Febrero", "4720.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "12.23", "2993.34", "0"},
            {"2007", "Febrero", "4751.00000", "IVA SOPORTADO", "2993.88", "0", "0"},
            {"2007", "Febrero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "2394.23", "3445.670", "0"},
            {"2007", "Febrero", "6000.00001", "COMPRAS LINEA ESQUI", "0", "5943.23", "0"},
            {"2007", "Febrero", "6221.00000", "GASTOS FINANCIEROS", "0", "39993.45", "0"},
            {"2007", "Febrero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "0", "233345.35", "0"},

            {"2007", "Marzo", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "0", "7374.34", "0"},
            {"2007", "Marzo", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "2834.45", "183774.00", "0"},
            {"2007", "Marzo", "4720.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "0", "233.45", "0"},
            {"2007", "Marzo", "4751.00000", "IVA SOPORTADO", "5392.88", "0", "0"},
            {"2007", "Marzo", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "0", "3445.670", "0"},
            {"2007", "Marzo", "6000.00001", "COMPRAS LINEA ESQUI", "500.00", "5943.23", "0"},
            {"2007", "Marzo", "6221.00000", "GASTOS FINANCIEROS", "2993.33", "23345.65", "0"},
            {"2007", "Marzo", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "129734", "33.34", "0"}

            {"2008", "Enero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "134.45", "0", "12345.45"},
            {"2008", "Enero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "233.345", "3489.00", "346789.00"},
            {"2008", "Enero", "4751.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "592.00", "3945", "5392.88"},
            {"2008", "Enero", "4720.00000", "IVA SOPORTADO", "98734.00", "23.45", "0"},
            {"2008", "Enero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "100.23", "345.670", "0"},
            {"2008", "Enero", "6000.00001", "COMPRAS LINEA ESQUI", "0.00", "1999234.23", "0"},
            {"2008", "Enero", "6221.00000", "GASTOS FINANCIEROS", "334.33", "2344", "23"},
            {"2008", "Enero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "292", "1234.34", "0"},
        </matrix>
    </vtable.insert>
    
    <file.bytes.write>
        <file name='reportdocs.dat' type='temp' />
        <report.document name='reportdocs' type='fo' html-debug='true' html2fo-font-correction='3'>
            <report.page name='r_page' group='ejerci' margin-left='0.25' margin-right='0.25' margin-bottom='0.5' margin-top='0.5'>
                <data>
                    <in>
                        <rows />
                    </in>
                </data>
                <body>
                    <report.region.flow name='detail' extent='0.0' >
                        <detail>
                            <column flow='true'>
                                <report.block>
                                    <report.table name='t_detail'>
                                        <head>
                                            <report.row>
                                                <report.column start='0' width='4'>
                                                    <static type='text'><string /></static>
                                                </report.column>
                                                <report.column start='4.25' width='1' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;'>
                                                    <static type='text'>Cuenta</static>
                                                </report.column>
                                                <report.column start='5.5' width='8' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;'>
                                                    <static type='text'>Nombre</static>
                                                </report.column>
                                                <report.column start='13.75' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Debe periodo </static>
                                                </report.column>
                                                <report.column start='16' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Haber periodo </static>
                                                </report.column>
                                                <report.column start='18.25' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Saldo</static>
                                                </report.column>
                                            </report.row>
                                        </head>
                                    <body>
                                        <report.row>
                                            <report.column start='0' width='4' >
                                                <static type='text'><string /></static>
                                            </report.column>
                                            <report.column start='4.25' width='1' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>cuenta</tupple>
                                            </report.column>
                                            <report.column start='5.5' width='8' style='font-family:sans-serif;font-size:10pt;text-align:left; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>nombre</tupple>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='13.75' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>debe</tupple>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='16' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>haber</tupple>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='18.25' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>saldo</tupple>
                                            </report.column>
                                        </report.row>
                                    </body>

                                </report.table>
                            </report.block>
                        </column>
                    </detail>
                </report.region.flow>
            </body>
        </report.page>
    </report.document>
 </file.bytes.write>

       <!-- 

            If the script is called from a command line then generates a file.
            If the script is called from a SQL Object then returns the content.    
         --> 


      <if>
            <expr><system.isBatch/></expr>
            <then>
                 <file.bytes.write>
                    <file name='reportdocs.pdf' type='absolute' />
                    <file.bytes.read>
                        <fop.transform type='pdf'>
                            <file name='reportdocs.dat' />
                        </fop.transform>
                    </file.bytes.read>
                </file.bytes.write>
            </then>

            <else>
                <return name='reportdocs' type='pdf'>
                    <file.bytes.read>
                        <fop.transform type='pdf'>
                            <file name='reportdocs.dat' />
                        </fop.transform>
                    </file.bytes.read>
                </return>
            </else>
        </if>                

</body>
</xsql-script>
  • Once the file is saved in the same directory, execute the script in the following way:
Copy
bin\ws-dbscript -file report_doc.xml

Note

With the -file parameter, the script that you want to execute is indicated.
  • The system will show the following message:
Copy
Running script................: report_doc
Rendering document report_doc html
flusing data
Done in 344 ms
Program returned..............: <void>
Execution completed...........: 0.546 secs.
C:\JAS>

Note

In the following sections, when referring to run, you will have to follow these steps.
  • The script generates a file report_doc.html in the directory where the script is running. If you open this file with a browser you will see the following:


As seen in the image, the system shows a table with the recovered records, and a header, which is written with the <head> tag inside the table.

 

5.2 Summary

  • Define the data source.
  • Define the document report.document.
  • Define the page report.page.
  • Associate the data source.
  • Declare a region report.region.flow.
  • Define a block report.block.
  • Define two rows, one head and the other body within the tag report.table.
 

6 Add title to report

 

6.1 Region before

If you want to add a title to the report, you will need to use the region <before>.

Copy
<before>
    <report.region.static name='before' extent='1.0'>
        <report.block>
            <report.table>
                <body>
                    <report.row name='h2'>
                        <report.column width='21'>
                            <static type='text'>BALANCE SUMAS Y SALDOS</static>
                        </report.column>
                    </report.row>
                </body>
            </report.table>
        </report.block>

    </report.region.static>
</before>
 

6.1.1 Run

Copy the complete code to the file report_doc.xml and execute.

Copy
<xsql-script name='report_doc'>

<body>

    <vtable name='rows'>
        <column name="ejerci" type='smallint' />
        <column name="period" type='char'  />
        <column name="cuenta" type='decimal'  />
        <column name="nombre" type='char' />
        <column name="debe"   type='decimal'  />
        <column name="haber"  type='decimal'  />
        <column name="saldo"  type='decimal'  />
    </vtable>

    <vtable.insert name='rows'>
        <matrix>
            {"2007", "Enero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "12345.45", "0", "12345.45"},
            {"2007", "Enero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "0", "346789.00", "346789.00"},
            {"2007", "Enero", "4751.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "5392.88", "0", "5392.88"},
            {"2007", "Enero", "4720.00000", "IVA SOPORTADO", "98734.00", "0", "0"},
            {"2007", "Enero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "0", "3445.670", "0"},
            {"2007", "Enero", "6000.00001", "COMPRAS LINEA ESQUI", "500.00", "5943.23", "0"},
            {"2007", "Enero", "6221.00000", "GASTOS FINANCIEROS", "288834.33", "0", "0"},
            {"2007", "Enero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "0", "12.34", "0"},

            {"2007", "Febrero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "9834.34", "399945.21", "0"},
            {"2007", "Febrero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "6634.34", "346789.00", "0"},
            {"2007", "Febrero", "4720.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "12.23", "2993.34", "0"},
            {"2007", "Febrero", "4751.00000", "IVA SOPORTADO", "2993.88", "0", "0"},
            {"2007", "Febrero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "2394.23", "3445.670", "0"},
            {"2007", "Febrero", "6000.00001", "COMPRAS LINEA ESQUI", "0", "5943.23", "0"},
            {"2007", "Febrero", "6221.00000", "GASTOS FINANCIEROS", "0", "39993.45", "0"},
            {"2007", "Febrero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "0", "233345.35", "0"},

            {"2007", "Marzo", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "0", "7374.34", "0"},
            {"2007", "Marzo", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "2834.45", "183774.00", "0"},
            {"2007", "Marzo", "4720.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "0", "233.45", "0"},
            {"2007", "Marzo", "4751.00000", "IVA SOPORTADO", "5392.88", "0", "0"},
            {"2007", "Marzo", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "0", "3445.670", "0"},
            {"2007", "Marzo", "6000.00001", "COMPRAS LINEA ESQUI", "500.00", "5943.23", "0"},
            {"2007", "Marzo", "6221.00000", "GASTOS FINANCIEROS", "2993.33", "23345.65", "0"},
            {"2007", "Marzo", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "129734", "33.34", "0"}

            {"2008", "Enero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "134.45", "0", "12345.45"},
            {"2008", "Enero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "233.345", "3489.00", "346789.00"},
            {"2008", "Enero", "4751.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "592.00", "3945", "5392.88"},
            {"2008", "Enero", "4720.00000", "IVA SOPORTADO", "98734.00", "23.45", "0"},
            {"2008", "Enero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "100.23", "345.670", "0"},
            {"2008", "Enero", "6000.00001", "COMPRAS LINEA ESQUI", "0.00", "1999234.23", "0"},
            {"2008", "Enero", "6221.00000", "GASTOS FINANCIEROS", "334.33", "2344", "23"},
            {"2008", "Enero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "292", "1234.34", "0"},
        </matrix>
    </vtable.insert>
    
    <file.bytes.write>
        <file name='reportdocs.dat' type='temp' />
        <report.document name='reportdocs' type='fo' html-debug='true' html2fo-font-correction='3'>
            <report.page name='r_page' group='ejerci' margin-left='0.25' margin-right='0.25' margin-bottom='0.5' margin-top='0.5'>
                <data>
                    <in>
                        <rows />
                    </in>
                </data>
                <before>
                    <report.region.static name='before' extent='1.0'>
                        <report.block>
                            <report.table>
                                <body>
                                    <report.row name='h2'>
                                        <report.column width='21'>
                                            <static type='text'>BALANCE SUMAS Y SALDOS</static>
                                        </report.column>
                                    </report.row>
                                </body>
                            </report.table>
                        </report.block>

                    </report.region.static>
                </before> 
                <body>
                    <report.region.flow name='detail' extent='0.0' >
                        <detail>
                            <column flow='true'>
                                <report.block>
                                    <report.table name='t_detail'>
                                        <head>
                                            <report.row>
                                                <report.column start='0' width='4'>
                                                    <static type='text'><string /></static>
                                                </report.column>
                                                <report.column start='4.25' width='1' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;'>
                                                    <static type='text'>Cuenta</static>
                                                </report.column>
                                                <report.column start='5.5' width='8' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;'>
                                                    <static type='text'>Nombre</static>
                                                </report.column>
                                                <report.column start='13.75' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Debe periodo </static>
                                                </report.column>
                                                <report.column start='16' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Haber periodo </static>
                                                </report.column>
                                                <report.column start='18.25' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Saldo</static>
                                                </report.column>
                                            </report.row>
                                        </head>
                                    <body>
                                        <report.row>
                                            <report.column start='0' width='4' >
                                                <static type='text'><string /></static>
                                            </report.column>
                                            <report.column start='4.25' width='1' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>cuenta</tupple>
                                            </report.column>
                                            <report.column start='5.5' width='8' style='font-family:sans-serif;font-size:10pt;text-align:left; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>nombre</tupple>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='13.75' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>debe</tupple>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='16' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>haber</tupple>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='18.25' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>saldo</tupple>
                                            </report.column>
                                        </report.row>
                                    </body>

                                </report.table>
                            </report.block>
                        </column>
                    </detail>
                </report.region.flow>
            </body>
        </report.page>
    </report.document>
 </file.bytes.write>

       <!-- 

            If the script is called from a command line then generates a file.
            If the script is called from a SQL Object then returns the content.    
         --> 


      <if>
            <expr><system.isBatch/></expr>
            <then>
                 <file.bytes.write>
                    <file name='reportdocs.pdf' type='absolute' />
                    <file.bytes.read>
                        <fop.transform type='pdf'>
                            <file name='reportdocs.dat' />
                        </fop.transform>
                    </file.bytes.read>
                </file.bytes.write>
            </then>

            <else>
                <return name='reportdocs' type='pdf'>
                    <file.bytes.read>
                        <fop.transform type='pdf'>
                            <file name='reportdocs.dat' />
                        </fop.transform>
                    </file.bytes.read>
                </return>
            </else>
        </if>                

</body>
</xsql-script>

To see the result, it is necessary to open the file report_doc.html with a browser:



 

6.2 Add styles to the title

Now styles will be added to the title. The styles allow to change the font, size, colors and alignment to texts.

To do this, in the region <before>, look for the column with the text BALANCE SUMAS Y SALDOS. Add the style attribute to the tag <column>, with a string that includes the style you want.

Some examples (the styles are the standard HTML styles):

font-family: Source
font-size: Size
padding-left: Spaces between the cell border (left) and the text.
padding-rigth: Spaces between the edge of the cell (right) and the text.
padding-top: Spaces between the edge of the cell (top) and the text.
padding-bottom: Spaces between the edge of the cell (bottom) and the text.
font-weight: Letter in bold.text-align: Alignment of text.
color: Color of the font.

Note

The style is a string composed of name of the style: value. To put several values they must be separated by semicolons.

 

6.2.1 Run

The complete code of the script is as follows, it is copied to our file report_doc.xml and it is executed.

Copy
<xsql-script name='report_doc'>

<body>

    <vtable name='rows'>
        <column name="ejerci" type='smallint' />
        <column name="period" type='char'  />
        <column name="cuenta" type='decimal'  />
        <column name="nombre" type='char' />
        <column name="debe"   type='decimal'  />
        <column name="haber"  type='decimal'  />
        <column name="saldo"  type='decimal'  />
    </vtable>

    <vtable.insert name='rows'>
        <matrix>
            {"2007", "Enero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "12345.45", "0", "12345.45"},
            {"2007", "Enero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "0", "346789.00", "346789.00"},
            {"2007", "Enero", "4751.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "5392.88", "0", "5392.88"},
            {"2007", "Enero", "4720.00000", "IVA SOPORTADO", "98734.00", "0", "0"},
            {"2007", "Enero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "0", "3445.670", "0"},
            {"2007", "Enero", "6000.00001", "COMPRAS LINEA ESQUI", "500.00", "5943.23", "0"},
            {"2007", "Enero", "6221.00000", "GASTOS FINANCIEROS", "288834.33", "0", "0"},
            {"2007", "Enero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "0", "12.34", "0"},

            {"2007", "Febrero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "9834.34", "399945.21", "0"},
            {"2007", "Febrero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "6634.34", "346789.00", "0"},
            {"2007", "Febrero", "4720.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "12.23", "2993.34", "0"},
            {"2007", "Febrero", "4751.00000", "IVA SOPORTADO", "2993.88", "0", "0"},
            {"2007", "Febrero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "2394.23", "3445.670", "0"},
            {"2007", "Febrero", "6000.00001", "COMPRAS LINEA ESQUI", "0", "5943.23", "0"},
            {"2007", "Febrero", "6221.00000", "GASTOS FINANCIEROS", "0", "39993.45", "0"},
            {"2007", "Febrero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "0", "233345.35", "0"},

            {"2007", "Marzo", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "0", "7374.34", "0"},
            {"2007", "Marzo", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "2834.45", "183774.00", "0"},
            {"2007", "Marzo", "4720.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "0", "233.45", "0"},
            {"2007", "Marzo", "4751.00000", "IVA SOPORTADO", "5392.88", "0", "0"},
            {"2007", "Marzo", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "0", "3445.670", "0"},
            {"2007", "Marzo", "6000.00001", "COMPRAS LINEA ESQUI", "500.00", "5943.23", "0"},
            {"2007", "Marzo", "6221.00000", "GASTOS FINANCIEROS", "2993.33", "23345.65", "0"},
            {"2007", "Marzo", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "129734", "33.34", "0"}

            {"2008", "Enero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "134.45", "0", "12345.45"},
            {"2008", "Enero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "233.345", "3489.00", "346789.00"},
            {"2008", "Enero", "4751.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "592.00", "3945", "5392.88"},
            {"2008", "Enero", "4720.00000", "IVA SOPORTADO", "98734.00", "23.45", "0"},
            {"2008", "Enero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "100.23", "345.670", "0"},
            {"2008", "Enero", "6000.00001", "COMPRAS LINEA ESQUI", "0.00", "1999234.23", "0"},
            {"2008", "Enero", "6221.00000", "GASTOS FINANCIEROS", "334.33", "2344", "23"},
            {"2008", "Enero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "292", "1234.34", "0"},
        </matrix>
    </vtable.insert>
    
    <file.bytes.write>
        <file name='reportdocs.dat' type='temp' />
        <report.document name='reportdocs' type='fo' html-debug='true' html2fo-font-correction='3'>
            <report.page name='r_page' group='ejerci' margin-left='0.25' margin-right='0.25' margin-bottom='0.5' margin-top='0.5'>
                <data>
                    <in>
                        <rows />
                    </in>
                </data>
                <before>
                    <report.region.static name='before' extent='1.0'>
                        <report.block>
                            <report.table>
                                <body>
                                    <report.row name='h2'>
                                        <report.column width='21' style='font-family:sans-serif;font-size:9px;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold;text-align:left;'>
                                            <static type='text'>BALANCE SUMAS Y SALDOS</static>
                                        </report.column>
                                    </report.row>
                                </body>
                            </report.table>
                        </report.block>

                    </report.region.static>
                </before> 
                <body>
                    <report.region.flow name='detail' extent='0.0' >
                        <detail>
                            <column flow='true'>
                                <report.block>
                                    <report.table name='t_detail'>
                                        <head>
                                            <report.row>
                                                <report.column start='0' width='4'>
                                                    <static type='text'><string /></static>
                                                </report.column>
                                                <report.column start='4.25' width='1' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;'>
                                                    <static type='text'>Cuenta</static>
                                                </report.column>
                                                <report.column start='5.5' width='8' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;'>
                                                    <static type='text'>Nombre</static>
                                                </report.column>
                                                <report.column start='13.75' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Debe periodo </static>
                                                </report.column>
                                                <report.column start='16' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Haber periodo </static>
                                                </report.column>
                                                <report.column start='18.25' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Saldo</static>
                                                </report.column>
                                            </report.row>
                                        </head>
                                    <body>
                                        <report.row>
                                            <report.column start='0' width='4' >
                                                <static type='text'><string /></static>
                                            </report.column>
                                            <report.column start='4.25' width='1' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>cuenta</tupple>
                                            </report.column>
                                            <report.column start='5.5' width='8' style='font-family:sans-serif;font-size:10pt;text-align:left; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>nombre</tupple>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='13.75' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>debe</tupple>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='16' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>haber</tupple>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='18.25' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>saldo</tupple>
                                            </report.column>
                                        </report.row>
                                    </body>

                                </report.table>
                            </report.block>
                        </column>
                    </detail>
                </report.region.flow>
            </body>
        </report.page>
    </report.document>
 </file.bytes.write>

       <!-- 

            If the script is called from a command line then generates a file.
            If the script is called from a SQL Object then returns the content.    
         --> 


      <if>
            <expr><system.isBatch/></expr>
            <then>
                 <file.bytes.write>
                    <file name='reportdocs.pdf' type='absolute' />
                    <file.bytes.read>
                        <fop.transform type='pdf'>
                            <file name='reportdocs.dat' />
                        </fop.transform>
                    </file.bytes.read>
                </file.bytes.write>
            </then>

            <else>
                <return name='reportdocs' type='pdf'>
                    <file.bytes.read>
                        <fop.transform type='pdf'>
                            <file name='reportdocs.dat' />
                        </fop.transform>
                    </file.bytes.read>
                </return>
            </else>
        </if>                

</body>
</xsql-script>

To see the edited result, open the file report_doc.html with a browser:



 

6.3 Summary

  • Define the data source.
  • Define the document report.document.
  • Define the page report.page.
  • Associate the data source.
  • Declare a static region before.
  • Declare to the region a block, table, row .
  • Define a column report.column and inside a static text.
  • Define styles to this text through the style attribute.
  • Declare a region report.region.flow .
  • Define a block report.block.
  • Define two rows one head and the other body inside the tag report.table
 

7 Add groups

Through the groups, records that have values of certain columns in common can be grouped. You can also draw blocks for when a group starts and when it ends.

 

7.1 Define the group exercise

Add a group to the year accounting exercise (Ejercicio) within the report.region.flow:

  • Define a <before> region with one or more blocks.
Copy
<before>
 <report.block>
        <report.table>
            <body>
                <report.row>
                    <report.column start='0' width='1' style='font-family:sans-serif;font-size:10pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold;text-align:left;height:5px;'>
                        <static type='text'>Ejercicio</static>
                    </report.column>
                    <report.column start='1.25' width='20' style='font-family:sans-serif;font-size:10pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold; text-align:left;height:5px;'>
                        <tupple type='text'>ejerci</tupple>
                    </report.column>
                </report.row>
            </body>
        </report.table>
    </report.block>
</before>

Each of these blocks represents the area to be drawn when the group is started.

  • Define a <detail> section that will contain the n homogeneous records.
Copy
<detail>
    <column flow='true'>
        <report.block>
            <report.table name='t_detail'>
                <head>
                    <report.row>
                        <report.column start='0' width='4'>
                            <static type='text'><string /></static>
                        </report.column>
                        <report.column start='4.25' width='1' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;'>
                            <static type='text'>Cuenta</static>
                        </report.column>
                        <report.column start='5.5' width='8' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;'>
                            <static type='text'>Nombre</static>
                        </report.column>
                        <report.column start='13.75' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                            <static type='text'>Debe periodo </static>
                        </report.column>
                        <report.column start='16' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                            <static type='text'>Haber periodo </static>
                        </report.column>
                        <report.column start='18.25' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                            <static type='text'>Saldo</static>
                        </report.column>
                    </report.row>
                </head>
            <body>
                <report.row>
                    <report.column start='0' width='4' >
                        <static type='text'><string /></static>
                    </report.column>
                    <report.column start='4.25' width='1' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                        <tupple type='text'>cuenta</tupple>
                    </report.column>
                    <report.column start='5.5' width='8' style='font-family:sans-serif;font-size:10pt;text-align:left; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                        <tupple type='text'>nombre</tupple>
                    </report.column>
                    <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='13.75' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                        <tupple type='text'>debe</tupple>
                    </report.column>
                    <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='16' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                        <tupple type='text'>haber</tupple>
                    </report.column>
                    <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='18.25' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                        <tupple type='text'>saldo</tupple>
                    </report.column>
                </report.row>
            </body>

        </report.table>
    </report.block>
</column>
</detail>
  • Define an <after> region with n report.block (symmetric to blocks before).
    Each of these blocks represents the area to be drawn when the group is finished.
Copy
<after>
    <null />
</after>
 

7.1.1 Run

Copy the following code in the file report_doc.xml and execute it.

Copy
<xsql-script name='report_doc'>

<body>

    <vtable name='rows'>
        <column name="ejerci" type='smallint' />
        <column name="period" type='char'  />
        <column name="cuenta" type='decimal'  />
        <column name="nombre" type='char' />
        <column name="debe"   type='decimal'  />
        <column name="haber"  type='decimal'  />
        <column name="saldo"  type='decimal'  />
    </vtable>

    <vtable.insert name='rows'>
        <matrix>
            {"2007", "Enero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "12345.45", "0", "12345.45"},
            {"2007", "Enero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "0", "346789.00", "346789.00"},
            {"2007", "Enero", "4751.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "5392.88", "0", "5392.88"},
            {"2007", "Enero", "4720.00000", "IVA SOPORTADO", "98734.00", "0", "0"},
            {"2007", "Enero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "0", "3445.670", "0"},
            {"2007", "Enero", "6000.00001", "COMPRAS LINEA ESQUI", "500.00", "5943.23", "0"},
            {"2007", "Enero", "6221.00000", "GASTOS FINANCIEROS", "288834.33", "0", "0"},
            {"2007", "Enero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "0", "12.34", "0"},

            {"2007", "Febrero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "9834.34", "399945.21", "0"},
            {"2007", "Febrero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "6634.34", "346789.00", "0"},
            {"2007", "Febrero", "4720.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "12.23", "2993.34", "0"},
            {"2007", "Febrero", "4751.00000", "IVA SOPORTADO", "2993.88", "0", "0"},
            {"2007", "Febrero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "2394.23", "3445.670", "0"},
            {"2007", "Febrero", "6000.00001", "COMPRAS LINEA ESQUI", "0", "5943.23", "0"},
            {"2007", "Febrero", "6221.00000", "GASTOS FINANCIEROS", "0", "39993.45", "0"},
            {"2007", "Febrero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "0", "233345.35", "0"},

            {"2007", "Marzo", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "0", "7374.34", "0"},
            {"2007", "Marzo", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "2834.45", "183774.00", "0"},
            {"2007", "Marzo", "4720.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "0", "233.45", "0"},
            {"2007", "Marzo", "4751.00000", "IVA SOPORTADO", "5392.88", "0", "0"},
            {"2007", "Marzo", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "0", "3445.670", "0"},
            {"2007", "Marzo", "6000.00001", "COMPRAS LINEA ESQUI", "500.00", "5943.23", "0"},
            {"2007", "Marzo", "6221.00000", "GASTOS FINANCIEROS", "2993.33", "23345.65", "0"},
            {"2007", "Marzo", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "129734", "33.34", "0"}

            {"2008", "Enero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "134.45", "0", "12345.45"},
            {"2008", "Enero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "233.345", "3489.00", "346789.00"},
            {"2008", "Enero", "4751.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "592.00", "3945", "5392.88"},
            {"2008", "Enero", "4720.00000", "IVA SOPORTADO", "98734.00", "23.45", "0"},
            {"2008", "Enero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "100.23", "345.670", "0"},
            {"2008", "Enero", "6000.00001", "COMPRAS LINEA ESQUI", "0.00", "1999234.23", "0"},
            {"2008", "Enero", "6221.00000", "GASTOS FINANCIEROS", "334.33", "2344", "23"},
            {"2008", "Enero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "292", "1234.34", "0"},
        </matrix>
    </vtable.insert>
    
    <file.bytes.write>
        <file name='reportdocs.dat' type='temp' />
        <report.document name='reportdocs' type='fo' html-debug='true' html2fo-font-correction='3'>
            <report.page name='r_page' group='ejerci' margin-left='0.25' margin-right='0.25' margin-bottom='0.5' margin-top='0.5'>
                <data>
                    <in>
                        <rows />
                    </in>
                </data>
                <before>
                    <report.region.static name='before' extent='1.0'>
                        <report.block>
                            <report.table>
                                <body>
                                    <report.row name='h2'>
                                        <report.column width='21' style='color:blue; font-family:sans-serif;font-size:14px;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px; font-weight:bold;text-align:left;'>
                                            <static type='text'>BALANCE SUMAS Y SALDOS</static>
                                        </report.column>
                                    </report.row>
                                </body>
                            </report.table>
                        </report.block>

                    </report.region.static>
                </before> 
                <body>
                    <report.region.flow name='detail' extent='0.0' >
                        <before>
                             <report.block>
                                    <report.table>
                                        <body>
                                            <report.row>
                                                <report.column start='0' width='1' style='font-family:sans-serif;font-size:10pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold;text-align:left;height:5px;'>
                                                    <static type='text'>Ejercicio</static>
                                                </report.column>
                                                <report.column start='1.25' width='20' style='font-family:sans-serif;font-size:10pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold; text-align:left;height:5px;'>
                                                    <tupple type='text'>ejerci</tupple>
                                                </report.column>
                                            </report.row>
                                        </body>
                                    </report.table>
                                </report.block>
                            </before>
                        <detail>
                            <column flow='true'>
                                <report.block>
                                    <report.table name='t_detail'>
                                        <head>
                                            <report.row>
                                                <report.column start='0' width='4'>
                                                    <static type='text'><string /></static>
                                                </report.column>
                                                <report.column start='4.25' width='1' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;'>
                                                    <static type='text'>Cuenta</static>
                                                </report.column>
                                                <report.column start='5.5' width='8' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;'>
                                                    <static type='text'>Nombre</static>
                                                </report.column>
                                                <report.column start='13.75' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Debe periodo </static>
                                                </report.column>
                                                <report.column start='16' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Haber periodo </static>
                                                </report.column>
                                                <report.column start='18.25' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Saldo</static>
                                                </report.column>
                                            </report.row>
                                        </head>
                                    <body>
                                        <report.row>
                                            <report.column start='0' width='4' >
                                                <static type='text'><string /></static>
                                            </report.column>
                                            <report.column start='4.25' width='1' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>cuenta</tupple>
                                            </report.column>
                                            <report.column start='5.5' width='8' style='font-family:sans-serif;font-size:10pt;text-align:left; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>nombre</tupple>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='13.75' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>debe</tupple>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='16' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>haber</tupple>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='18.25' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>saldo</tupple>
                                            </report.column>
                                        </report.row>
                                    </body>

                                </report.table>
                            </report.block>
                        </column>
                    </detail>
                    <after>
                        <null />
                    </after> 
                </report.region.flow>
            </body>
        </report.page>
    </report.document>
 </file.bytes.write>

       <!-- 

            If the script is called from a command line then generates a file.
            If the script is called from a SQL Object then returns the content.    
         --> 


      <if>
            <expr><system.isBatch/></expr>
            <then>
                 <file.bytes.write>
                    <file name='reportdocs.pdf' type='absolute' />
                    <file.bytes.read>
                        <fop.transform type='pdf'>
                            <file name='reportdocs.dat' />
                        </fop.transform>
                    </file.bytes.read>
                </file.bytes.write>
            </then>

            <else>
                <return name='reportdocs' type='pdf'>
                    <file.bytes.read>
                        <fop.transform type='pdf'>
                            <file name='reportdocs.dat' />
                        </fop.transform>
                    </file.bytes.read>
                </return>
            </else>
        </if>                

</body>
</xsql-script>

To see the result, open the report_doc.html file with a browser:



As seen in the image, the system places a header Ejercicio 2007, Ejercicio 2008, etc... above each group.

Note

The <after> and <before> regions must be symmetric, they must have the same block quantities. For example, as in this case, you can place the after or the before to null.

 

7.2 Add the period group

You can put as many groups as you want. The order in which the blocks are put will determine which group breaks first, second, etc. We must also bear in mind that the groups must be closed symmetrically opposed to the opening. That is, if the first group that opens is the year accounting exercise and later the month accounting period, first you have to put the <after> period and later the <after> exercise. This way, another group will be added within the exercise: the period.

Here we can find the region <before> with the two blocks, one for the year acconting exercise and another for the month accounting period.

Copy
<before>
 <report.block>
        <report.table>
            <body>
                <report.row>
                    <report.column start='0' width='1' style='font-family:sans-serif;font-size:10pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold;text-align:left;height:5px;'>
                        <static type='text'>Ejercicio</static>
                    </report.column>
                    <report.column start='1.25' width='20' style='font-family:sans-serif;font-size:10pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold; text-align:left;height:5px;'>
                        <tupple type='text'>ejerci</tupple>
                    </report.column>
                </report.row>
            </body>
        </report.table>
    </report.block>
    <report.block>
        <report.table>
            <body>
                <report.row>
                    <report.column start='1' width='1' style='font-family:sans-serif;font-size:9pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold;text-align:left;'>
                        <static type='text'>Mes:</static>
                    </report.column>
                    <report.column start='2' width='19' style='font-family:sans-serif;font-size:10pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold;text-align:left;'>
                        <tupple type='text'>period</tupple>
                    </report.column>
                </report.row>
            </body>
        </report.table>
    </report.block>
</before>

The region <after> with the two blocks:

Copy
<after>
    <null />
    <null />
</after>

Save the code in the file report_doc.xml and execute it.

To see the result, open the report_doc.html file with a browser.



 

7.3 Add group totals

In the following example we are going to add totals to these groups. In the previous examples, in the after regions blocks >nulls have been placed. But now these regions will be used to draw totals.

Aggregation functions will be used to add totals.

Copy
<after>
<null />
<report.block>
        <report.table>
            <body>
                <report.row>
                    <report.column start='0' width='8' >
                        <static type='text'><string /></static>
                    </report.column>
                    <report.column start='8' width='1' style='font-family:sans-serif;font-size:10pt; font-weight:bold; text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px; height:5px;'>
                        <static type='text'>Total</static>
                    </report.column>
                    <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='9' width='4.50' style='font-family:sans-serif;font-size:10pt; font-weight:bold; text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px; height:5px;'>
                        <static type='text'><string /></static>
                    </report.column>
                    <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='13.75' width='2' style='font-family:sans-serif;font-size:10pt; font-weight:bold; text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px; height:5px;'>
                        <aggregate type='text'>sum(debe)</aggregate>
                    </report.column>
                    <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='16' width='2' style='font-family:sans-serif;font-size:10pt; font-weight:bold; text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px; height:5px;'>
                        <aggregate type='text'>sum(haber)</aggregate>
                    </report.column>
                    <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='18.25' width='2' style='font-family:sans-serif;font-size:10pt; font-weight:bold; text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px; height:5px;'>
                        <aggregate type='text'>sum(saldo)</aggregate>
                        <!-- <static type='text'><string /></static> -->
                    </report.column>
                </report.row>
            </body>
        </report.table>
    </report.block>
</after>

Note

The closure of the blocks in the after regions are inverses to how they open in before. In this case the total is being placed in the second block so it is referring to the closure of the group period.

With the tag aggregate it is indicated that you want to place an aggregation function. The possible functions that can be used are:

sum: Sum columns of the group.
count: Count group records.
avg: Average of the values.
max: Maximum value of the group.
min: Minimum value of the group.

The use of the function is indistinct according to the place where it will be used. The system detects in which group it is being used and shows the aggregation of that group.

 

8 Add styles

Now we will give style to the columns, titles, sections, etc. To do this, a style attribute will be placed in the column tag.

Copy
<xsql-script name='report_doc'>

<body>

    <vtable name='rows'>
        <column name="ejerci" type='smallint' />
        <column name="period" type='char'  />
        <column name="cuenta" type='decimal'  />
        <column name="nombre" type='char' />
        <column name="debe"   type='decimal'  />
        <column name="haber"  type='decimal'  />
        <column name="saldo"  type='decimal'  />
    </vtable>

    <vtable.insert name='rows'>
        <matrix>
            {"2007", "Enero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "12345.45", "0", "12345.45"},
            {"2007", "Enero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "0", "346789.00", "346789.00"},
            {"2007", "Enero", "4751.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "5392.88", "0", "5392.88"},
            {"2007", "Enero", "4720.00000", "IVA SOPORTADO", "98734.00", "0", "0"},
            {"2007", "Enero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "0", "3445.670", "0"},
            {"2007", "Enero", "6000.00001", "COMPRAS LINEA ESQUI", "500.00", "5943.23", "0"},
            {"2007", "Enero", "6221.00000", "GASTOS FINANCIEROS", "288834.33", "0", "0"},
            {"2007", "Enero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "0", "12.34", "0"},

            {"2007", "Febrero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "9834.34", "399945.21", "0"},
            {"2007", "Febrero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "6634.34", "346789.00", "0"},
            {"2007", "Febrero", "4720.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "12.23", "2993.34", "0"},
            {"2007", "Febrero", "4751.00000", "IVA SOPORTADO", "2993.88", "0", "0"},
            {"2007", "Febrero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "2394.23", "3445.670", "0"},
            {"2007", "Febrero", "6000.00001", "COMPRAS LINEA ESQUI", "0", "5943.23", "0"},
            {"2007", "Febrero", "6221.00000", "GASTOS FINANCIEROS", "0", "39993.45", "0"},
            {"2007", "Febrero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "0", "233345.35", "0"},

            {"2007", "Marzo", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "0", "7374.34", "0"},
            {"2007", "Marzo", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "2834.45", "183774.00", "0"},
            {"2007", "Marzo", "4720.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "0", "233.45", "0"},
            {"2007", "Marzo", "4751.00000", "IVA SOPORTADO", "5392.88", "0", "0"},
            {"2007", "Marzo", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "0", "3445.670", "0"},
            {"2007", "Marzo", "6000.00001", "COMPRAS LINEA ESQUI", "500.00", "5943.23", "0"},
            {"2007", "Marzo", "6221.00000", "GASTOS FINANCIEROS", "2993.33", "23345.65", "0"},
            {"2007", "Marzo", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "129734", "33.34", "0"}

            {"2008", "Enero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "134.45", "0", "12345.45"},
            {"2008", "Enero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "233.345", "3489.00", "346789.00"},
            {"2008", "Enero", "4751.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "592.00", "3945", "5392.88"},
            {"2008", "Enero", "4720.00000", "IVA SOPORTADO", "98734.00", "23.45", "0"},
            {"2008", "Enero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "100.23", "345.670", "0"},
            {"2008", "Enero", "6000.00001", "COMPRAS LINEA ESQUI", "0.00", "1999234.23", "0"},
            {"2008", "Enero", "6221.00000", "GASTOS FINANCIEROS", "334.33", "2344", "23"},
            {"2008", "Enero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "292", "1234.34", "0"},
        </matrix>
    </vtable.insert>
    
    <file.bytes.write>
        <file name='reportdocs.dat' type='temp' />
        <report.document name='reportdocs' type='fo' html-debug='true' html2fo-font-correction='3'>
            <report.page name='r_page' group='ejerci' margin-left='0.25' margin-right='0.25' margin-bottom='0.5' margin-top='0.5'>
                <data>
                    <in>
                        <rows />
                    </in>
                </data>
                <before>
                    <report.region.static name='before' extent='1.0'>
                        <report.block>
                            <report.table>
                                <body>
                                    <report.row name='h2'>
                                        <report.column width='21' style='color:blue; font-family:sans-serif;font-size:14px;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px; font-weight:bold;text-align:left;'>
                                            <static type='text'>BALANCE SUMAS Y SALDOS</static>
                                        </report.column>
                                    </report.row>
                                </body>
                            </report.table>
                        </report.block>

                    </report.region.static>
                </before> 
                <body>
                    <report.region.flow name='detail' extent='0.0' >
                        <before>
                             <report.block>
                                    <report.table>
                                        <body>
                                            <report.row>
                                                <report.column start='0' width='1' style='font-family:sans-serif;font-size:10pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold;text-align:left;height:5px;'>
                                                    <static type='text'>Ejercicio</static>
                                                </report.column>
                                                <report.column start='1.25' width='20' style='font-family:sans-serif;font-size:10pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold; text-align:left;height:5px;'>
                                                    <tupple type='text'>ejerci</tupple>
                                                </report.column>
                                            </report.row>
                                        </body>
                                    </report.table>
                                </report.block>
                                <report.block>
                                    <report.table>
                                        <body>
                                            <report.row>
                                                <report.column start='1' width='1' style='font-family:sans-serif;font-size:9pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold;text-align:left;'>
                                                    <static type='text'>Mes:</static>
                                                </report.column>
                                                <report.column start='2' width='19' style='font-family:sans-serif;font-size:10pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold;text-align:left;'>
                                                    <tupple type='text'>period</tupple>
                                                </report.column>
                                            </report.row>
                                        </body>
                                    </report.table>
                                </report.block>
                            </before>
                        <detail>
                            <column flow='true'>
                                <report.block>
                                    <report.table name='t_detail'>
                                        <head>
                                            <report.row>
                                                <report.column start='0' width='4'>
                                                    <static type='text'><string /></static>
                                                </report.column>
                                                <report.column start='4.25' width='1' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;'>
                                                    <static type='text'>Cuenta</static>
                                                </report.column>
                                                <report.column start='5.5' width='8' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;'>
                                                    <static type='text'>Nombre</static>
                                                </report.column>
                                                <report.column start='13.75' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Debe periodo </static>
                                                </report.column>
                                                <report.column start='16' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Haber periodo </static>
                                                </report.column>
                                                <report.column start='18.25' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Saldo</static>
                                                </report.column>
                                            </report.row>
                                        </head>
                                    <body>
                                        <report.row>
                                            <report.column start='0' width='4' >
                                                <static type='text'><string /></static>
                                            </report.column>
                                            <report.column start='4.25' width='1' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>cuenta</tupple>
                                            </report.column>
                                            <report.column start='5.5' width='8' style='font-family:sans-serif;font-size:10pt;text-align:left; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>nombre</tupple>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='13.75' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>debe</tupple>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='16' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>haber</tupple>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='18.25' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>saldo</tupple>
                                            </report.column>
                                        </report.row>
                                    </body>

                                </report.table>
                            </report.block>
                        </column>
                    </detail>
                    <after>
                        <null />
                        <report.block>
                                <report.table>
                                    <body>
                                        <report.row>
                                            <report.column start='0' width='8' >
                                                <static type='text'><string /></static>
                                            </report.column>
                                            <report.column start='8' width='1' style='font-family:sans-serif;font-size:10pt; font-weight:bold; text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px; height:5px;'>
                                                <static type='text'>Total</static>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='9' width='4.50' style='font-family:sans-serif;font-size:10pt; font-weight:bold; text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px; height:5px;'>
                                                <static type='text'><string /></static>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='13.75' width='2' style='font-family:sans-serif;font-size:10pt; font-weight:bold; text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px; height:5px;'>
                                                <aggregate type='text'>sum(debe)</aggregate>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='16' width='2' style='font-family:sans-serif;font-size:10pt; font-weight:bold; text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px; height:5px;'>
                                                <aggregate type='text'>sum(haber)</aggregate>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='18.25' width='2' style='font-family:sans-serif;font-size:10pt; font-weight:bold; text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px; height:5px;'>
                                                <aggregate type='text'>sum(saldo)</aggregate>
                                                <!-- <static type='text'><string /></static> -->
                                            </report.column>
                                        </report.row>
                                    </body>
                                </report.table>
                            </report.block>
                        </after> 
                </report.region.flow>
            </body>
        </report.page>
    </report.document>
 </file.bytes.write>

       <!-- 

            If the script is called from a command line then generates a file.
            If the script is called from a SQL Object then returns the content.    
         --> 


      <if>
            <expr><system.isBatch/></expr>
            <then>
                 <file.bytes.write>
                    <file name='reportdocs.pdf' type='absolute' />
                    <file.bytes.read>
                        <fop.transform type='pdf'>
                            <file name='reportdocs.dat' />
                        </fop.transform>
                    </file.bytes.read>
                </file.bytes.write>
            </then>

            <else>
                <return name='reportdocs' type='pdf'>
                    <file.bytes.read>
                        <fop.transform type='pdf'>
                            <file name='reportdocs.dat' />
                        </fop.transform>
                    </file.bytes.read>
                </return>
            </else>
        </if>                

</body>
</xsql-script>


 

9 Attributes to columns

The possible atrributes that can be used are:

start: Start position of the column (in cm).
width: Width of the column (in cm).
colspan: Number of columns that you want to expand this column.
rowspan: Number of rows that you want to expand this row.
maximumfractiondigits: Maximum number of decimal digits that must be used to represent the number.
minimumfractiondigits: Minimum number of decimal digits that must be used to represent the number.
Copy
<report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='14' width='2' style='background-color: \#F7F7F7;font-family:sans-serif;font-size:9px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;color:black;'>
    <tupple type='text'>debe</tupple>
</report.column>
 

10 Dynamic styles

You can also give dinamical styles to the columns. For example, modify the colour of numerical values to red if it is negative.

Copy
<report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='14' width='2' style='background-color: \#F7F7F7;font-family:sans-serif;font-size:9px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;color:black;'>
    <tupple type='text'>debe</tupple>
    <style match='#debe < 0' value='color:red;' />
</report.column>

If the content of the column #debe is less than zero, the column adds the style color:red;

You can use the column #name to reference values from the current tuple.

 

11 Links to other documents

You can also place a link on a column. For this use the <link> tag.

The links are placed inside a column tag and the following attributes can be reported:

  • code: code of the object that you want to open
  • cond: condition of the relation between both objects.
    The string that is reported in the system will add it to the where clause of the target object.
    The #cuenta of the example will be replaced by the system by the value of the account column in the tuple being processed. For this reason you can refer to any column of the flow with #.
    You can also build complex conditions, for example cdiarios.cuenta=#cuenta AND cdiarios.fecha=TODAY.
  • target: _blank indicates that the new screen will open in a new window.
Copy
<report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='14' width='2' style='background-color: \#F7F7F7;font-family:sans-serif;font-size:9px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;color:black;'>
    <link code='capuntes_comp' cond="capuntes.cuenta=#cuenta" target='_blank'></link>
</report.column>

If the destination object had variables, the link tag would be as follows:

Copy
<report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='14' width='2' style='background-color: \#F7F7F7;font-family:sans-serif;font-size:9px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;color:black;'>
    <link code='capuntes_comp' cond="capuntes.cuenta=#cuenta" target='_blank'>
        <vars>
            <var name='EJERCI'>#ejerci</var>
            <var name='PERIOD'>#period</var>
        </vars>
    </link>
</report.column>

Note

When a link is placed to execute the script from the console, the system will request DBMS and user to be informed.

Example:

Copy
bin/ws-dbscript -dbms demo_formacion -file report_doc.xml -user mlg
  • dbms: name of the application / Database.
  • file: file that contains the script.
  • user: user with permissions on the application.
 

12 Function calls

Sometimes the value to show in a column is complex and requires calculations. Within the repport.column you can make a call to a local function within the script.

 

12.1 Add percentage calculation

For example, the percentage calculation between debit and credit can be performed as a local function in the script.

Copy
<function name='local_getpor'>
    <args>
        <arg name='p_data1' type='decimal' />
        <arg name='p_data2' type='decimal' />
    </args>

    <body>

        <if>
            <expr><eq><p_data1 />0</eq></expr>
            <then>
                <return>100.00</return>
            </then>
            <else>
                <return><mul><div><p_data2 /><p_data1 /></div>100</mul></return>
            </else>
        </if>

    </body>
</function>

This function local_getport obtains two parameters (debit and credit) and returns the percentage. Make the call inside the tag report.column. A column with the percentage in detail is added.

Copy
<report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='18' width='2' style='background-color: \#F7F7F7;font-family:sans-serif;font-size:9px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;'>
    <function name='local_getpor' >
        <args>
            <arg name='data1'>#debe</arg>
            <arg name='data2'>#haber</arg>
        </args>
    </function>
</report.column>
 

13 Finished example

See the complete example here below:

Copy
<xsql-script name='report_doc'>

<body>
    <function name='local_getpor'>
        <args>
            <arg name='p_data1' type='decimal' />
            <arg name='p_data2' type='decimal' />
        </args>

        <body>

            <if>
                <expr><eq><p_data1 />0</eq></expr>
                <then>
                    <return>100.00</return>
                </then>
                <else>
                    <return><mul><div><p_data2 /><p_data1 /></div>100</mul></return>
                </else>
            </if>

        </body>
    </function>

    <vtable name='rows'>
        <column name="ejerci" type='smallint' />
        <column name="period" type='char'  />
        <column name="cuenta" type='decimal'  />
        <column name="nombre" type='char' />
        <column name="debe"   type='decimal'  />
        <column name="haber"  type='decimal'  />
        <column name="saldo"  type='decimal'  />
    </vtable>

    <vtable.insert name='rows'>
        <matrix>
            {"2007", "Enero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "-12345.45", "0", "12345.45"},
            {"2007", "Enero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "0", "346789.00", "346789.00"},
            {"2007", "Enero", "4751.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "5392.88", "0", "5392.88"},
            {"2007", "Enero", "4720.00000", "IVA SOPORTADO", "-98734.00", "0", "0"},
            {"2007", "Enero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "0", "-3445.670", "-18"},
            {"2007", "Enero", "6000.00001", "COMPRAS LINEA ESQUI", "500.00", "5943.23", "0"},
            {"2007", "Enero", "6221.00000", "GASTOS FINANCIEROS", "288834.33", "0", "-55"},
            {"2007", "Enero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "0", "-12.34", "0"},

            {"2007", "Febrero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "9834.34", "399945.21", "-27"},
            {"2007", "Febrero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "6634.34", "346789.00", "0"},
            {"2007", "Febrero", "4720.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "12.23", "-2993.34", "0"},
            {"2007", "Febrero", "4751.00000", "IVA SOPORTADO", "2993.88", "0", "0"},
            {"2007", "Febrero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "2394.23", "3445.670", "0"},
            {"2007", "Febrero", "6000.00001", "COMPRAS LINEA ESQUI", "-25", "5943.23", "0"},
            {"2007", "Febrero", "6221.00000", "GASTOS FINANCIEROS", "0", "-39993.45", "-30"},
            {"2007", "Febrero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "0", "-233345.35", "0"},

            {"2007", "Marzo", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "0", "7374.34", "0"},
            {"2007", "Marzo", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "2834.45", "-183774.00", "0"},
            {"2007", "Marzo", "4720.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "-10", "233.45", "-50"},
            {"2007", "Marzo", "4751.00000", "IVA SOPORTADO", "5392.88", "0", "0"},
            {"2007", "Marzo", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "0", "-3445.670", "0"},
            {"2007", "Marzo", "6000.00001", "COMPRAS LINEA ESQUI", "-500.00", "5943.23", "0"},
            {"2007", "Marzo", "6221.00000", "GASTOS FINANCIEROS", "2993.33", "23345.65", "-9"},
            {"2007", "Marzo", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "129734", "33.34", "0"}

            {"2008", "Enero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "-134.45", "0", "12345.45"},
            {"2008", "Enero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "233.345", "3489.00", "346789.00"},
            {"2008", "Enero", "4751.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "592.00", "3945", "-392.88"},
            {"2008", "Enero", "4720.00000", "IVA SOPORTADO", "98734.00", "-23.45", "0"},
            {"2008", "Enero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "100.23", "-345.670", "-34"},
            {"2008", "Enero", "6000.00001", "COMPRAS LINEA ESQUI", "-30.00", "1999234.23", "0"},
            {"2008", "Enero", "6221.00000", "GASTOS FINANCIEROS", "334.33", "-2344", "-56"},
            {"2008", "Enero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "292", "1234.34", "0"},
        </matrix>
    </vtable.insert>
    
    <file.bytes.write>
        <file name='reportdocs.dat' type='temp' />
        <report.document name='reportdocs' type='fo' html-debug='true' html2fo-font-correction='3'>
            <report.page name='r_page' group='ejerci' margin-left='0.25' margin-right='0.25' margin-bottom='0.5' margin-top='0.5'>
                <data>
                    <in>
                        <rows />
                    </in>
                </data>
                <before>
                    <report.region.static name='before' extent='1.0'>
                        <report.block>
                            <report.table>
                                <body>
                                    <report.row name='h2'>
                                        <report.column width='21' style='color:blue; font-family:sans-serif;font-size:14px;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px; font-weight:bold;text-align:left;'>
                                            <static type='text'>BALANCE SUMAS Y SALDOS</static>
                                        </report.column>
                                    </report.row>
                                </body>
                            </report.table>
                        </report.block>

                    </report.region.static>
                </before> 
                <body>
                    <report.region.flow name='detail' extent='0.0' >
                        <before>
                             <report.block>
                                    <report.table>
                                        <body>
                                            <report.row>
                                                <report.column start='0' width='1' style='font-family:sans-serif;font-size:10pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold;text-align:left;height:5px;'>
                                                    <static type='text'>Ejercicio</static>
                                                </report.column>
                                                <report.column start='1.25' width='20' style='font-family:sans-serif;font-size:10pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold; text-align:left;height:5px;'>
                                                    <tupple type='text'>ejerci</tupple>
                                                </report.column>
                                            </report.row>
                                        </body>
                                    </report.table>
                                </report.block>
                                <report.block>
                                    <report.table>
                                        <body>
                                            <report.row>
                                                <report.column start='1' width='1' style='font-family:sans-serif;font-size:9pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold;text-align:left;'>
                                                    <static type='text'>Mes:</static>
                                                </report.column>
                                                <report.column start='2' width='19' style='font-family:sans-serif;font-size:10pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold;text-align:left;'>
                                                    <tupple type='text'>period</tupple>
                                                </report.column>
                                            </report.row>
                                        </body>
                                    </report.table>
                                </report.block>
                            </before>
                        <detail>
                            <column flow='true'>
                                <report.block>
                                    <report.table name='t_detail'>
                                        <head>
                                            <report.row>
                                                <report.column start='0' width='2'>
                                                    <static type='text'><string /></static>
                                                </report.column>
                                                <report.column start='2' width='1' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;'>
                                                    <static type='text'>Cuenta</static>
                                                </report.column>
                                                <report.column start='3.25' width='8' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;'>
                                                    <static type='text'>Nombre</static>
                                                </report.column>
                                                <report.column start='11.50' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Debe periodo </static>
                                                </report.column>
                                                <report.column start='13.75' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Haber periodo </static>
                                                </report.column>
                                                <report.column start='16' width='2' style='font-family:sans-serif;font-size:11pt; text-align:center; background-color: \#FFFFFF; height:10px; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;' >
                                                    <static type='text'>Saldo</static>
                                                </report.column>
                                                <report.column start='18.25' width='2' style='font-family:sans-serif;font-size:10pt; text-align:center; background-color: \#FFFFFF; border-bottom-style:solid ; border-bottom-color: black; border-bottom-width:1px;height:5px;' >
                                                    <static type='text'>%</static>
                                                </report.column>
                                            </report.row>
                                        </head>
                                    <body>
                                        <report.row>
                                            <report.column start='0' width='2' >
                                                <static type='text'><string /></static>
                                            </report.column>
                                            <report.column start='2' width='1' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>cuenta</tupple>
                                            </report.column>
                                            <report.column start='3.25' width='8' style='font-family:sans-serif;font-size:10pt;text-align:left; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>nombre</tupple>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='11.50' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>debe</tupple>
                                                <style match='#debe &lt; -0.1' value='color:#c67985;font-weight:bold;' />
                                                <style match='#debe &gt;  0.1' value='color:#8493b3;font-weight:bold;' />
                                                <style match='#debe ==      0' value='color:black;font-weight:bold;' />
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='13.75' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>haber</tupple>
                                                <style match='#haber &lt;  -0.1' value='color:#c67985;font-weight:bold;' />
                                                <style match='#haber &gt;  0.1' value='color:#8493b3;font-weight:bold;' />
                                                <style match='#haber ==      0' value='color:black;font-weight:bold;' />
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='16' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px;'>
                                                <tupple type='text'>saldo</tupple>
                                                <style match='#saldo &lt;  -0.1' value='color:#c67985;font-weight:bold;' />
                                                <style match='#saldo &gt;  0.1' value='color:#8493b3;font-weight:bold;' />
                                                <style match='#saldo ==      0' value='color:black;font-weight:bold;' />
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='18.25' width='2' style='font-family:sans-serif;font-size:10pt;text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px; height:5px;'>
                                                <function name='local_getpor' >
                                                    <args>
                                                        <arg name='data1'>#debe</arg>
                                                        <arg name='data2'>#haber</arg>
                                                    </args>
                                                </function>
                                            </report.column>
                                        </report.row>
                                    </body>

                                </report.table>
                            </report.block>
                        </column>
                    </detail>
                    <after>
                        <null />
                        <report.block>
                                <report.table>
                                    <body>
                                        <report.row>
                                            <report.column start='0' width='8' >
                                                <static type='text'><string /></static>
                                            </report.column>
                                            <report.column start='8' width='1' style='font-family:sans-serif;font-size:10pt; font-weight:bold; text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px; height:5px;'>
                                                <static type='text'>Total</static>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='9' width='2.25' style='font-family:sans-serif;font-size:10pt; font-weight:bold; text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px; height:5px;'>
                                                <static type='text'><string /></static>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='11.50' width='2' style='font-family:sans-serif;font-size:10pt; font-weight:bold; text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px; height:5px;'>
                                                <aggregate type='text'>sum(debe)</aggregate>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='13.75' width='2' style='font-family:sans-serif;font-size:10pt; font-weight:bold; text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px; height:5px;'>
                                                <aggregate type='text'>sum(haber)</aggregate>
                                            </report.column>
                                            <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='16' width='2' style='font-family:sans-serif;font-size:10pt; font-weight:bold; text-align:right; border-bottom-style:dotted; border-bottom-color: grey; border-bottom-width:0.75px; height:5px;'>
                                                <aggregate type='text'>sum(saldo)</aggregate>
                                            </report.column>
                                        </report.row>
                                    </body>
                                </report.table>
                            </report.block>
                        </after> 
                </report.region.flow>
            </body>
        </report.page>
    </report.document>
 </file.bytes.write>

       <!-- 

            If the script is called from a command line then generates a file.
            If the script is called from a SQL Object then returns the content.    
         --> 


      <if>
            <expr><system.isBatch/></expr>
            <then>
                 <file.bytes.write>
                    <file name='reportdocs.pdf' type='absolute' />
                    <file.bytes.read>
                        <fop.transform type='pdf'>
                            <file name='reportdocs.dat' />
                        </fop.transform>
                    </file.bytes.read>
                </file.bytes.write>
            </then>

            <else>
                <return name='reportdocs' type='pdf'>
                    <file.bytes.read>
                        <fop.transform type='pdf'>
                            <file name='reportdocs.dat' />
                        </fop.transform>
                    </file.bytes.read>
                </return>
            </else>
        </if>                

</body>
</xsql-script>

To execute this example, copy this code in the file report_doc.xml and executed it.

Since the script contains a link to execute, you must place dbms and user.

Copy
bin\ws-dbscript -dbms demo_formacion -file report_doc.xml -user mlg

To see the result, you should open the file report_doc.html with a browser.



 

14 Generate the report from an SQL Object

You can generate the report from an object. For this purpose, follow the steps below.

 

14.1 Definition of the SQL Object

The first thing to do is to create the object: connect to the dictionary of the application and enter SQL Objects / Definition / Objects option.

Register an object with the following fields:

  • Code: report_doc.
  • Description SALDOS REPORT.
  • Functional group: GEN (if not, create the functional group).
  • SQL Statement: here is placed the call to the script that will generate the report.
Copy
<call name='report_doc'>
    <args>
        <arg>$TYPE</arg>
        <arg>$DEBUG</arg>
    </args>
</call>

For the other values, leave the default values and the record is inserted.



 

14.2 Declaring variables

As seen in the call to the script, variables $TYPE, $DEBUG will be used. These variables must be declared, and for that purpose, enter the Variables tab.

  • TYPE: it indicates the type of output that will be generated, html, fo or asci.
  • DEBUG: it indicates whether a frame on the sections will be issued in html.

To declare a variable it must be informed.

  • Order: order in which the user is asked for the variables.
  • Variable: name of the variable (as it will be referenced in the SQL Object).
  • Description: description that will show the user.
  • Type of variable: Character, Numeric, Date, etc.


 

14.3 Editing the script

Now we must modify our final script to adapt it to the call from the system. For this purpose, follow the steps described below.

 

14.3.1 Adding parameters

As seen in the SQL Object, the script is being called with two parameters, TYPE and DEBUG. You must have the script in order to receive these parameters and use them. In the header of the script the parameters must be declared.

Copy
<xsql-script name='report_doc'>

    <args>
        <arg name='p_type'  />
        <arg name='p_debug' />
    </args>

    <body>

Two parameters are declared p_type and p_debug.

 

14.3.2 Producing the output

Now these parameters must be used, the report.document tag has two attributes type and html-debug. The variables p_type and p_debug are used to set in the document what is selected by the user.

Copy
<report.document name='report_doc' type='#p_type' html-debug='#p_debug' html2fo-font-correction='3'>

With #p_type the system will replace this with the value of the variable, the same for #p_debug.

When the script is called from the system, a file must no longer be generated, but the script must return the html or PDF. For this, the report will continue to be written in a file, but at the end of the script the following will be done:

Copy
<if>
    <expr><eq><p_type />fo</eq></expr>
    <then>
        <return>
            <file.getBytes>
                <fop.transform type='pdf'>
                    <file name='report.dat' />
                </fop.transform>
            </file.getBytes>
        </return>
    </then>
    <else>
        <return>
            <file.getBytes>
                <file name='report.dat' />
            </file.getBytes>
        </return>
    </else>
</if>

If the type is html: Read the file file.getBytes and return it return.

If the type is fo: Read the file file.getBytes, send it to transform and return the PDF.

Note

For more information on XSLQ-SCRIPT see Script

 

14.4 Registering the script

Once the script has been modified, it must be registered in the dictionary database.

  • Access the dictionary of the application.
  • Click on the panel SPL & triggers.
  • Enter XSQL XML SQL Scripts.
  • Code: report_doc.
  • Description: Balance report generation script.
  • Script: Here the modified script is placed (copy and paste the following code):
Copy
<xsql-script name='report_doc'>
    <args>
        <arg name='p_type'  />
        <arg name='p_debug' />
    </args>

    <body>

        <function name='local_getpor'>
            <args>
                <arg name='p_data1' type='decimal' />
                <arg name='p_data2' type='decimal' />
            </args>

            <body>

                <if>
                    <expr><eq><p_data1 />0</eq></expr>
                    <then>
                        <return>100.00</return>
                    </then>
                    <else>
                        <return><mul><div><p_data2 /><p_data1 /></div>100</mul></return>
                    </else>
                </if>

            </body>
        </function>

        <vtable name='rows'>
            <column name="ejerci" type='smallint' />
            <column name="period" type='char'  />
            <column name="cuenta" type='char'  />
            <column name="nombre" type='char' />
            <column name="debe"   type='decimal'  />
            <column name="haber"  type='decimal'  />
            <column name="saldo"  type='decimal'  />
        </vtable>

        <vtable.insert name='rows'>
            <matrix>
                    {"2007", "Enero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "12345.45", "0", "12345.45"},
                    {"2007", "Enero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "0", "346789.00", "346789.00"},
                    {"2007", "Enero", "4751.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "5392.88", "0", "5392.88"},
                    {"2007", "Enero", "4720.00000", "IVA SOPORTADO", "98734.00", "0", "0"},
                    {"2007", "Enero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "0", "-3445.670", "0"},
                    {"2007", "Enero", "6000.00001", "COMPRAS LINEA ESQUI", "500.00", "-5943.23", "0"},
                    {"2007", "Enero", "6221.00000", "GASTOS FINANCIEROS", "-288834.33", "0", "0"},
                    {"2007", "Enero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "0", "12.34", "0"},

                    {"2007", "Febrero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "9834.34", "399945.21", "0"},
                    {"2007", "Febrero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "6634.34", "346789.00", "0"},
                    {"2007", "Febrero", "4720.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "12.23", "2993.34", "0"},
                    {"2007", "Febrero", "4751.00000", "IVA SOPORTADO", "2993.88", "0", "0"},
                    {"2007", "Febrero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "2394.23", "3445.670", "0"},
                    {"2007", "Febrero", "6000.00001", "COMPRAS LINEA ESQUI", "0", "5943.23", "0"},
                    {"2007", "Febrero", "6221.00000", "GASTOS FINANCIEROS", "0", "39993.45", "0"},
                    {"2007", "Febrero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "0", "233345.35", "0"},

                    {"2007", "Marzo", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "0", "7374.34", "0"},
                    {"2007", "Marzo", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "2834.45", "183774.00", "0"},
                    {"2007", "Marzo", "4720.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "0", "233.45", "0"},
                    {"2007", "Marzo", "4751.00000", "IVA SOPORTADO", "5392.88", "0", "0"},
                    {"2007", "Marzo", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "0", "3445.670", "0"},
                    {"2007", "Marzo", "6000.00001", "COMPRAS LINEA ESQUI", "500.00", "5943.23", "0"},
                    {"2007", "Marzo", "6221.00000", "GASTOS FINANCIEROS", "2993.33", "23345.65", "0"},
                    {"2007", "Marzo", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "129734", "33.34", "0"},

                    {"2008", "Enero", "4000.00001", "DISTRIBUIDORA DEPORTIVA,S.A.", "134.45", "0", "12345.45"},
                    {"2008", "Enero", "4100.00001", "SUMINISTROS DEPORTIVOS Y PARA EL OCIO, S.A.", "233.345", "3489.00", "346789.00"},
                    {"2008", "Enero", "4751.00000", "HACIENDA PÚBLICA, ACREEDOR POR RETENCIONES PRACTICADAS", "592.00", "3945", "5392.88"},
                    {"2008", "Enero", "4720.00000", "IVA SOPORTADO", "98734.00", "23.45", "0"},
                    {"2008", "Enero", "6000.00000", "COMPRAS DE ARTICULOS VARIOS", "100.23", "345.670", "0"},
                    {"2008", "Enero", "6000.00001", "COMPRAS LINEA ESQUI", "0.00", "1999234.23", "0"},
                    {"2008", "Enero", "6221.00000", "GASTOS FINANCIEROS", "334.33", "2344", "23"},
                    {"2008", "Enero", "7650.00000", "DESCUENTO PRONTO PAGO POR COMPRAS", "292", "1234.34", "0"},
            </matrix>
        </vtable.insert>

        <file.writer.open id='out1'>
              <file name='report_doc.html' type='absolute' />
          </file.writer.open>
      
          <file.writer.println id='out1'>
            <report.document name='report_doc' type='#p_type' html-debug='#p_debug' html2fo-font-correction='3'>

                <report.page name='r_page' group='ejerci' margin-left='0.25' margin-right='0.25' margin-bottom='0.5' margin-top='0.5'>

                    <data>
                        <in>
                            <rows />
                        </in>
                    </data>

                     <before>
                        <report.region.static name='before' extent='1.0'>
                            <report.block>
                                <report.table>
                                    <body>
                                        <report.row name='h2'>
                                            <report.column width='21' style='font-family:sans-serif;font-size:12pt;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;font-weight:bold;text-align:center;color:blue;'>
                                                <static type='text'>BALANCE SUMAS Y SALDOS</static>
                                            </report.column>
                                        </report.row>
                                    </body>
                                </report.table>
                            </report.block>

                        </report.region.static>

                    </before>

                    <body>

                        <report.region.flow name='detail' extent='0.0' >

                            <before>

                                 <report.block>
                                        <report.table>
                                            <body>
                                                <report.row>
                                                    <report.column start='0' width='1' style='font-family:sans-serif;font-size:8pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;text-align:left;'>
                                                        <static type='text'>Ejercicio</static>
                                                    </report.column>
                                                    <report.column start='1' width='20' style='font-family:sans-serif;font-size:9pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold;'>
                                                        <tupple type='text'>ejerci</tupple>
                                                    </report.column>
                                                </report.row>
                                            </body>
                                        </report.table>
                                    </report.block>

                                    <report.block>
                                        <report.table>
                                            <body>
                                                <report.row>
                                                    <report.column start='1' width='1' style='font-family:sans-serif;font-size:8pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;text-align:left;'>
                                                        <static type='text'>Mes:</static>
                                                    </report.column>
                                                    <report.column start='2' width='19' style='font-family:sans-serif;font-size:9pt;padding-left:1px;padding-right:1px;padding-top:1px;padding-bottom:1px;font-weight:bold;text-align:left;'>
                                                        <tupple type='text'>period</tupple>
                                                    </report.column>
                                                </report.row>
                                            </body>
                                        </report.table>
                                    </report.block>
                            </before>

                            <detail>
                                <column flow='true'>
                                    <report.block>
                                        <report.table name='t_detail'>
                                            <head>
                                                <report.row>
                                                    <report.column start='0' width='3' style='background-color: \#D9E8F9;font-family:sans-serif;font-size:10px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:left;border-bottom-style:solid; border-bottom-color:black;border-bottom-width:1px;'>
                                                        <static type='text'><string /></static>
                                                    </report.column>
                                                    <report.column start='3' width='2' style='background-color: \#D9E8F9;font-family:sans-serif;font-size:10px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:left;border-bottom-style:solid; border-bottom-color:black;border-bottom-width:1px;'>
                                                        <static type='text'>Cuenta</static>
                                                    </report.column>
                                                    <report.column start='5' width='7' style='background-color: \#D9E8F9;font-family:sans-serif;font-size:10px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:left;border-bottom-style:solid; border-bottom-color:black;border-bottom-width:1px;'>
                                                        <static type='text'>Nombre</static>
                                                    </report.column>
                                                    <report.column start='12' width='2' style='background-color: \#D9E8F9;font-family:sans-serif;font-size:10px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;border-bottom-style:solid; border-bottom-color:black;border-bottom-width:1px;'>
                                                        <static type='text'>Debe periodo </static>
                                                    </report.column>
                                                    <report.column start='14' width='2' style='background-color: \#D9E8F9;font-family:sans-serif;font-size:10px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;border-bottom-style:solid; border-bottom-color:black;border-bottom-width:1px;'>
                                                        <static type='text'>Haber periodo </static>
                                                    </report.column>
                                                    <report.column start='16' width='2' style='background-color: \#D9E8F9;font-family:sans-serif;font-size:10px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;border-bottom-style:solid; border-bottom-color:black;border-bottom-width:1px;'>
                                                        <static type='text'>Saldo</static>
                                                    </report.column>
                                                    <report.column start='18' width='2' style='background-color: \#D9E8F9;font-family:sans-serif;font-size:10px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;border-bottom-style:solid; border-bottom-color:black;border-bottom-width:1px;'>
                                                        <static type='text'>%</static>
                                                    </report.column>

                                                </report.row>
                                            </head>
                                            <body>
                                                <report.row>
                                                    <report.column start='0' width='3' style='background-color: \#F7F7F7;font-family:sans-serif;font-size:9px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:left;'>
                                                        <static type='text'><string /></static>
                                                    </report.column>
                                                    <report.column start='3' width='2' style='background-color: \#F7F7F7;font-family:sans-serif;font-size:9px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:left;'>
                                                        <tupple type='text'>cuenta</tupple>
                                                        <link code='capuntes_comp' cond="capuntes.cuenta=#cuenta" target='_blank'>
                                                        </link>
                                                    </report.column>
                                                    <report.column start='5' width='7' style='background-color: \#F7F7F7;font-family:sans-serif;font-size:9px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:left;'>
                                                        <tupple type='text'>nombre</tupple>
                                                    </report.column>
                                                    <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='12' width='2' style='background-color: \#F7F7F7;font-family:sans-serif;font-size:9px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;color:black;'>
                                                        <tupple type='text'>debe</tupple>
                                                        <style match='#debe < 0' value='color:red;' />
                                                    </report.column>
                                                    <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='14' width='2' style='background-color: \#F7F7F7;font-family:sans-serif;font-size:9px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;color:black;'>
                                                        <tupple type='text'>haber</tupple>
                                                        <style match='#haber < 0' value='color:red;' />
                                                    </report.column>
                                                    <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='16' width='2' style='background-color: \#F7F7F7;font-family:sans-serif;font-size:9px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;'>
                                                        <tupple type='text'>saldo</tupple>
                                                    </report.column>
                                                    <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='18' width='2' style='background-color: \#F7F7F7;font-family:sans-serif;font-size:9px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;'>
                                                        <function name='local_getpor' >
                                                            <args>
                                                                <arg name='data1'>#debe</arg>
                                                                <arg name='data2'>#haber</arg>
                                                            </args>
                                                        </function>
                                                    </report.column>
                                                </report.row>
                                            </body>

                                        </report.table>
                                    </report.block>

                                </column>
                            </detail>

                            <after>
                                <null />
                                <report.block>
                                    <report.table>
                                        <body>
                                            <report.row>
                                                <report.column start='0' width='10' >
                                                    <static type='text'><string /></static>
                                                </report.column>
                                                <report.column start='10' width='2' style='font-family:sans-serif;font-size:10px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;border-bottom-style:solid; border-bottom-color:black;border-bottom-width:1px;text-align:right;'>
                                                    <static type='text'>Total</static>
                                                </report.column>
                                                <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='12' width='2' style='background-color: \#D9E8F9;font-family:sans-serif;font-size:10px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;border-bottom-style:solid; border-bottom-color:black;border-bottom-width:1px;'>
                                                    <aggregate type='text'>sum(debe)</aggregate>
                                                </report.column>
                                                <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='14' width='2' style='background-color: \#D9E8F9;font-family:sans-serif;font-size:10px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;border-bottom-style:solid; border-bottom-color:black;border-bottom-width:1px;'>
                                                    <aggregate type='text'>sum(haber)</aggregate>
                                                </report.column>
                                                <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='16' width='2' style='background-color: \#D9E8F9;font-family:sans-serif;font-size:10px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;border-bottom-style:solid; border-bottom-color:black;border-bottom-width:1px;'>
                                                    <aggregate type='text'>sum(saldo)</aggregate>
                                                </report.column>
                                                <report.column  minimumfractiondigits='2' maximumfractiondigits='2' start='18' width='2' style='background-color: \#D9E8F9;font-family:sans-serif;font-size:10px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px;text-align:right;border-bottom-style:solid; border-bottom-color:black;border-bottom-width:1px;'>
                                                    <static type='text'><string /></static>
                                                </report.column>
                                            </report.row>
                                        </body>
                                    </report.table>
                                </report.block>
                            </after>
                        </report.region.flow>

                    </body>

                </report.page>
            </report.document>
        </file.writer.println>

      <file.writer.flush id='out1'/>
      <file.writer.close id='out1'/>

        <if>
            <expr><eq><p_type />fo</eq></expr>
            <then>
                <return>
                    <file.getBytes>
                        <fop.transform type='pdf'>
                            <file name='report_doc.dat' />
                        </fop.transform>
                    </file.getBytes>
                </return>
            </then>
            <else>
                <return>
                    <file.getBytes>
                        <file name='report_doc.dat' />
                    </file.getBytes>
                </return>
            </else>
        </if>
    </body>
</xsql-script>
 

14.5 Run

  • From the desktop.
  • Access Applications.
  • Select the server.
  • Select the Database.
  • Execute the object, from the search box of the application /report_doc.


Click on View document:



 

15 Adding a sum and follow

There are cases in which you want to print at the end of the page a cumulative value of some column, for example a sum and follow or a total general, etc.

To do this, the following steps will be followed:

  • The column or columns that you wish to accumulate should be brought from the main report select.
  • In the after-page region (for example) these accumulated columns should be painted as if they were normal columns. For example:
Copy
<report.region.static name='after' type='REGION_TYPE_AFTER' extent='2.0'>
    <report.block>
        <report.table>
            <body>
                <report.row name='after1'>
                    <report.column start='0' width='14' style='font-size:14pt;color:red;'>
                        <tupple type='text'>totaltxt</tupple>
                    </report.column>
                    <report.column start='14' width='4' style='text-align:right;'  minimumfractiondigits='2' maximumfractiondigits='2'>
                        <tupple type='text'>subtotal</tupple>
                    </report.column>
                </report.row>
            </body>
        </report.table>
    </report.block>
</report.region.static>

In the subtotal column of the main selection, the column of interest is accumulated.

In this case, the totaltxt tag is also brought from the select to place SUM AND FOLLOW on all pages other than the last; and to place TOTAL on the last page.

Note

All tupple columns that are placed in the after region will be considered as cumulative columns, totals, etc. and the value of the tupple column will be placed for the last record of the page. In this way you can, on pages other than the last one, print a caption "SUM AND FOLLOW" and on the last page print "TOTAL".

 

16 Example library

Examples

This report contains a start, before page, after page and end section. Within the detail section there is an after and a before on the program column. The page is broken by the province.

In this report, it is broken by plan and by project number. An after page is displayed with report titles, an after section (project) and the detail.

Examples

Example of a purchase order in which it is broken (page change) by Order number.

Sales statistics by different groupings, Category, Subcategory, Region. Totals are shown in the before group.

Examples

Profile of clients, grouped by Region, Letter of the name, etc. In this report you can see how multiple lines can be included in each row of the report.

Detail of works by province and municipalities. This example is programmed with after and before to print the headers and summaries. It is also a good example of the aggregation functions (count and sum).

Examples

Detail of works by province and municipalities. In this example, headers and summaries are about the main table (head and footer).

This example shows a balance with breaks according to the different levels of the account. The cutting of the sheet is done by level 1 of the account.