TReport samples

mosh1
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

TReport samples

Post 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.
ADutheil
Posts: 352
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: TReport samples

Post 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 
 
Regards,

André Dutheil
FWH 13.04 HB 3.2 BCC 5.82 MinGW 4.5.2 MSVS 10
mosh1
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

Re: TReport samples

Post 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?
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: TReport samples

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
mosh1
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

Re: TReport samples

Post 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?
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: TReport samples

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
ADutheil
Posts: 352
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: TReport samples

Post 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
 
Regards,

André Dutheil
FWH 13.04 HB 3.2 BCC 5.82 MinGW 4.5.2 MSVS 10
ADutheil
Posts: 352
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: TReport samples

Post 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.
Regards,

André Dutheil
FWH 13.04 HB 3.2 BCC 5.82 MinGW 4.5.2 MSVS 10
mosh1
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

Re: TReport samples

Post 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?
ADutheil
Posts: 352
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: TReport samples

Post by ADutheil »

Try with oRepo:Line( nTop, nLeft, nBottom, nRight, nPen, nScale )
Regards,

André Dutheil
FWH 13.04 HB 3.2 BCC 5.82 MinGW 4.5.2 MSVS 10
mosh1
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

Re: TReport samples

Post 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 ?
ADutheil
Posts: 352
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: TReport samples

Post 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.
Regards,

André Dutheil
FWH 13.04 HB 3.2 BCC 5.82 MinGW 4.5.2 MSVS 10
mosh1
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

Re: TReport samples

Post 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.
ADutheil
Posts: 352
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: TReport samples

Post by ADutheil »

The test I wrote seems OK:

Image
Regards,

André Dutheil
FWH 13.04 HB 3.2 BCC 5.82 MinGW 4.5.2 MSVS 10
mosh1
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

Re: TReport samples

Post 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.
Post Reply