Creating Crystal Reports

Embed Size (px)

DESCRIPTION

Creating Crystal Reports. Tips and Tricks. Presented by Ben Rimmasch. Topics. When to Use Crystal Reports Getting Started with Crystal Reports Hands On Deploying Reports in CMC Best Practices Developing and Maintaining Versioning and Deploying Tips, Tricks and Strategies Questions. - PowerPoint PPT Presentation

Text of Creating Crystal Reports

PowerPoint Presentation

Tips and TricksCreating Crystal ReportsPresented by Ben Rimmaschwww.regoconsulting.comPhone: 1-888-813-0444

1When to Use Crystal ReportsGetting Started with Crystal ReportsHands OnDeploying Reports in CMCBest PracticesDeveloping and MaintainingVersioning and DeployingTips, Tricks and StrategiesQuestionsTopics# www.regoconsulting.comPhone: 1-888-813-0444

ProsVery flexible layout for when layout is importantSpecific deliverable formatFormsGraphicsConsNot customizable by the userChanges require deploymentMore time consuming than portlets

When to Use Crystal Reports# www.regoconsulting.comPhone: 1-888-813-0444

versusWhen to Use Crystal Reports (contd)

# www.regoconsulting.comPhone: 1-888-813-0444

Work Environment PreparationSetting data sourcesOracle Client and Java for Oracle databasesAdd a tnsnames.ora entry for each environmentSystem DSN for SQL ServerInstallation of Crystal EditorSetting Editor PreferencesOptions -> Fonts (so all reports have the same look and feel)Options -> Layout (to make editing easier)Getting Started with Crystal Reports# www.regoconsulting.comPhone: 1-888-813-0444

Creating Your First ReportTo wizard or not to wizard...All options are available and easy to get to without using the wizard. Its likely to not save you any time. Its likely to cost you time.As far as Crystal Reports go, friends dont let friends wizard.Save immediately (and often)See Tips Tricks and StrategiesGetting Started with Crystal Reports (contd)# www.regoconsulting.comPhone: 1-888-813-0444

Adding a Command and query parametersConsider the size of your dataset in choosing query parametersDetermine if a parameter would be single-select or multi-select. Script the SQL accordingly.When creating parameters in Clarity in the report definition for each parameter a data type must be chosen.For the data type of Browse or Pull-down a lookup must be specified.Parameters with lookups can be set to single-select or multi-select.Clarity will pass the hidden id of the lookup in the Browse and Pull-down parameter types to the Business Objects server.For all parameters the id of the parameter in the report definition must match the name of the parameter in the Crystal reportGetting Started with Crystal Reports (contd)# www.regoconsulting.comPhone: 1-888-813-0444

Adding a Command and query parameters (contd)For single-select lookups in filters the query might contain the following components:{?param_project} is NULL For testing when the parameter is optional and not supplied. This is only applicable INSIDE the editor because this will never be null from Clarity{?param_project} = 0 For testing when the parameter is option and not supplied from Clarity{?param_project} = invi.id To do the actual filtering of a single project For multi-select lookups in filters the query might contain the following components:0 IN {?param_project} For testing when the parameter option is not supplied from Clarityinvi.id IN {?param_project} To do the actual filtering of multiple projectsThe examples above assumed the hidden id in the lookup for the parameter was a lookup_enum and used 0. For lookups where the hidden id is a lookup_code use .Test the data source with one or two fields surfaced on the reportSetup groups (report grouping) as one of your first stepsGetting Started with Crystal Reports (contd)# www.regoconsulting.comPhone: 1-888-813-0444

Sample Query

select rim.name ,rim.description ,rim.impact_description ,rim.assumptions ,rim.resolution ,assignee.full_name assigned_to_name ,rim.created_date ,rim.priority_code ,case rim.priority_code when 'HIGH' then 3 when 'MEDIUM' then 2 when 'LOW' then 1 else 0 end priority_sort ,rim.impact_enum ,rim.impact_date ,i.name inv_name ,i.id inv_dbidfrom rim_risks_and_issues rimleft join srm_resources assigneeon assignee.user_id = rim.assigned_tojoin inv_investments ion i.id = rim.pk_idwhere 1 = 1and (rim.description is not null or rim.description '')and rim.type_code = 'RISK'and (i.id IN {?param_project} OR 0 IN {?param_project})Getting Started with Crystal Reports (contd)# www.regoconsulting.comPhone: 1-888-813-0444

Creating a reportNavigating the editorField ExplorerUsed to add items to the reportReport ExplorerUsed to edit or remove items already in the reportOptions (Editor-wide)FontsSet fonts for consistent look and feel across all reportsLayoutMake preference changes for easier editingSummary Options (Report specific)Report TitleOther fields as needed

