CLASS REPORT

CLASS REPORT

Postby leszekj » Thu Feb 02, 2012 4: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
leszekj
 
Posts: 3
Joined: Mon Jan 30, 2012 5:25 pm

Re: CLASS REPORT

Postby Antonio Linares » Thu Feb 02, 2012 7: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: CLASS REPORT

Postby Marcelo Via Giglio » 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: 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()
 
 
Marcelo Via Giglio
 
Posts: 1051
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: CLASS REPORT

Postby leszekj » Tue Feb 07, 2012 5: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: 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
leszekj
 
Posts: 3
Joined: Mon Jan 30, 2012 5:25 pm

Re: CLASS REPORT

Postby Marcelo Via Giglio » Tue Feb 07, 2012 6: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: 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
Marcelo Via Giglio
 
Posts: 1051
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: CLASS REPORT

Postby leszekj » Mon Feb 13, 2012 8: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
leszekj
 
Posts: 3
Joined: Mon Jan 30, 2012 5:25 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 38 guests