Simple Application Example

book list add book to my bookshelf create a bookmark purchase this book online

mastering crystal reports 9
Chapter 17 - The Crystal Programming Forest
Mastering Crystal Reports 9
by Cate McCoy and Gord Maric
Sybex 2003

If you have used Crystal Reports only as report writer, you might be wondering how Crystal Reports can be used with an application. Figures 17.1 and 17.2 display a Crystal Report in a reporting system. This system uses VistaNations travel reports that we created in previous chapters. The application groups management reports in an easy-to-use system where managers can choose the report they would like to see and click the Refresh button to view it. Notice in Figures 17.1 and 17.2 that users can choose to see All countries, North America, or Others. Behind the scenes, the programmer has written code to modify the Crystal Reports selection formula. The end user does not need to know how to use Crystal Reports or even what a selection formula is. The programmer can provide a simple-to-use interface.

The report in our example is displayed in a Windows Forms Viewer for the Windows application and a Web Forms Viewer for the browser application. The viewers are components that display Crystal Reports and are included with Crystal Reports Developer Edition. They can be programmed and controlled in the application as well as in the Crystal report itself.

click to expand
Figure 17.1. A Windows application displaying a Crystal report

Warning 

Before you can use Crystal Reports in your custom application, you must have the Developer or Advanced Edition of Crystal Reports. See the section “Licensing Issues” later in this chapter for more details.

Crystal Reports has been providing report-writing capabilities to custom applications from companies like PeopleSoft, Great Plains Software, ACCPAC International, and over 150 other applications. The developers of these applications focus on the core business functionality of the application and let Crystal Reports focus on the details of the reports. You can use Crystal Reports for your custom applications in the same way as these commercial applications use it.

click to expand
Figure 17.2. A web application displaying a Crystal report

Using Crystal Reports in an Application

Crystal Reports exposes all report-writing functionality to a development language. Anything that you can do with Crystal Reports as an end user you can also do with a development language. In our example in Figures 17.1 and 17.2 we are modifying the selection criteria formula and refreshing the report from the database. You can add groups, modify graphics, etc., through program code, and your application provides a custom user interface to the Crystal functionality. For example, the user is able to change the selection criterion from All to North America and click the Refresh button. The code behind the buttons modifies the selection criteria in Crystal Reports and redisplays the report with the required data. This provides an easy-to-use interface instead of you having to teach all your end users how to write selection criteria in Crystal Reports.

Crystal Development Platforms

Crystal Reports supports the following development platforms: Windows, .NET, and Java.

Windows

By Windows we mean an application or program that is installed on the user’s (client’s) computer and runs inside Microsoft Windows. Sometimes this is referred to as a thick client because code has to be installed on the end user’s computer. Crystal Reports 9 supports two separate Windows development platforms: legacy Windows and .NET. From an end user’s perspective there is no difference; the platforms start and run the application and it behaves like any other Windows application. However, from a developer’s perspective they are completely different.

.NET

In spring 2002, Microsoft released a brand-new development platform called .NET (pronounced dot net). They recognized that development environments have changed drastically with the introduction of the Internet. Since 1995, Microsoft has added Internet functionality to development language tools, but Internet functionality was not always well integrated or easy to use because the tools were not designed with the Internet in mind. They recognized the need to clean the white board and redesign an entire environment from an Internet perspective. .NET Framework is that new environment. .NET includes new system components that run in Windows and Microsoft’s IIS (Internet Information Server) web servers. A new development language has been created called C# (C Sharp), and Visual Basic has been rewritten to run in .NET. The new version is called VB.NET. Crystal Reports 9 was also written to work in the new .NET environment.

Note 

Crystal Report is the only third-party product to be bundled with Microsoft’s Visual Studio .NET development environment.

Legacy Windows

We refer to legacy Windows as any development environment that uses Windows COM (Component Object Model) components and Windows APIs (applications programming interfaces) instead of the .NET Framework. Visual Basic 6 and C++ fall into the legacy category. Crystal Reports 9 is also written to support a COM-based programming interface for VB6 and C++ and any language that uses COM. Both development environments of Crystal Reports 9, .NET and legacy Windows development, offer similar functionality but they run on different platforms.

