FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour CLASS REPORT
Posts: 3
Joined: Mon Jan 30, 2012 05:25 PM
CLASS REPORT
Posted: Thu Feb 02, 2012 04:17 PM

Hi,
I'm generating reports using Report class.
I am able to print columns total for the whole report, also I can get
the increasing sum on each page.
I'd like to know if it is possible to additionally get the summary for
each page of the report (not increasing, just each page sum up).
Have you any idea how to do that? Maybe I should use another class?

Thanks,
Leszek

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: CLASS REPORT
Posted: Thu Feb 02, 2012 07:51 PM

Leszek,

If you are using the REPORT command try the SUMMARY clause:

REPORT oRpt ... SUMMARY

if you are managing the report object directly, you can do:

oReport:lSummary := .T.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: CLASS REPORT
Posted: Thu Feb 02, 2012 10:44 PM
Hola,

this is a sample but working with array, you can change easily to work with DataBase

Code (fw): Select all Collapse
 

   // was missing this important declaration in the first publication
   LOCAL aTotal := {0,0,0,0,0,0,0,0,0,0,0}.....

聽 聽DEFINE FONT oFont1 NAME "ARIAL NARROW" SIZE 0,-8
聽 聽DEFINE FONT oFont2 NAME "ARIAL NARROW" SIZE 0,-8 BOLD
聽 聽DEFINE FONT oFont3 NAME "ARIAL NARROW" SIZE 0,-12 BOLD
聽 聽DEFINE FONT oFont4 NAME "ARIAL NARROW" SIZE 0,-8 BOLD
聽 聽DEFINE FONT oFont5 NAME "ARIAL NARROW" SIZE 0,-6
聽
聽 聽DEFINE PEN pen1 WIDTH 0.3
聽
聽 聽 聽 聽REPORT oReport;
聽 聽 聽 聽 TITLE "PERIODO: " + SUBSTR( aData[1,5], 4 ) ;
聽 聽 聽 聽 聽FONT oFont1, oFont2, oFont3, oFont4, oFont5 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 ;
聽 聽 聽 聽 聽 PEN pen1 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 ;
聽 聽 聽 聽HEADER "Nombre o Raz贸n Social: " + cNombre,;
聽 聽 聽 聽 聽 聽 聽 "N煤mero NIT: " + cNit ,;
聽 聽 聽 聽 聽 聽 聽 "N煤mero Sucursal: " + cSucursal ,;
聽 聽 聽 聽 聽 聽 聽 "Direcci贸n: " + cDireccion;
聽 聽 聽 聽 聽 聽 聽 LEFT 聽 聽 聽 聽;
聽 聽 聽 聽FOOTER "P谩gina : " + STR (oReport:nPage,3);
聽 聽 聽 PREVIEW 聽;
聽 聽 聽 CAPTION "LIBRO VENTAS - IVA"
聽
聽 聽 聽 聽 聽 聽 聽 COLUMN TITLE "Fecha" 聽 聽 聽 聽 聽 聽 聽 聽 DATA aData[ nAt, 5] 聽 聽 聽 SIZE 聽9 FONT 1 CENTER
聽 聽 聽 聽 聽 聽 聽 COLUMN TITLE "N煤mero" 聽 聽 聽 聽 聽 聽 聽 聽DATA aData[ nAt, 1] 聽 聽 聽 SIZE 聽9 FONT 1
聽 聽 聽 聽 聽 聽 聽 COLUMN TITLE "Nombre o Raz贸n Social" DATA aData[ nAt, 2] 聽 聽 聽 SIZE 30 FONT 1
聽 聽 聽 聽 聽 聽 聽 COLUMN TITLE "N煤mero","Factura" 聽 聽 聽DATA aData[ nAt, 3] 聽 聽 聽 SIZE 聽7 FONT 1
聽 聽 聽 聽 聽 聽 聽 COLUMN TITLE "N煤mero","Autorizaci贸n" DATA aData[ nAt, 4] 聽 聽 聽 SIZE 15 FONT 1 CENTER
聽 聽 聽 聽 聽 聽 聽 COLUMN TITLE "C贸digo de","Control" 聽 DATA aData[ nAt, 12] 聽 聽 聽SIZE 12 FONT 1 CENTER
聽 聽 聽 聽 聽 聽 聽 COLUMN TITLE "Importe","Facturado" 聽 DATA VAL(aData[ nAt, 6]) 聽SIZE 聽9 FONT 1 RIGHT PICTURE "999,999.99" TOTAL
聽 聽 聽 聽 聽 聽 聽 COLUMN TITLE "ICE" 聽 聽 聽 聽 聽 聽 聽 聽 聽 DATA aData[ nAt, 7] 聽 聽 聽 SIZE 聽6 FONT 1 RIGHT PICTURE "@Z 999,999.99"
聽 聽 聽 聽 聽 聽 聽 COLUMN TITLE "Exento" 聽 聽 聽 聽 聽 聽 聽 聽DATA aData[ nAt, 8] 聽 聽 聽 SIZE 聽6 FONT 1 RIGHT PICTURE "@Z 999,999.99"
聽 聽 聽 聽 聽 聽 聽 COLUMN TITLE "Valor","Neto" 聽 聽 聽 聽 聽DATA VAL(aData[ nAt, 9]) 聽SIZE 聽9 FONT 1 RIGHT PICTURE "999,999.99" TOTAL
聽 聽 聽 聽 聽 聽 聽 COLUMN TITLE "IVA" 聽 聽 聽 聽 聽 聽 聽 聽 聽 DATA VAL(aData[ nAt, 10]) SIZE 聽7 FONT 1 RIGHT PICTURE "999,999.99" TOTAL
聽
聽 聽END REPORT
聽
聽 聽oReport:bPreInit 聽 聽 := {|| nAt := 1 }
聽 聽oReport:bSkip 聽 聽 聽 聽:= {|| nAt++ }
聽 聽oReport:lPageTotal 聽 := .T.
聽 聽oReport:lTotal 聽 聽 聽 := .T.
聽 聽oReport:cGrandTotal 聽:= 'Total P谩gina'
聽 聽oReport:cPageTotal 聽 := 'Total P谩gina' 
聽
聽 聽AEVAL ( oReport:oHeader:aFont, { |e,i| oReport:oHeader:aFont[i] := {||2} } )
聽 聽AEVAL ( oReport:oTitle:aFont, 聽{ |e,i| oReport:oTitle:aFont[i] 聽:= {||3} } )
聽 聽AEVAL ( oReport:aColumns, 聽 聽 聽{ |e| e:bTitleFont 聽 聽 聽 聽 聽 聽 聽 := {||4} 聽 聽 ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 e:bTotalFont 聽 聽 聽 聽 聽 聽 聽 := {||2} } )
聽
聽 聽oReport:oDevice:lPrvModal := .T.
聽
聽 聽ACTIVATE REPORT oReport ;
聽 聽 聽 聽 聽 聽 聽WHILE nAt <= LEN( aData ) ;
聽 聽 聽 聽 聽 聽 ON POSTPAGE AEVAL( oReport:aColumns, {|c,i| aTotal[i] += c:nTotal, c:nTotal := 0 } ) ;
聽 聽 聽 聽 聽 聽 ON POSTEND ( oReport:cGrandTotal 聽:= 'Total General',;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽AEVAL( oReport:aColumns, {|c,i| c:nTotal := aTotal[i] } ),;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽oReport:PageTotal() )
聽
聽 聽oFont1:END()
聽 聽oFont2:end()
聽 聽oFont3:END()
聽 聽oFont4:END()
聽 聽oFont5:END()
聽
聽 聽pen1:END()
Posts: 3
Joined: Mon Jan 30, 2012 05:25 PM
Re: CLASS REPORT
Posted: Tue Feb 07, 2012 05:19 PM
Great thanks for your answers.

