Introduction to Rave Reports

download Introduction to Rave Reports

of 13

Transcript of Introduction to Rave Reports

  • 8/11/2019 Introduction to Rave Reports

    1/13

    P a g e | 1Introduction to Rave Reports - 2004

    Introduction to Rave Reports - Part I: Code Based ReportsBy: Leonel TogniolliAbstract: This is a introduction to Rave Reports. Part I describes how to work with Code Base reports. - by Leonel Togniolli

    Introduction to Rave R eports - Part I: Code Based Reportselphi ! has included Rave Reports as the de"ault reporting solution# replacing $uick Reports. %ince they work in very di""erent paradig&s# &any people

    were con"used by the new environ&ent. This is intended as an introduction "or people who haven't worked with Rave yet# and would like to start .

    elphi ! ships with Rave Reports (.).*. I" you haven't already# download the update "ro& the registered users page # since it "i+es so&e i&portantproble&s.

    ,ou can develop reports with Rave using two di""erent ways: Code Based or with the isual esigner. This docu&ent describes how to work with thecode based engine. Part II will describe the isual esigner.

    Code Based Reportsith Code Based# you write reports using plain elphi code. That provides a very "le+ible way displaying any kind o" data# allowing any kind o" co&ple+

    layouts.To write a code based report# /ust drop a TRv%yste& co&ponent on the "or& and writ e the report on the 0nPrint event handler. %ender is the report youare creating# and can be typecasted to TBaseReport. It contains all the &ethods you need to output in"or&ation to that particular r eport.

    Simple Code Base Report1ere's a si&ple report using the code based &echanis&:

    procedure TFormMain.RvSystemPrint Sender! T"#$ect%&

    begin with Sender as T'aseReport do begin SetFont ()ria*( + 1,%& oto / 1+1%& Print ( e*come to ode 'ased Reporting in Rave( %& end &end &

    To e+ecute this report# call Rv%yste&.2+ecute &ethod.%o# what does that si&ple code do3 4irst# it calls %et4ont to select the "ont and si5e o" the te+t that will be printed "ro& that point on. Then it positions thecursor on the coordinates 67#78. These coordinates are e+pressed using the units set in the %yste&Printer.9nits property o" the Rv%yste& ob/ect# and itde"aults to Inches. ,ou can set it to un9ser and set a nu&ber relative to Inches in the %yste&Printer.9nits4actor property. 4or e+a&ple# i" 9nits4actorwas set to ).( then 7 unit would correspond to hal" an inch. 4inally# the code calls the Print &ethod to output the te+t. 1ere's the output:

    Tabular Code Based Report1ere's another e+a&ple. It displays a list o" the "olders in the root o" the current drive# along with a recursive count o" nu&ber o" "iles and "older# and totalsi5e o" the "iles included in each "older.

    procedure TFormMain.PrintTa#u*arReport Report! T'aseReport%&var Fo*der ist ! TString ist& i ! Integer& 3umFi*es ! ardina*& 3umFo*ders ! ardina*& Si eFi*es ! ardina*& Root ! string &begin with Report do begin SetFont ()ria*( + 1,%& 3e5 ine& Print enter ( ist o6 Fo*ders in t7e 8rive Root( + 4%& 3e5 ine&

    http://gp.codegear.com/authors/edit/1784.aspxhttp://gp.codegear.com/authors/edit/1784.aspxhttp://bdn.borland.com/article/0,1410,29792,00.htmlhttp://bdn.borland.com/article/0,1410,29792,00.htmlhttp://bdn.borland.com/article/0,1410,29792,00.htmlhttp://www.borland.com/products/downloads/download_delphi.htmlhttp://www.borland.com/products/downloads/download_delphi.htmlhttp://www.borland.com/products/downloads/download_delphi.htmlhttp://bdn.borland.com/article/0,1410,29792,00.htmlhttp://www.borland.com/products/downloads/download_delphi.htmlhttp://gp.codegear.com/authors/edit/1784.aspx
  • 8/11/2019 Introduction to Rave Reports

    2/13

    P a g e | 2Introduction to Rave Reports - 2004

    3e5 ine& *earTa#s& SetTa# 0.2+ p$ e6t+ 1.9+ 0+ 0+ 0%& SetTa# 1.9+ p$Rig7t+ :.1+ 0+ 0+ 0%& SetTa# :.1+ p$Rig7t+ :.,+ 0+ 0+ 0%& SetTa# :.,+ p$Rig7t+ 4.,+ 0+ 0+ 0%& SetFont ()ria*( + 10%& 'o*d !; True&

    PrintTa# (Fo*der 3ame( %& PrintTa# (3um#er o6 Fi*es( %& PrintTa# (3um#er o6 Fo*ders( %& PrintTa# (Si e o6 Fi*es( %& 'o*d !; Fa*se& 3e5 ine& Fo*der ist !; TString ist. reate& try Root !; Inc*udeTrai*ingPat78e*imiter i?%+ 3umFi*es+ 3umFo*ders+ Si eFi*es%& PrintTa# Format (Au( +>3umFi*es?%%& PrintTa# Format (Au( +>3umFo*ders?%%& PrintTa# Format (Au #ytes( +>Si eFi*es?%%& 3e5 ine& end & nally Fo*der ist.Free& end & end &end &

    otice that a di""erent approach has been taken: instead o" speci"ying the coordinates o" each te+t output# the printing was done using Lines andColu&ns as re"erences. The line heigh depends on the si5e o" the current "ont: each unit r epresents 7;!et4olderIn"o# on CodeCentral.Graphical Code Based Report,ou can include shapes and i&ages in your code based report# along with the te+t. The "ollowing e+a&ple de&onstrates that:

    procedure TFormMain.Print rap7icsReport Report! T'aseReport%&var 'itmap ! T'itmap&begin with Report do begin anvas.'rus7. o*or !; c* ray& Rectang*e 0.:+ 0.:+ 4.9+ :.:%& SetFont ()ria*( + 1,%& Font o*or !; c*Red&

    http://codecentral.borland.com/codecentral/ccWeb.exe/listing?id=20535http://codecentral.borland.com/codecentral/ccWeb.exe/listing?id=20535
  • 8/11/2019 Introduction to Rave Reports

    3/13

    P a g e | :Introduction to Rave Reports - 2004

    Print / 0.,+0.,+ (Bust *ooC at a** t7e grap7icsD( %& 'itmap !; T'itmap. reate& try 'itmap. oadFromFi*e (de*p7i.#mp( %& Print'itmap :.,+0.:+1+1+ 'itmap%& Print'itmap 1+2+:+:+ 'itmap%& anvas.Pen. o*or !; c*'*ue& anvas.'rus7.'itmap !; 'itmap&

  • 8/11/2019 Introduction to Rave Reports

    4/13

    P a g e | 4Introduction to Rave Reports - 2004reports can be &ade standalone # and be used or updated independently o" your application# or even &ade available in a Intranet or in theInternet# using evrona's Rave Report %erver . 0" course# you can still have it saved in a "or&'s 4A.To get started with the Rave isual esigner# drop a TRvPro/ect in a "or&. This will be the link "ro& your application to the reports you aredeveloping. I" you want# you can add a TRv%yste& and link your RvPro/ect to it# through it's 2ngine property. The Rv%yste& is the ob/ectresponsible "or the general con"iguration o" the reports: the printer that is going to be used# the &argins# the nu&ber o" pages# and so on. Tostart a new pro/ect# double click the RvPro/ect you added to the "or or select Rave isual esigner... "ro& its conte+t &enu. This is theinter"ace that you will be working on:

    The inter"ace is si&ple# and you &ight be "a&iliar with so&e parts o" it "ro& elphi's I 2. 0n the top there's the &enu# the toolbar# and the

    co&ponent pallete that contain the co&ponents that will be used in the reports. In the le"t there's the 0b/ect Inpector# which will be used toad/ust the properties o" the co&ponents o" the report. In the &iddle there's the Page esigner or the 2vent 2ditor# and in the le"t there's the veryuse"ull Pro/ect Treeview. 4or a @uick overview o" the co&ponents in the pallete# you can go to evrona's isual esigner page.

    ? Rave Pro/ect 4ile can have one or &ore reports. That way you can keep co&&on ite&s between the& in a single location# called >lobalPages. I" you e+pand the Report Library node o" the Pro/ect Treeview# you can see that right now you are working on Report7. Clicking on it# itsproperties will show on the Inspector. Let's change it's na&e and call it %i&pleReport. e+t# go to the %tandard tab on the Co&ponent Pallete#and pick a Te+t co&ponent and add it to the page. Change its te+t property# and ad/ust its si5e and position. 1ere's how &ine looked like:

    ?s you can see# the properties that were changed "ro& the de"ault values are shown in bold. In this case# I changed the 4ont# Te+t and Truncateproperties. By de"ault it does not highlight a&e# Pos and %i5e changes. I" you'd like to see the right click the Inspector and uncheck

    2+clude a&e# %i5e and Pos changes in the conte+t &enu.

    ,ou &ight have also noticed that Rave does not have an auto si5e property. ,ou can use the Truncate property to have that e""ect: i" truncate is"alse# the design ti&e si5e will have no e""ect.

    http://www.nevrona.com/rave/server.htmlhttp://www.nevrona.com/rave/server.htmlhttp://www.nevrona.com/rave/server.htmlhttp://www.nevrona.com/rave/designer.htmlhttp://www.nevrona.com/rave/designer.htmlhttp://www.nevrona.com/rave/server.htmlhttp://www.nevrona.com/rave/designer.html
  • 8/11/2019 Introduction to Rave Reports

    5/13

    P a g e | ,Introduction to Rave Reports - 2004,ou can see the result o" this si&ple report right on the designer: Press F9 or use File/Execute Report to run it. ow let's do it in ourapplication. %ave your pro/ect and return to elphi. Change to Pro/ect4ile property o" RvPro/ect to point to the "ile you /ust saved. To run thereport# add a call to the 2+ecute &ethod o" the RvPro/ect ob/ect in a button click# "or e+a&ple.

    RvPro/ect.2+ecute will only work "or now because we only have one report in this pro/ect. I" we had &ultiple reports# we'd have to call%electReport to choose one be"ore calling 2+ecute# or calling 2+ecuteReport directly.

    1ere's the output:

    Tip: I" you Close and 0pen your pro/ect be"ore e+ecuting# you won't need to to reco&pile your application or restart it to see the changes you /ust &ade in the designer.

    Interacting with the ProjectI" you worked with $uick Reports# you &ight be used to &anipulating the ob/ects in runti&e# changing their Position# Te+t and isibility. ?"ter all#they were /ust T0b/ects hile this is possible with Rave# and I'll cover it in a later article# it's a little harder than it was with $R. But don't worry#Rave provides a di""erent answer to this kind o" proble&s.

    ParametersI" you can use para&eters in your reports. They can be de"ined using the para&eters property o" either the Pro/ect# a Report or a Page.Para&eters can be de"ined in either o" these places# they are /ust in &ultiple places "or easier access.

    ,ou can only select the Pro/ect and a Report through the Pro/ect Treeview. ? page# however# can be selected using the Pro/ect Treeview orclicking on it's title above the page designer.

    ?&ong other uses# you can print para&eters. %o# "or instance# i" the title o" your report can be user-de"ined# you could pass it "ro& yourapplication into the report as a para&eter.Let's add a new report to this pro/ect to see how para&eters work. To do that# click the "ourth button on the toolbar or choose 4ile; ew Report.Call it Para&etri5edReport# changing its na&e through the ob/ect inspector. This report is going to be very si&ilar to the "irst one# e+cept the te+tis going to be user-de"ined.

    ow we need to de"ine the para&eter that is going to be printed. To do that# still having the report as the selected ob/ect# open the propertyeditor the the para&eters property. There should be listed all para&eters o" this report# each on a separate line. ?dd a para&eter called a&e#like this:

    Para&eters can be printed using a ataTe+t co&ponent# available in the Report tab o" the co&ponent pallete. ?dd a ataTe+t to the page# andopen the property editor o" the ata4ield property. There you can choose which "ield is going to be printed# when working with ata?warereports 6which will be covered on Part III o" these series8. ,ou can also choose Pro/ect ariables# Para&eters and Post-Initiali5e ariables "ro&there.%o choose the para&eter added previously "ro& the Para&eters drop-down co&bo and press the Insert Para&eter button. The data te+te+pression is now Param !ame 6we are going to change that a little later8. Press 0D and try to e+ecute the report# as be"ore. othing isprinted# since the para&eter has not been set.

    e need to set this para&eter be"ore printing. on't "orget to save your changes# and return to elphi# adding a call to %electReport be"ore2+ecute# so we can see the right report. Be"ore e+ecuting# though# we need to set the para&eter we added. That is &ade using RvPro/ect's%etPara& &ethod. This is how &y code looks like right now:

    procedure TFormMain.#tn

  • 8/11/2019 Introduction to Rave Reports

    6/13

    P a g e | EIntroduction to Rave Reports - 2004

    end &ow# when we e+ecute the report# we are going to see the string we set as a para&eter printed.

    Tip: ,ou can use RvPro/ect.>etReportList to get a list o" avaible pro/ects# and add the& to a Co&boBo+# or a Radio>roup# "or e+a&ple. That&akes selecting the report easier.

    But this is too si&ple. Let's change the e+pression that is going to be printed. Return to Rave esigner and open the property editor "or theataTe+t we added. ,ou can add any te+t you want# co&bining te+t# "ields# para&eters and variables. I changed it to this:

    1ere's the result:

    Post"#nitiali$e %ariablesPost-Initiali5e ariables# or si&ply PI ars# are variables whose value is only known a"ter the report has already been printed. It &ay soundstrange# at "irst# but think about the nu&ber o" pages o" a report# "or e+a&ple. e can only know it's value a"ter the report is ready. ?ctuallyTotalPages is a report variable that acts like a PI var# and can easily be printed using ataTe+ts as we did with Para&eters.Global Pa&es

    hen you have parts o" reports that are co&&on to two or &ore reports# you can put these in a global page. Let's supose we have a headerwith our co&pany na&e# the date and ti&e that report is being printed# the current page and the nu&ber o" pages o" that report. e want thatheader to be in every report. 1ow can we do it34irst# add a global page to the pro/ect# using 4ile; ew >lobal Page# or the Toolbar shortcut. In that page# add a section co&ponent# available inthe standard tab o" the co&ponent pallete.

    %ections are logical groupings o" co&ponents. they can be used to group co&ponent so they can be easily &oved around the report# or ascontainers "or Airrors# as we are doing right now.

    Inside that section we add what we want to be printed. In this case# a "ew ataTe+ts. Ay header looks like this:

    1int: Instead o" changing the "ont property o" several co&ponents to the sa&e "ont# link the& to a 4ontAaster co&ponent# available in thestandard tab# and set the "ont on it. That way is easier to change the "ont in the "uture# in case it's needed.

    ow add another section to the Page7 o" %i&pleReport. %et its Airror property to >lobalPage7.%ection7. ,ou will see a copy o" the header youcreated in the global page. o the sa&e thing to Para&etri5edReport. ow both reports share the sa&e header. 1ere how it looks like "or &e:

    Conditional Printin&

  • 8/11/2019 Introduction to Rave Reports

    7/13

    P a g e | 9Introduction to Rave Reports - 2004%o&eti&es we need to print certain parts o" a reporting depending o" so&e conditions. Rave has a very power"ul way o" dealing with this. ecan conditionally &irror sections depending on "ield values or para&eters. Let's create a new Report# calling it a ConditionalReport.Let's pretend that this new report is a trick one. The user can choose the header that is going to be printed# "ro& two di""erent kinds o" headers.1e can also choose "or the report to be printed without a header. e are going to use a para&eter to tell the report what kind o" header is goingto be printed# and a ataAirror%ection to select the proper header at runti&e.4irst# add a para&eter to this new report called 1eaderDind. Let's assu&e that it will have the values 1) 6"or no header8# 17 6"or the "irstheader8# 1< 6"or the second kind o" header8. ow add a new section to the global page 6you can reach it through the Pro/ect Treeview8# with thesecond kind o" header layout. I created a header si&ilar to the "irst one# changing the "ont title and adding a border around the values. It lookslike this:

    ow return to the Page7 o" ConditionalReport# and add a ataAirror%ection# available at the Report tab o" the co&ponent pallete. >o to itsata4ield property editor# and set Param 'eader(ind as the e+pression. ow go to the ataAirrors property editor# and add two ata Airrors:

    i" the value is 17# it should point to the "irst header# 1

  • 8/11/2019 Introduction to Rave Reports

    8/13

    P a g e | Introduction to Rave Reports - 2004

    Introduction to Rave Reports - Part III: ata ?ware ReportsBy: Leonel TogniolliAbstract: This is a introduction to Rave Reports. Part III describes how to create ata ?ware Reports using river ata iews - by Leonel Togniolli

    Introduction to Rave Reports - Part III: Data Aware R eportsIn the previous articles# I have shown how do the Code Based engine and the isual esigner work. In this docu&ent# I'& going to e+plore the ata-

    ?ware capabilities o" Rave Reports.

    The Database C onnection

    There are two ways to access data "ro& inside a report: you can share the sa&e connection established by your application# "etching records "ro&atasets that e+ists in your 4or&s or ata&odules# or you can con"igure a new connection on the report# allowing it to be independent o" a particularapplication. 4or the "irst &ethod you would use a )irect )ata %ie* # and a )ri+er )ata %ie* "or the second. ata iew is the analog o" a

    ata%ource; ata%et co&bination inside the report.

    I" you intend to deploy your application using evrona's Rave Report %erver # you should use river ata iews.

    The )ri+er )ata %ie*Let's create a si&ple database report using a river ata iew. %tart the Rave isual esigner# and start a new pro/ect. e need to de"ine the databaseconnection. To do this# choose 4ile; ew atabase 0b/ect# or press the si+th button in the toolbar 6the purple cube8. The )ata Connections window willappear:

    Choose )atabase Connection # and you will be asked which ata Link you are going to be using. There is a "older called ataLinks where Rave hasbeen installed# containing so&e "iles with the .rvd e+tensions# responsible "ro& the connection &echanis&. By de"ault# you can choose between B 2#

    b2+press and ? 0. I'll be using B 2 "or this e+a&ple. Choose B 2# press 4inish# and the atabase Connection Para&eters window will show up.2very ata Link has a di""erent set o" connection para&eters available# si&ilar to those available in the elphi I 2. 4or now# /ust set ?lias to b e&osand press 0D. otice that a atabase ob/ect has been added to the Pro/ect Treeview# under ata iew ictionary:

    otice that the settings you con"igured in the atabase Connection Para&eters# a"ter the wi5ard# including userna&e and password# i" aplicable# weresaved in the ?uth esign property o" the atabase co&ponent. In the ?uthRun property you can use di""erent settings to be used at runti&e# when yourreport has been deployed.

    e are going to create now the river ata iew. Click on ew ata 0b/ect# then choose )ri+er )ata %ie* . ,ou should now choose the atabaseConnection that is going to be used by this ata iew: choose the atabase created in the previous step. ? $uery ?vanced esigner will show up. ragand rop the table custo&er.db "ro& the table list to the Layout window. It should look like this:

    http://gp.codegear.com/authors/edit/1784.aspxhttp://gp.codegear.com/authors/edit/1784.aspxhttp://www.nevrona.com/rave/server.htmlhttp://www.nevrona.com/rave/server.htmlhttp://www.nevrona.com/rave/server.htmlhttp://gp.codegear.com/authors/edit/1784.aspxhttp://www.nevrona.com/rave/server.html
  • 8/11/2019 Introduction to Rave Reports

    9/13

    P a g e | Introduction to Rave Reports - 2004

    I" you have &ore than one table# you should drag and drop "ields that should be /oined between tables. I" you press the Editor button you can check thegenerated %$L# or type-in a &ore co&ple+ @uery. Let's keep the si&ple Custo&er Listing "or now. Press 0D and a river ata iew will be added to thePro/ect Treeview# below the atabase co&ponents# having the selected "ields as subite&s:

    otice that I rena&ed the atabase Connection and the ata iewto &ore appropriate na&es. It's in the Treeview where properties o" the "ields should

    be set# like the isplay Label 6 Full!ame property8# and the )ispla,Format .Re&ions and Bands

    Report co&ponents that should be printed in a "i+ed position in every page# like "i+ed headers and "ooters can be put directly in page. Co&ponentswhose position will be dependent o" previously printed ite&s# should be put in bands. ataBands will be printed once "or every record in the linked

    ata iew# while regular Bands will only be printed once# regardless o" how &any records have been selected. Both can contain ata-?ware co&ponents6like ataTe+t8# or regular co&ponents 6like Te+t8.Bands should be put inside Regions. Regions deli&itate the width o" the bands# and the &a+i&u& height that bands can use be"ore starting a new page.0ne page can have &any Regions# and one Region can contain &any Bands.

    ?dd a Region to the Page covering its whole area. Inside the region add a Band# to be used as the report header# a ataBand# to print the custo&erin"or&ation# and another Band# the report "ooter.

    I" you wish to change the ordering o" e+isting bands in a report# use the -o+e For*ard and -o+e Behind buttons in the ?lig&ent Toolbar.

    Rena&e the bands to &ore &eaning"ul na&es 6I used 1eader# Custo&er ata and 4ooter8. %et the )ata%ie* property o" Custo&er ata to vCusto&er#and set Custo&er ata as the ControllerBand o" the 1eader and 4ooter bands. ,ou should also run the Band %tyle 2ditor# "ro& the 0b/ect Inspector#and set the Print .ocation o" those two bands to Bod, 'eader and Bod, Footer # respectively. ,ou can have an idea on how the report is going to beprinted observing the Band isplay as you change the settings. I t shows iterating bands repeated three ti&es# and other bands only once:

    e also want the 1eader to be printed in other pages in case the listing spans &ore than one page: check the !e* Pa&e option in the Print ccurrencegroupbo+# in that sa&e dialog.

    The 4ooter band will only print when vCusto&ers has reached its end. I" you want it printed in every page# regardless o" that# /ust put the co&ponentsdirectly on the page# below the region# and not in a Band.

    In the editor# you can @uickly identi"y the relationship between bands# their styles and their print occurrences:

  • 8/11/2019 Introduction to Rave Reports

    10/13

    P a g e | 10Introduction to Rave Reports - 2004

    Addin& FieldsIt's not hard to add "ields to a report. ,ou can Ctrl0)ra& the "ields "ro& the ata iew# in the Pro/ect Treeview# to add ataTe+t co&ponents to the report#

    and Alt0)ra& the& to add Te+t co&ponents containing the 4ullna&e property. This allows you to @uickly create the layout o" the report. ow add so&e"ields to Custo&er ata and their titl e to the 1eader. I added Cust o# Co&pany# Phone# Ta+Rate and LastInvoice ate.

    on't "orget that you can use the tools on the ?lign&ent Toolbar to align the co&ponents# even i" they are in di""erent bands.

    I added a title to the 1eader band and a si&ple te+t to the 4ooter band# indicating that the listing has ended. Later on the series we are going to see howto use the Calc0p and CalcTotal co&ponents to be able to add totals# averages and other calculated values to the 4ooter.

    Addin& the Report to 1our Pro2ectTo add this report to your pro/ect you should use use the sa&e approach as seen in Part II: /ust use a RvPro/ect in a 4or& or ataAodule# link it to thereport "ile# and call i t's 2+ecute &ethod. But there is one gotcha when using river ata iews: your application &ust load the apropriate driver. To dothat# /ust add the unit Rv LB 2 to your uses clause# i" using B 2# Rv L BE i" using b2+press# or Rv L? 0 i" using ? 0.

    ConclusionsThis article has shown how to develop si&ple ata?ware reports. ,ou can "ind a pro/ect containing the report developed here on CodeCentral . Part Iwill de&onstrate the use o" irect ata iew# show how to &ake Aaster; etail reports# and how to calculate values to display totals and calculated "ields.

    Introduction to Rave Reports - Part I : Aore ata ?wareReportsBy: Leonel TogniolliAbstract: T7is is a introduction to Rave Reports. Part IJ s7o5s 7o5 to create MasterK8etai* reports using 8irect8ata Jie5s - #y eone* Tognio**i

    Introduction to Rave Reports - Part IV: More Data Aware Reports

    In Part III we have explored the data aware capabilities of Rave Reports, using the Driver Data iew! "n Part I we are goingto learn how to use Direct Data iews, the creation of #aster$Detail reports, and the use of %alc"P and %alcTotal co&ponents

    to display calculated values and totals!

    The Direct Data View

    The Direct Data iew allows you share the database connection established by your application, fetching data directly fro&the Data'ets in your application! (ou can lin) the& to any TData'et descendant, and, with so&e code, you can even fetch datafro& custo& Data'tructures, li)e arrays of records or T'tringLists! *part fro& that, it behaves in the way as the Driver Data

    iew we explored on Part III!

    Using DataSet Connections

    Let+s create a &aster detail report using Direct Data iews! %reate a new application, and set up a connection with your

    database using your favorite Db ra&ewor)! I+ll still be using BD-, for de&onstration purposes! *dd two tables .or /ueries, asyou prefer0, selecting data fro& the orders and ite&s tables! or each Data'et, add a corresponding TRvData'et%onnection,available in the Rave tab, in the pallete! 'et the property DataSet of each Data'et%onnection to the corresponding co&ponent,and give the& &eaningful na&es .I called the& dscIte&s and dsc"rders0!

    The na&e is i&portant: it is the your application lin) to the report! (ou won+t be able to have two Data'et connections, even indifferent reports, with the sa&e na&e, or you &ight run into trouble if so&eone tries to run both reports concurrently!

    *fter the Data'ets are set up, return to the Rave Reports designer! %hoose New Data Connection , and you should see theData'et %onnections you added to your for& in the Delphi designer:

    http://codecentral.borland.com/codecentral/ccWeb.exe/listing?id=21318http://codecentral.borland.com/codecentral/ccWeb.exe/listing?id=21318http://gp.codegear.com/authors/edit/1784.aspxhttp://gp.codegear.com/authors/edit/1784.aspxhttp://codecentral.borland.com/codecentral/ccWeb.exe/listing?id=21318http://gp.codegear.com/authors/edit/1784.aspx
  • 8/11/2019 Introduction to Rave Reports

    11/13

    P a g e | 11Introduction to Rave Reports - 2004

    'elect dscIte&s to create the first Data iew, then repeat the process to create the Data iew for dsc"rders! (ou should now seethe fields in the Pro1ect Treeview, under the newly created Data iews:

    Don+t forget to rena&e the Data iews to better na&es than Data iew2 and Data iew3!

    Creating the ands

    *fter the Data iews have been created, we should set up the bands! %reate a Region consisting of the whole page area, andadd one band .4eader0, two DataBands .#aster and Detail0, and another Band . ooter0! 'et the Contro!!er and property of4eader, Detail and ooter to #aster! 5sing the andSt"!e property editor, set the style of the 4eader band to od" #eader$ %, the style of the Detail band to Detai! $D%, and the ooter band to od" &ooter $'% ! 6otice how the and Disp!a" gives anice preview of how the bands are going to printed:

    (ou also need to lin) the DataView property of the #aster band to dv"rders, and the Detail band to dvIte&s! To create the#aster$Detail relashionship, set the MasterDataView property of the Detail band to dv"rders, and both the Master(e" andDetai!(e" properties to the field "rder6o!

    The &ontMaster Co)ponent

  • 8/11/2019 Introduction to Rave Reports

    12/13

    P a g e | 12Introduction to Rave Reports - 2004(ou proably want si&ilar ite&s .all the ite&s in the Detail Band, for exa&ple0, to print with the sa&e font! Instead of settingeach &ont property individually, you can you a ont#aster! *dd a ont#aster co&ponent to the page and set its &ont propertto Ti&es 6ew Ro&an, 27! In the next step, when adding the Text and DataText co&ponents, set their &ontMirror property tothe ont#aster! 6ow, if you ever change your &ind about the font that is going to be used in this report, you don+t need tochange it in every co&ponent, 1ust change it in the ont#aster and it will be reflect in every other co&ponent that is lin)ed toit! (ou can have as &uch ont#asters in one report as you need!

    The ont#aster is a 6on8 isual co&ponent, &eaning it won+t show in the Design *rea! If you need to reselect it, you will

    have to do it through the Pro1ect Tree iew!

    Adding the DataTe*ts

    6ow its 1ust a &atter of adding Text and DataText co&ponents to the bands! Don+t forget you can drag8and8drop .while pressing the ctrl and alt )eys0 fro& the Pro1ect Treeview to create the&! I added "rder6o, 'aleDate, Ter&s, Pay&ent#ethod,*&ountPaid and reight to the #aster band, and Ite&6o, Part6o, 9ty and Discount to the Detail band! Don+t forget that theDisp!a"&or)at of float fields is set in the fields the&selves, in the Pro1ect Treeview, and not in the DataText co&ponents!

    Adding Tota!s and Ca!cu!ated &ie!ds

    (ou can &a)e calculations and aggregated values using the %alc"P and %alcTotal co&ponents, available on the Report tab!The result of these calculations can be outputted to para&eters, PI ars, or used as inter&ediate result for other calculations!

    e are going to output the& to para&eters, so select your report in the Pro1ect Treeview and add two para&eters, called*&ountPaidTotal and reightTotal:

    6ow add two %alcTotal co&ponents to your the ooter band, and set their Contro!!er property to the #aster band, theirDataView property to dv"rders, the Data&ie!d to *&ountPaid and reight, and the DestPara) to the para&s you createdearlier, *&ountPaidTotal and reightTotal! It+s also in the %alcTotal co&ponent where you define the Disp!a"&or)at of thevalue printed!

    6ote that the %alc co&ponents are evaluated in the order they appear in the Pro1ect Treeview! If a %alc"p result is going to printed by a DataText co&ponent, &a)e sure it appears in the Treeview before it! (ou can use the buttons #ove orward and#ove Behind fro& the *lign&ent Toolbar to change their order!

    (ou can now add in the ooter Band two DataText co&ponents to print those variables! 6otice that is has su&&ed the values,and you can define through the Ca!cT"pe property of the the %alcTotal co&ponents the operation you would li)e to perfor&!

    The sa&ple data included in the DbDe&os does not have a value for reight in any of the records! eel free to edit a fewrecords to see the& added up!

    6ow let+s suppose we need to su& both totals, and display the& in the footer band! *dd a new para&eter called Total to thereport and a %alc"p co&ponent below the %alcTotal co&ponents, in the ooter band, and set the Src+Data&ie!d toPara&!*&ountPaidTotal, and Scr,Data&ie!d to Para&! reightTotal! 'et the DestPara) property to Total, and theDisp!a"&or)at of the value! *dd a DataText to print this value!

    &inishing Up

  • 8/11/2019 Introduction to Rave Reports

    13/13

    P a g e | 1:Introduction to Rave Reports - 2004To add the report to your pro1ect, 1ust do the sa&e as was done in the previous reports: 1ust lin) it in a RvPro1ect and call theexecute &ethod! (ou &ight want to filter the Data'et based on user input, but that+s the sa&e way as you always done before!

    Conc!usions

    e have seen how to create Data*ware reports using Direct Data iews, how to set up &aster$detail relationships, and how touse %alc co&ponents! (ou can find a pro1ect containing the report developed here on %ode%entral ! Part will de&onstrate the

    use of %usto& %onnections and so&e other tric)s!

    http://codecentral.borland.com/codecentral/ccWeb.exe/listing?id=21330http://codecentral.borland.com/codecentral/ccWeb.exe/listing?id=21330http://codecentral.borland.com/codecentral/ccWeb.exe/listing?id=21330