Over the years Crystal Reports has evolved along with Visual Basic, and a number of programming interfaces have been developed with the evolving technologies. For legacy Windows development as of version 9 of Crystal Reports, the only supported development environment is the Report Designer Component (RDC) introduced in version 8 of Crystal Reports. The RDC is a COM-based interface that replaces all the development environments previously introduced. Chapter 19 is devoted to the RDC. Table 17.1 lists the retired development environments.

Table 17.1: Retired Windows Development APIs

API

Comments

Report Engine API

This was called the CRPE API (Crystal Reports Programming Engine API (aka Creepy). It is a Windows DLL-based programming interface. Your program must call DLL subroutines and functions. These are low-level C++ functions that are not easy to work with. The CRPE API is very powerful but also very difficult to use. Initially this was the only way to manage Crystal Reports programmatically.

Report Engine Automation Server

Microsoft developed the COM standard and Crystal Decisions followed with the Report Engine Automation Server. This was an object-oriented programming approach to programming Crystal Reports. It has not been upgraded to version 8 of Crystal Reports.

ActiveX control

Until the RDC came out, this was the easiest way to manage Crystal Reports in your application. A Visual Basic program would add the Crystal Reports ActiveX control to the VB toolbar and then add it to the form. By setting a few properties, you could easily display Crystal Reports. Because of its simplicity, there was limited functionality.

Design Time Control for Microsoft Visual Interdev

The Design Time Control simplified adding a report to an ASP page in Visual Interdev. (We cover how to manually add a report to an ASP web page in Chapter 20.)

RDC Runtime C Headers

No longer supported as of Crystal Reports 9

Web-Based Applications

A web application is an application that the end user accesses via a web browser, such as Internet Explorer or Netscape Navigator. This is sometimes called a thin client application because no software, or very little software, is installed on the client’s computer. Crystal Decisions has two products that can be used in web application development: Crystal Reports and Crystal Enterprise.

Crystal Enterprise is a web-based application that houses and runs Crystal Reports on a web server. Chapter 23 discusses Crystal Enterprise. With Crystal Reports 8.5, Crystal Decisions shipped the standard version of Crystal Enterprise. With version 9 of Crystal Reports, Crystal Decisions ships the Report Application Server (RAS), which is an entry-level version of Crystal Enterprise. You can purchase the standard or professional version for Crystal Enterprise. The RAS server supports a Microsoft and Java development Environment. Chapter 24 discusses programming RAS.

Tip 

The Professional, Developer, and Advanced editions of Crystal Reports received the Report Application Server. Refer to Appendix A for the breakdown of versions.

Also, with the release of .NET, Microsoft web applications development has two separate environments: legacy Active Server Pages (ASP) and ASP.NET. Crystal Reports 9 supports both environments.

Are you confused yet? Table 17.2 summarizes the development environments supported.

Table 17.2: Application Development Choices

Microsoft Environment and Crystal APIs

Comments

RDC

Can be used in ASP or legacy Windows applications

RAS

Used for Web applications and provides an easy transition to Crystal Enterprise Standard and Professional

.NET

Fully integrated with ASP.NET and Windows applications

RAS

sed for Web applications and for web deployment of reports. RAS also provides an easy transition to Crystal Enterprise Standard and Professional editions.

Note 

It will be interesting to see how .NET evolves over the next decade and whether we will have a long list of technologies to choose from as we do with legacy Windows development or whether the design is good enough to handle a decade of computer changes. Only time will tell. Our bigger concerns now are migration issues from legacy Windows to .NET.

XML Web Services

Large-scale, or enterprise, applications have been developed with a three-tier systems development model for years. In that model the system is separated into three parts representing three logical or physical tiers: the client graphical user interface, the business logic and functions, and the database access. The advantages of this design are that the client’s graphical user interface can change from a Windows application to a web application or support both Windows and web applications, and there is only one set of business rules on the second tier. Changes in the business tier are automatically reflected in all clients.

The disadvantage to this type of model (apart from being complicated to design) is that the client and business services communicate using proprietary protocols. The two main protocols in the industry are Microsoft’s DCOM (Distributed Component Object Model), used in Microsoft’s development, and CORBA (Common Object Request Broker Architecture), used in Java development. They do not communicate with each other.

XML web services are the business components in the three-tier application model. They can be accessed via a newly developed Internet protocol, SOAP (Simple Object Access Protocol), that the industry has agreed upon. Microsoft and Java can share components that are written as XML web services. An example of a web service might be where a bank creates a web service program that accepts a credit card number and the amount of the purchase. An application written by a programmer, which follows web services standards, then can call the web service and tell the bank’s web service the credit card number and the amount of the purchase. The web service then tells the client program whether the credit card transaction is accepted or declined. Because the web service is using industry standards, it does not matter whether the client program is a Microsoft program or a Java program. A web service is a way of publishing functionality on the Web and letting any client access the functionality no matter which language it is written in.

Crystal Decisions has embraced the web service concept for Crystal Reports. Crystal Reports can be published on the Web as a web service, and any application on the Internet that understands web services can retrieve your report and display it, as shown in Figure 17.3. (Of course, you can add security to prevent just anyone from accessing your report.)

click to expand
Figure 17.3. A web service

In the following chapters we will see how to implement all these types of applications.

.NET or VB6?

It is best to consult with your Information Technology department to determine when they are planning to move to .NET. Upgrading an existing VB6 application that uses Crystal Reports 8.x RDC’s (Report Designer Component) Report designer is not possible because the .NET environment does not support Designers from VB6. Your only option is to rewrite the application for .NET or continue to run the application in VB6. Crystal Reports 9 has components that will work in both environments.

If you access Crystal Reports via RDC’s automation server (see Chapter 19 for a complete list of components included with the RDC) and did not use the Report designer, or used the Report Engine API or the ActiveX control, upgrading would be possible. However, we would not recommend it, because the .NET upgrade wizard adds a layer of compatibility code for .NET so it works with legacy components, and this code is not always efficient.

Note 

Microsoft has recognized that legacy Windows will not go away for a long time because of the huge number of systems in use. They have pledged to support both .NET and COM environments for many years, and Crystal Decisions will support both also.

Development Languages

Because Crystal Reports supports both legacy Windows and .NET, we need to look at language options in both environments. (Who said it was going be easy?)

Legacy Development

Crystal Reports’ developer components work with Windows development languages such as Visual Basic, C++, and Inprise Delphi. Basically any language that can use a Windows COM component should be able to work with Crystal Reports. In ASP applications you can use VBScript, JavaScript, or JScript.

.NET

The .NET environment was written to be language neutral—you can use any language in the .NET environment. VB.NET and C# are the two main choices. However, other languages are being written for the .NET environment.

Java

Crystal also supports Java for the Crystal Report Viewer Java Bean (or Report Viewer Bean). The Java report viewer can be added to an application in any development environment that supports Java version 1.1. Java is also used for the Remote Application Server (RAS).

Our Choice

The most popular development language for Crystal Reports is Visual Basic in legacy applications and VBScript for ASP applications. We are going to use Visual Basic, VBScript, and Visual Basic.NET for our examples in this book.

Licensing Issues

With version 9 of Crystal Reports, Crystal Decisions has introduced two developer licenses: the Developer and Advanced Developer licenses. Licensing has also been broken down depending on which platform the application is running on.

Environment

License

Comment

Windows Applications (.NET and Legacy)

Developer

If you use RDC in your Windows application to display reports, change selection criteria, or modify graphics, you are free to compile Crystal Reports in your application and distribute the application royalty free.

 

Advanced

If you are using the RDC to create reports, then you will need to purchase the report creation API license from Crystal Decisions before you deploy your applications.

RDC and .NET

Developer

Can only create a single instance of each component on a single server.

RAS

 

Intended for testing and development only. Report requests in excess of five simultaneous requests are denied.

RAS

Advanced

Excess requests are queued; can upgrade to multiprocessor or Crystal enterprise for larger user base.

Note 

For the complete details on licensing, refer to license.chm in C:\Program Files\Crystal Decisions\ Crystal Reports 9\Developer Files\Help\en (this is the standard directory; your directory might be different). Refer to "Runtime File Use Restrictions" for a complete list of functions that require the Report Creation License.

Development Skills Summary

Tables 17.2, 17.3, 17.4, 17.5, 17.6, and 17.7 summarize the technical skills that are required to build Windows or web applications with Crystal Reports and RAS. We cannot possibly teach these technologies in this book. We are summarizing the technologies to help you understand what you need to learn in order to use Crystal Reports to its maximum potential in your applications.

Table 17.2: Windows Development Requirements

Windows Development

Comments

Visual Basic, C++, or Delphi

Visual Basic is the most popular language used to develop Crystal Reports.

Database (SQL, stored procedures)

A good understanding of databases and SQL is necessary. Knowing how to write and use stored procedures is a benefit and will improve the performance of your reports.

ADO (ActiveX Data Objects)

If you are developing reports in a Microsoft environment, understanding ADO will be beneficial because Crystal Reports can report from ADO datasets.

Table 17.3: ASP Development Requirements

ASP Development

Comments

VBScript or JavaScript

ASP Consists of six objects that reside on Microsoft’s IIS web server. Dynamic web pages can be programmed using the ASP objects with VBScript or JavaScript. If you are familiar with VB, VBScript will be very easy to understand. If you know JavaScript, there is no need to learn VBScript, since you can use JavaScript to control the ASP objects.

Database (SQL, stored procedures)

See Windows Development above.

ADO

See Windows Development above.

HTML

A good understanding of HTML is required to build web pages.

Internet Information Server (IIS) basic administration

A basic understanding of security and physical and logical directories on IIS is required.

Table 17.4: .NET Windows Development Requirements

.NET Windows Development

Comments

Visual Basic .NET, C#, or any .NET language

VB.NET might be the most popular language for .NET, but C# is the next most popular. You can use any .NET language. If you have VB6 experience, you will find that the VB in VB.NET is completely different. VB6 and VB.NET share similar syntax and the name only; the rest is completely different!

Database (SQL, stored procedures)

See Windows Development above.

ADO

See Windows Development above.

ADO .NET

ADO was designed to be used in a client/server connected environment where the client and the server are always talking to each other. ADO.NET was designed for an Internet disconnected environment. ADO.NET is not a replacement for ADO. Use ADO.NET if your application will work with disconnected record sets.

.NET Framework

.NET Framework is a replacement for all Windows system DLLs. It is important that you understand this framework to be able to program in a .NET language.

Table 17.5: .NET Windows Web Development Requirements

.NET Windows Web Development

Comments

Visual Basic, C#, or any .NET language

See .NET Windows Development above.

Database (SQL, stored procedures)

See Windows Development above.

ADO

See Windows Development above.

ADO.NET

See .NET Development above.

.NET Framework

See .NET Development above.

HTML

See ASP Development above.

JavaScript

JavaScript is important in .NET if you are planning to write code that will execute on the client’s browser. If your application will perform only server-side processing, then you can use any .NET language.

Table 17.6: XML Web Services Development Requirements

XML Web Services Development

Comments

Visual Basic, C#, or any .NET language

See .NET Windows Development above.

XML

XML is a large set of technologies. From a web services point of view, it is important that you understand the structure of an XML file (document), WSDL (Web Services Description Language), and SOAP (Simple Object Access Protocol).

Table 17.7: Java Web Development

java Web Development

Comments

Java and Object Oriented Technology

Understanding of the Java language and OO concepts is mandatory.

Database (SQL, stored procedures)

See Windows Development above.

HTML

See .NET development above.

Web Server

Understand how to configure a web server.

Unix or Linux

A good understanding of the Unix or Linux operations systems is mandatory.

Use of content on this site is expressly subject to the restrictions set forth in the Membership Agreement
 
Conello © 2000-2003     Feedback


Mastering Crystal Reports 9
Mastering Crystal Reports 9
ISBN: 0782141730
EAN: 2147483647
Year: 2005
Pages: 217

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net