Page 1 of 3

TReport samples

Posted: Wed Apr 24, 2013 10:14 pm
by mosh1
Hi All!

Is it possible to report from more than one database, like each invoice or order with its line items ? All the samples given are for just one.

Re: TReport samples

Posted: Thu Apr 25, 2013 12:39 am
by ADutheil
I know 2 ways:

Code: Select all

select invoice
REPORT oRepo TITLE ....
COLUMN TITLE "INVOICE Nº" DATA invoice->invoicenbr
COLUMN TITLE "PRODUCT NAME" DATA YourFunction( order->codproduct) 

FUNCTION YourFunction( codproduct )
products->( ordsetfocus( "the right index"), dbseek( codproduct) )
return products->name
 

Code: Select all

products->( ordsetfocus( "the right index") )
invoice->( dbSetRelation("products", { || invoice->codproduct} ))

select invoice
REPORT oRepo TITLE ....
COLUMN TITLE "INVOICE Nº" DATA invoice->invoicenbr
COLUMN TITLE "PRODUCT NAME" DATA products->name 
 

Re: TReport samples

Posted: Thu Apr 25, 2013 7:51 pm
by mosh1
ADutheil wrote:I know 2 ways:
Is it possible to print different data on different rows, like 1 row - name, address, order # - after that several rows - items of the order?

Re: TReport samples

Posted: Thu Apr 25, 2013 8:51 pm
by Antonio Linares
Mosh,

In FWH/samples/report/repdemo.prg and rep*.prg there are a lot of very useful an easy TReport examples.

You can built it running go.bat and you should get repdemo.exe

Re: TReport samples

Posted: Thu Apr 25, 2013 10:16 pm
by mosh1
Antonio Linares wrote:Mosh,

In FWH/samples/report/repdemo.prg and rep*.prg there are a lot of very useful an easy TReport examples.

You can built it running go.bat and you should get repdemo.exe
1) go.bat doesn t go

2) I did study all rep*.prg and didnt find my example. Can you please show such example?

Re: TReport samples

Posted: Thu Apr 25, 2013 10:30 pm
by Antonio Linares
Mosh,

What error do you get with go.bat ? What FWH version are you using ?

rep09.prg from FWH/samples/report shows how to use multiple lines in columns:

Code: Select all

     COLUMN TITLE "First Name", "Last Name" ;
            DATA  Test->First, Test->Last

     COLUMN TITLE "Street", "City"  ;
            DATA  Test->Street, Test->City

Re: TReport samples

Posted: Fri Apr 26, 2013 12:07 am
by ADutheil
Mosh,

I think you are looking for something like this:

Code: Select all

LOCAL cOrderNumber
LOCAL oRepo

details->( ordSetFocus( "ordered_by_order_number" ) )
REPORT oRepo TITLE  "Master/Details"  PREVIEW
     COLUMN TITLE "NAME" DATA master->NAME
     COLUMN TITLE "ADDRESS" DATA master->ADDR
     COLUMN TITLE "ORDER" DATA SayOrderNumber( @cOrderNumber )
     COLUMN TITLE "PRODUCTS" DATA "" SIZE 50 
END REPORT
ACTIVATE REPORT oRepo ON CHANGE SayDetails( oRepo, cOrderNumber )

STATIC FUNCTION SayOrderNumber( cOrderNumber )  
cOrderNumber := master->ORDN
RETURN master->ORDN

STATIC Function SayDetails( oRepo, cOrderNumber )
details->( ordScope( 0, cOrderNumber ), ordScope( 1, cOrderNumber ), dbGoTop() )

oRepo:BackLine( 1 )
WHILE details->( !eOF() )
    oReport:StartLine()
    oReport:Say( 4, details->FIELD_YOU_WANT )
    oReport:EndLine()
    details->( dbSkip() )
ENDDO
details->( ordScope( 0, NIL ), ordScope( 1, NIL ) )
oRepo:Newline()
RETURN NIL
 

Re: TReport samples

Posted: Fri Apr 26, 2013 12:12 am
by ADutheil
Antonio,

With WINDOWS 7 seems that harbour can´t create the .\obj directory. But if you create it with md obj go.bat Works OK.

Re: TReport samples

Posted: Fri Apr 26, 2013 1:44 pm
by mosh1
ADutheil wrote:Mosh,
I think you are looking for something like this:
Yes, exactly! Thanks. One more question : how can I draw a box around master row?

Re: TReport samples

Posted: Fri Apr 26, 2013 2:22 pm
by ADutheil
Try with oRepo:Line( nTop, nLeft, nBottom, nRight, nPen, nScale )

Re: TReport samples

Posted: Fri Apr 26, 2013 2:47 pm
by mosh1
ADutheil wrote:Try with oRepo:Line( nTop, nLeft, nBottom, nRight, nPen, nScale )
I understand, but the question is how to determine nTop, nLeft, nBottom, nRight ?

Re: TReport samples

Posted: Fri Apr 26, 2013 5:08 pm
by ADutheil
I you want a box better use box method:

Code: Select all

oRepo:bStartRecord := { || oRepo:box( oRepo:nRow / oRepo:oDevice:nLogPixelY, oRepo:nMargin/oRepo:oDevice:nLogPixelX, ( oRepo:nRow + oRepo:nStdLineHeight) / oRepo:oDevice:nLogPixelY, RightMargin( oRepo ) / oRepo:oDevice:nLogPixelX , 1 )  }



FUNCTION RightMargin( oRepo )
LOCAL nRight := oRepo:nMargin

AEval( oRepo:aColumns, { | v | nRight += v:nWidth } )
nRight += ( ( Len( oRepo:aColumns )- 1 ) * oRepo:nSeparator )
RETURN nRight
 
Antônio can tell if there is better way but this works.

Re: TReport samples

Posted: Fri Apr 26, 2013 8:13 pm
by mosh1
ADutheil wrote:I you want a box better use box method:
Thanks!
But in fact this sample draw boxes between rows not around them. I couldn't make it work as desired.

Re: TReport samples

Posted: Fri Apr 26, 2013 10:13 pm
by ADutheil
The test I wrote seems OK:

Image

Re: TReport samples

Posted: Sun Apr 28, 2013 2:45 am
by mosh1
ADutheil wrote:The test I wrote seems OK:

Image
Can you please post your entire sample? Also - I need all the master row for master info and start 1st detail row on next row.