Page 1 of 1

CLASS REPORT

PostPosted: Thu Feb 02, 2012 4:17 pm
by leszekj
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

Re: CLASS REPORT

PostPosted: Thu Feb 02, 2012 7:51 pm
by Antonio Linares
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.

Re: CLASS REPORT

PostPosted: Thu Feb 02, 2012 10:44 pm
by Marcelo Via Giglio
Hola,

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

Code: Select all  Expand view


   // 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()
 
 

Re: CLASS REPORT

PostPosted: Tue Feb 07, 2012 5:19 pm
by leszekj
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: Select all  Expand view
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

Re: CLASS REPORT

PostPosted: Tue Feb 07, 2012 6:49 pm
by Marcelo Via Giglio
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: Select all  Expand view
  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

Re: CLASS REPORT

PostPosted: Mon Feb 13, 2012 8:50 am
by leszekj
Hi, Marcelo!
Thanks again for your help. I used your instructions and got it working well.
I owe you a beer! ;)

Best regards,
Leszek