FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour how to add two columns in the Report
Posts: 26
Joined: Thu Apr 21, 2011 06:02 PM
how to add two columns in the Report
Posted: Wed May 15, 2013 08:12 PM

how to add two columns in the Report,
I have a DBF file in which there is a field input and output field, using the report command to print the report should look like this:
input output balance


100 0 100
20 0 120
0 10 110
0 5 105


120 15 105
I do not know how to calculate the third column thank you for your help.

Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: how to add two columns in the Report
Posted: Wed May 15, 2013 10:10 PM
Hi, here's is an example:
Code (fw): Select all Collapse
local nBalance:=0

      REPORT oReport ;
     ...
     oReport:bInit := { || MyTable->(dbGoTop()), nBalance:= (nBalance+MyTable->debit - MyTable->Credit )   }  //FWH 1204
          
     COLUMN TITLE "DEBITS    " ;
          DATA  MyTable->Debit ;
          PICTURE "@Z 99,999,999.99" ;
          SIZE 10 ;
          TOTAL 

     COLUMN TITLE "CREDITS    " ;
          DATA  MyTable->Credit ;
          PICTURE "@Z 99,999,999.99" ;
          SIZE 10 ;
          TOTAL 

     COLUMN TITLE "BALANCE   " ;
          DATA nBalance += ( MyTable->Debit - MyTable->Credit ) ;
          PICTURE "99,999,999.99" ;
          SIZE 10 

     END REPORT

     ACTIVATE REPORT oReport


Let me know if it helps you.
Regards.
Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 26
Joined: Thu Apr 21, 2011 06:02 PM
Re: how to add two columns in the Report
Posted: Thu May 16, 2013 06:14 PM

Thanks for your help Mr. FranciskoA, this is a small example of what I wanted to do in my program who now works ok.
Best regards Davor.

include "FiveWin.ch"

include "report.ch"

REQUEST DBFFPT,DBFCDX

function rept()
local nBalance:=0,nfor,astruct,oReport

IF FILE("MyTable.DBF")=.F.
ASTRUCT := { ;
{ "AAA" , "N", 5, 0 }, ;
{ "DEBIT" , "N", 5, 0 }, ;
{ "CREDIT" , "N", 5, 0 } ;
}

DBCREATE("MyTable", ASTRUCT, "DBFCDX", , )

endif

USE MyTable NEW
index on str(MyTable->aaa) to aaacdx temporary
dbGoTop()
if eof()=.t.
for nfor=1 to 20
append blank
if nfor<=10
replace MyTable->aaa with 10
else
replace MyTable->aaa with 20
endif
replace MyTable->debit with nfor*2
replace MyTable->credit with nfor
next
endif

 REPORT oReport ;
    TITLE &quot;Test&quot; ;
    HEADER dtoc(date());
    FOOTER &quot;Page: &quot;+str(oReport:nPage,3) RIGHT;
    PREVIEW


 oReport:bInit := { || MyTable-&gt;(dbGoTop()), nBalance:= 0   }  //FWH 1204

 COLUMN TITLE &quot;GROUP    &quot; ;
      DATA  MyTable-&gt;AAA ;
      PICTURE &quot;@Z 99999999&quot; ;
      SIZE 10


 COLUMN TITLE &quot;DEBITS    &quot; ;
      DATA  MyTable-&gt;Debit ;
      PICTURE &quot;@Z 99,999,999.99&quot; ;
      SIZE 10 ;
      TOTAL

 COLUMN TITLE &quot;CREDITS    &quot; ;
      DATA  MyTable-&gt;Credit ;
      PICTURE &quot;@Z 99,999,999.99&quot; ;
      SIZE 10 ;
      TOTAL

 COLUMN TITLE &quot;BALANCE   &quot; ;
      DATA nBalance += ( MyTable-&gt;Debit - MyTable-&gt;Credit ) ;
      PICTURE &quot;99,999,999.99&quot; ;
      SIZE 10

 GROUP ON MyTable-&gt;aaa

 END REPORT

 ACTIVATE REPORT oReport ON ENDGROUP nBalance:= 0

close all
return nil

Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: how to add two columns in the Report
Posted: Thu May 16, 2013 07:36 PM

davor0501,
Good.

Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql

Continue the discussion