Marcelo, thanks for your sample. I've changed it to print from file.
I've got the page summary, but I lost the increasing sums for every page. I'd like to have both of them on every page.

Please, see the following sample.
How can I create something like that?

Thanks,
Leszek


Code (fw): Select all Collapse
Page 1
- - - - - - - - 聽- - - - - - 聽- - - 聽- - - - 聽- -
| NR 聽 聽| ..... | 聽 聽col 1 聽 聽 聽 聽 聽| 聽col 2 聽 | 
- - - - - - - - 聽- - - - - - 聽- - - 聽- - - - 聽- -
聽 1 聽 聽 聽 聽 聽 聽 聽 聽 聽100 聽 聽 聽 聽 聽 聽 聽 200
聽 2 聽 聽 聽 聽 聽 聽 聽 聽 聽100 聽 聽 聽 聽 聽 聽 聽 200
聽...
- - - - - - - - 聽- - - - - - 聽- - - 聽- - - - 聽- -
Page sum: 聽 聽 聽 | 聽 聽200 聽 聽 聽 聽 聽 聽 聽 400
- - - - - - - - 聽- - - - - - 聽- - - 聽- - - - 聽- -
Increasing sum 聽| 聽 聽200 聽 聽 聽 聽 聽 聽 聽 400
- - - - - - - - 聽- - - - - - 聽- - - 聽- - - - 聽- -