Hands On# www.regoconsulting.comPhone: 1-888-813-0444

Section ExpertSuppress (vs Hide)Suppressing removes a section or field from view always. Hiding removes a section from view but leaves it available for drill-down.Print at Bottom of PageForces the section to be at the bottom of the page. All following sections will then be forced to the next page (or column)Keep TogetherDetermines when pagination will occurAll Keep Together values are essentially ignored once sections are placed in a group and the groups Keep Group Together option is checked.Group vs Parent Section vs Child SectionGroup will always try to print the entire group on the same pageParent will always try to print the children sections on the same page but when all sections are longer than a page it will page if necessary where the child section groups not set to keep togetherSuppress Blank Section (almost never applicable because all values have to be fields)Hands On (contd)# www.regoconsulting.comPhone: 1-888-813-0444

GroupsGroup BySection will be printed on any change of this field. Order matters! If the values have already been through a group or have been sorted and the field occurs in your records a few times and then again in your records two groups will be created for that field.OrderingOften a virtual field must be created for ordering to occur correctly in groups.Customize Group Name FieldVery useful when the virtual sorting field scenario comes into play.Keep Group TogetherOverrides almost all other keep together settingsRepeat Group Header on Each PageVery useful as a makeshift page header in subreportsUseful for breadcrumb or hierarchy data displayHands On (contd)# www.regoconsulting.comPhone: 1-888-813-0444

Menu and ButtonsInsert Text ObjectThe primary way to insert static text into a report.Fields and formulas can be dragged into text objects.Insert GroupOpens the group creation dialogue (see previous slide)Insert SummarySummary vs Running Total FieldsSummary fields can be used anywhere and the values have already been calculated. Very limited options compared to running total fields.Depending on where you put a running total field the values may not have accumulated. This is sometimes desirable and sometimes not.Insert SubreportRestricted to parent report and one level below. Subreports may not contain subreports.Subreports dont have page headers or footers.Once a subreport is placed parameters, fields and formulas from the main report can be passed to the subreport as parameters by right clicking the subreport and changing the subreport links. Data types of parameters must match.Hands On (contd)# www.regoconsulting.comPhone: 1-888-813-0444

Menu and Buttons (contd)Insert Line and Insert BoxBoth objects will grow if placed across sectionsWont snap to grid or guidelinesInsert PictureBMP always works and is usually editable through CrystalJPG and PNG sometimes throw errors and wont import and are never editable.Insert Chart (charts and graphs)Provides basic charts, Gantts, pies, cross-tabs and many others.There are many options and features here that wont be covered in class because its beyond scope.

Hands On(contd)# www.regoconsulting.comPhone: 1-888-813-0444

Cross-tab ExpertRight click an existing cross-tabThis is an additional way to get totals other than summaries and running total fields. Essentially the same options as running total fields but in a grid with additional grouping outside of the groups setup in the report.Database expertAdding and editing commandsChanging database locations (Set Datasource Location)ParametersData types must match those of Clarity. Clarity always passes numbers for checkboxesClarity always passes empty strings () instead of nulls for blank stringsClarity never passes a null array for empty multi-value lookups with lookup_code as the hidden key. It passes an array with one value and that value is an empty string. ([])Clarity always passes 0 instead of null for blank numbersClarity never passes a null array for empty multi-value lookups with lookup_enum as the hidden key. It passes an array with one value and that value is 0. ([0])The two rules above will dictate how your report filter lookups are designed.

Hands On (contd)# www.regoconsulting.comPhone: 1-888-813-0444

Formulas and Formula WorkshopBelieve it or not, the built-in Help library is very informative.Ctrl + space brings up autocomplete drop downOption of Crystal or Basic syntaxCrystal syntax is included in all versions of Crystal ReportsBasic syntax is modeled on Microsoft Visual BasicNote that record selection formulas and group selection formulas cannot be written in Basic syntax. For this reason I prefer Crystal syntax across the entire report.Basic operators and functions are availableif, else if, else, IIF, switch, loops (do while, do, etc.), for (supports exit), assignments, scoping variables, totext, len, concatenate, substring (through operator), in (contains), split, replace, plus many more. Strings are delimited by double quotes e.g. this is a string.IsNull and HasValue for checking if fields or parameters have values

Hands On (contd)# www.regoconsulting.comPhone: 1-888-813-0444

Running Total FieldsChoose when to evaluate and when to resetMultiple summary types including sum, count, distinct count, max, min, Nth largest, Nth smallest, average, sample varia