TReport samples

TReport samples

Postby mosh1 » Wed Apr 24, 2013 10:14 pm

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.
mosh1
 
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

Re: TReport samples

Postby ADutheil » Thu Apr 25, 2013 12:39 am

I know 2 ways:

Code: Select all  Expand view

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  Expand view

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 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: TReport samples

Postby mosh1 » Thu Apr 25, 2013 7:51 pm

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?
mosh1
 
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

Re: TReport samples

Postby Antonio Linares » Thu Apr 25, 2013 8:51 pm

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

Re: TReport samples

Postby mosh1 » Thu Apr 25, 2013 10:16 pm

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?
mosh1
 
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

Re: TReport samples

Postby Antonio Linares » Thu Apr 25, 2013 10:30 pm

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  Expand view
    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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: TReport samples

Postby ADutheil » Fri Apr 26, 2013 12:07 am

Mosh,

I think you are looking for something like this:

Code: Select all  Expand view

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 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: TReport samples

Postby ADutheil » Fri Apr 26, 2013 12:12 am

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 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: TReport samples

Postby mosh1 » Fri Apr 26, 2013 1:44 pm

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?
mosh1
 
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

Re: TReport samples

Postby ADutheil » Fri Apr 26, 2013 2:22 pm

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

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: TReport samples

Postby mosh1 » Fri Apr 26, 2013 2:47 pm

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 ?
mosh1
 
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

Re: TReport samples

Postby ADutheil » Fri Apr 26, 2013 5:08 pm

I you want a box better use box method:

Code: Select all  Expand view

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 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: TReport samples

Postby mosh1 » Fri Apr 26, 2013 8:13 pm

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.
mosh1
 
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

Re: TReport samples

Postby ADutheil » Fri Apr 26, 2013 10:13 pm

The test I wrote seems OK:

Image
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: TReport samples

Postby mosh1 » Sun Apr 28, 2013 2:45 am

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.
mosh1
 
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: cnavarro and 37 guests