Page 2
- - - - - - - - 聽- - - - - - 聽- - - 聽- - - - 聽- -
| NR 聽 聽| ..... | 聽 聽col 1 聽 聽 聽 聽 聽| 聽col 2 聽 | 
- - - - - - - - 聽- - - - - - 聽- - - 聽- - - - 聽- -
聽 1 聽 聽 聽 聽 聽 聽 聽 聽 聽300 聽 聽 聽 聽 聽 聽 聽 700
聽 2 聽 聽 聽 聽 聽 聽 聽 聽 聽500 聽 聽 聽 聽 聽 聽 聽 150
聽...
- - - - - - - - 聽- - - - - - 聽- - - 聽- - - - 聽- -
Page sum: 聽 聽 聽 | 聽 聽800 聽 聽 聽 聽 聽 聽 聽 850
- - - - - - - - 聽- - - - - - 聽- - - 聽- - - - 聽- -
Increasing sum 聽| 聽 1000 聽 聽 聽 聽 聽 聽 聽1250
- - - - - - - - 聽- - - - - - 聽- - - 聽- - - - 聽- -

End
Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: CLASS REPORT
Posted: Tue Feb 07, 2012 06:49 PM
Hello,

first add some blank line at the begin in the footer like FOOTER " ", " "," " to reserve space for the new extra pagetotal

then you change the ACTIVE REPORT LIKE

Code (fw): Select all Collapse
   ACTIVATE REPORT oReport ;
             WHILE nAt <= LEN( aData ) ;
        ON ENDPAGE ( AEVAL( oReport:aColumns, {|c,i| aTotal[i] += c:nTotal  } ) , oReport:PageTotal(), AEVAL( oReport:aColumns, {|c,i| c:nTotal := aTotal[i]  } ) );
            ON POSTPAGE AEVAL( oReport:aColumns, {|c,i|  c:nTotal := 0 } ) ;
            ON POSTEND ( oReport:cGrandTotal  := 'Total General',;
                         AEVAL( oReport:aColumns, {|c,i| c:nTotal := aTotal[i] } ),;
                         oReport:PageTotal() )


I think you can add easily the page total legend

regards

Marcelo
Posts: 3
Joined: Mon Jan 30, 2012 05:25 PM
Re: CLASS REPORT
Posted: Mon Feb 13, 2012 08:50 AM

Hi, Marcelo!
Thanks again for your help. I used your instructions and got it working well.
I owe you a beer! ;)

Best regards,
Leszek

Continue the discussion