Chemy Chen, Author at Perficient Blogs https://blogs.perficient.com/author/cchen/ Expert Digital Insights Thu, 03 May 2018 00:22:25 +0000 en-US hourly 1 https://blogs.perficient.com/files/favicon-194x194-1-150x150.png Chemy Chen, Author at Perficient Blogs https://blogs.perficient.com/author/cchen/ 32 32 30508587 Update RPT when Column Modified in Data Source https://blogs.perficient.com/2012/07/11/update-rpt-when-column-modified-in-data-source/ https://blogs.perficient.com/2012/07/11/update-rpt-when-column-modified-in-data-source/#respond Wed, 11 Jul 2012 13:32:57 +0000 http://blogs.perficient.com/delivery/?p=1645

During the Crystal Reports development, it is very common data source (database, universe) definition modifications impact the fileds to be presented in the RPT, such as field renaming, data type changes, or even deletion of a specific data field. How can we synchronize the changes from the data source into RPT to make sure the RPT is line up with the latest definition?

Problem Description

I have a report.The report retrieves several columns of a certain entity table in data mart to be placed in the report details. One day, I am noticed by the data mart developer that he / she revised a column naming of a specific entity table and requested a regression on the report side. I open up a report RPT and try to refresh it by hitting F5 key on the keyboard. An error like below prompts up:


At the same time, I try to refresh “Database Fields” under “Field Explorer”,  but it doesn’t work, either.


So, what can we do?

 Verify Database

What we will need to do is always using “Verify Database” command from “Database” menu to refresh data source definition and remap data field if necessary. When you choose “Verify Database”, the program checks the active databases or universes, and reports. If it detects changes, the report must be adapted to prevent errors.
With the report active in the Design tab, choose Verify Database from the Database menu.
The Verify Database message box appears.
If the program detects no changes in the active database, or the changes do not impact the report data, the message box displays this message: “The database is up to date.” In this case, click OK and return to your work.

Crystal Reports automatically adapts the report (and does not display the Map Fields dialog box) if it detects any of these changes:

 

  • Fields have been added to the database or universe.
  • Fields that are not used in the report have been deleted from the database or universe.
  • Field positions have changed in the database or universe.
  • Data types have changed for fields in the database or universe.

 

If the program detects a change(s) in the active database impact the report data, the message box displays this message: “The database file [“table name”] has changed. Proceeding to fix up the report!”
Click OK, the program displays the Map Fields dialog box. It indicates either of these types of changes happen to the database or universe:
·         The name of a field that is used in the report has changed.

·         The database or universe has been upsized from a PC data source to an SQL data source.

An Example

  • Create a view V_REPORTS for testing:

 

CREATE OR REPLACE VIEW DFRPT.V_REPORTS

(REPORT_ID, REPORT_TITLE, REPORT_TYPE, STATUS)

AS

select report_id report_id,

report_title report_title,

report_type report_type,

status status

from dfrpt.reports;

commit;

  • Create a RPT based on V_REPORTS:

  • Now that we change the column name from STATUS to STATUS_BK for the view in database:

 

CREATE OR REPLACE VIEW DFRPT.V_REPORTS

(REPORT_ID, REPORT_TITLE, REPORT_TYPE, STATUS_BK)

AS

select report_id report_id,

report_title report_title,

report_type report_type,

status status

from dfrpt.reports;

commit;

 

  • If we refresh (F5) the RPT without reopening it, an error message will prompt:

  • What we need to do is: click Database -> Verify Database from the Menu bar.

At this time Crystal report notices the mismatch and we have the opportunity to correct it.

Update the  mapping in this dialog and click OK, the RPT comes back to work.

Conclusion

In this post, I illustrate a good practice when designing RPT – always remember to use “Verify Database” command to refresh the data source to make sure the report data fields are the most up-to-date according to the source changes. Fix the inconsistence timely by remapping fields to make report run successfully.

 

]]>
https://blogs.perficient.com/2012/07/11/update-rpt-when-column-modified-in-data-source/feed/ 0 210557
Placeholders in the CMC – Business Objects(II) https://blogs.perficient.com/2012/06/13/placeholders-in-the-cmc-business-objects%ef%bc%88ii%ef%bc%89/ https://blogs.perficient.com/2012/06/13/placeholders-in-the-cmc-business-objects%ef%bc%88ii%ef%bc%89/#comments Wed, 13 Jun 2012 14:01:41 +0000 http://blogs.perficient.com/delivery/?p=1558

This is the second part of “Placeholders in the CMC – Business Objects”, please see the first part here

10. Placeholder List

Table Placeholder Variables

 Name Variable

Description

Title %SI_NAME% Report title, it is same as report rpt name
 ID %SI_ID% InfoStore SI_ID value, System ID
 Owner %SI_OWNER% Report owner who schedules the report
 DateTime %SI_STARTTIME% Date and time report was run, YYYY-MM-DD-HH-MM-SS
 User Full Name %SI_USERFULLNAME% Report owner full name, set in the properties page in Users and Groups setting
 Email Address %SI_EMAIL_ADDRESS% Report owner E-mail address, set in the properties page in Users and Groups setting
 Document Name %SI_DOCUMENT_NAME% Report document name
 File Extension %EXT% File extension, set in the Format step – Format Options
 Viewer Hyperlink %SI_VIEWER_URL% URL to view report, check more belo

11. For “Viewer Hyperlink”, we can set it from Applications -> CMC -> Processing Settings

12. So, for Notification setting, we can configure it like below:

13. To keep the placeholder setting, we’d better set it in “Default Settings”. The Schedule steps will copy the default settings, and we can customize them if necessary.

Conclusion

In this post, I illustrate the schedule placeholder variables in details. These variables help us manage report scheduling easier and with less effort, especially when we schedule report to a file system, and we configure email notification for success or failure.

There are several know issues regarding placeholders, they are:

  1. The format of %SI_STARTTIME% is not configurable. It is fixed as “YYYY-MM-DD-HH-MM-SS”. In the BOB forum, I see a lot people ask to set it differently. Another case is some people would like to remove time element, such as YYYYMMDD. From some discussion I know there is a hidden placeholder named %SI_STARTDATE% can help. But I didn’t get it work for the report schedule page, and some others reported the same problem. It turns out it works for publisher and need some further validation.
  2. %SI_DOCUMENT_NAME% cannot be evaluated during the report scheduling, either. It is displayed plain as %SI_DOCUMENT_NAME% in the export file name.
]]>
https://blogs.perficient.com/2012/06/13/placeholders-in-the-cmc-business-objects%ef%bc%88ii%ef%bc%89/feed/ 1 210548
Placeholders in the CMC – Business Objects(I) https://blogs.perficient.com/2012/06/11/placeholders-in-the-cmc-business-objectsi/ https://blogs.perficient.com/2012/06/11/placeholders-in-the-cmc-business-objectsi/#comments Mon, 11 Jun 2012 15:22:58 +0000 http://blogs.perficient.com/delivery/?p=1551

Usually, after we finish developing a Crystal Report rpt with sufficient unit testing according to the report requirement, the next step is to upload it onto the CMC (Central Management Console) or InfoView server for scheduling. During the scheduling, we will be asked to walk through several steps (recurrence, schedule for, notification, database connection, filters, format, destination, etc.) to provide a lot of information. To facilitate the process, BO provides scheduling placeholders to provide the information on demand. Crystal Reports 2008 and the related CMC is used to test the placeholder in this post.

Placeholder Variables

Please follow the steps below to check out the variables:

1. Log on to CMC -> Click on Folders
2. Select that particular report, right click to pop up the context menu -> Select Schedule
3. In the left pane of the pop-up, up to 13 steps that we will be able to configure for scheduling
4. Most likely, we set placeholders for the following two steps: Notification, and Destination
5. Click on Destination -> Select “File System” for Destination

6. Select one item from “Add placeholder…” list, the value will be filled in “Use Specific Name”, such as %SI_NAME% for “Title”. Placeholders contain read-only values and the placeholder names begin and end with the percentage character %.
7. Log on to CMC -> Click on Servers
8. In “Servers List”, right click on “DestinationJobServer”, and select “Destination” from the context menu
9. In the pop-up window, select “Email”, scroll down to “Subject”, “Message” area where we are able to set placeholder, too. From this list, we will be able to select “Viewer Hyperlink” to be included in the email message so that end user can click on the link with report variables to navigate to the report quickly.

]]>
https://blogs.perficient.com/2012/06/11/placeholders-in-the-cmc-business-objectsi/feed/ 1 210547
How Can I Make “Today” My Default Prompt Value II https://blogs.perficient.com/2012/05/07/how-can-i-make-today-my-default-prompt-value-ii/ https://blogs.perficient.com/2012/05/07/how-can-i-make-today-my-default-prompt-value-ii/#respond Mon, 07 May 2012 08:20:39 +0000 http://blogs.perficient.com/delivery/?p=1299

Here, you can see “Optional Prompt” is dimmed as “False” and cannot be modified. It means the prompt is required to input value before running report. What if we set “Default Value” as blank and run the report?

Click on “OK”, the page does not respond. We are required to input a standard date value, e.g. 03/27/2012, before we are able to click on “OK” to proceed. So, the default value cannot be set as blank anymore for the prompt created within the Command Object, and the prompt cannot be optional.

I need to design a “Magic Date” value, something like January 1, 1900 as the placeholder. It is highly unlikely that any of my records will include that date as a valid entry. That is the first important point about this concept: I must pick a date that will never appear as part of my normal data. That is the magic date.

In the Command SQL query edit box, I have the code logic to substitute “1/1/1900” to whatever I want it to be. In the example below, it is the current date.

Meanwhile, I revise the Prompt Text to be more readable:

 

Stored Procedure

What if I use a Stored Procedure as the data source and input parameter is needed for the sproc? Prompt will be created automatically. The name is the same as the sproc parameter. The different part for the sproc prompt is that there is an option to “Set to Null”. I can use it to set the default value as Null. Please look at an example below:

Stored Procedure cr_unbilledDeliv_CalDate is used as the data source, 4 prompts – @startdate, @enddate, @Createdonfrom, @Createdonto are created when the data source is set:

There is a “Set to Null” option with every prompt. When I check on it, I am able to set the default as Null to be passed to the backend sproc.

In the sproc, I parse the Null date and set the default date according to the business requirement respectively:

Conclusion

With three approaches I illustrate – Blank Default for a standard prompt, Magic Date for Command Object prompt, Set to Null for Stored Procedure prompt, with some specific code logic support, I can convert the prompt default to today, yesterday, end of this week, end of last week, end of the month… just about anything else that I’ve already covered above. For extended adaption, I can use the concept of a “magic number” for numeric prompts and a “magic string” for text prompts as well, although those are generally not used as frequently. Last by not the least, Dave Rathbun wrote a post on how to design a prompt default within universe. Feel free to refer to it for more information.

 

]]>
https://blogs.perficient.com/2012/05/07/how-can-i-make-today-my-default-prompt-value-ii/feed/ 0 210521
How Can I Make “Today” My Default Prompt Value Ι https://blogs.perficient.com/2012/05/07/how-can-i-make-today-my-default-prompt-value-%ce%b9/ https://blogs.perficient.com/2012/05/07/how-can-i-make-today-my-default-prompt-value-%ce%b9/#respond Mon, 07 May 2012 07:40:05 +0000 http://blogs.perficient.com/delivery/?p=1238

In one of my recent projects, I designed a bunch of reports using SAP Crystal Reports 2008 tool. In some of reports, I wanted to have a value like “sysdate”, “the first day of previous month”, or a formula of some kind like CurrentDate() plugged into that parameter as default for user convenience and for report scheduling onto InfoView server. Unfortunately, it doesn’t work. I have seen this question come up frequently on BOB for a long time but it seems SAP has no plan to support it in the near future. In this post, I’d like to share the work-around that I’ve used in the project. I create some kinds of placeholder to set as the default and some creative logic within code to do the substitution after the user has already responded to the prompt.

Problem Description

I have a report. The report has a date prompt. I want the date prompt to have a default value (partially possible) and I want the default value to be “today” instead of a standard date. The request is quite reasonable, in my opinion. But Business Objects does not think so. Prompt handling has been one of the weakest points of the tools for a long, long time. What you fill in the text input behind “Default Value” below will be parsed into a standard date: 2012-3-27, 2012/3/27, 3/27/2012. If the parse fails, it will be set to blank. Therefore, there is no way to specify a dynamic date which needs calculation as the Default Value. Any value entered for that parameter is treated as plain text data, and no formulas or calculations will be evaluated.

Defining the Prompt

Based on the various data sources a Crystal Report consumes, there are three ways to create parameters: Table Link, Command Object, and Stored Procedure. Consequently, we will need to deal with the parameter default for the three cases. I will be talking about them one by one below.

Table Link

Right-click the “Parameter Fields” in the “Field Explorer” view and select New… from the contextual menu to create a parameter. This is the standard way to create it. In the pop-up “Create New Parameter” window, I am able to set “Default Value” as blank and set “Optional Prompt” as “True”. Input the necessary information for the parameter and click “OK” to save it. The prompt is created properly.

As I mentioned above, the blank Default Value is just a placeholder. I design an additional formula field to receive the parameter value to do the substitution afterwards.

Right-click the “Formula Fields” in the “Field Explorer” view and select New… from the contextual menu to create a formula – {@Start Date}. Function HasValue is used to check if {?Start Date} is blank or not. Set it as currentDate if it is blank as default, or use the actual date specified, otherwise.

if not HasValue({?Start Date})

then

currentDate

else

{?Start Date}

Now, I am able to use {@Start Date} as a Record Selection or whatever I want in the report. With an optional parameter and a formula built on it, a parameter with dynamic default value works. The above is a simple sample; feel free to modify the formula to meet your needs. At the same time, revising the Prompt Text to be more readable is better below:

Command Object

If I am using a Command Object as the report data source, and at least one prompt is required within the Command Object, what can I do for the prompt default? Is there anything different with the above case? Yes, definitely it is.

Let’s start to create a prompt within the Command Object:

Save it, and review it from Parameter Fields in Field Explorer section:

 

To be continued

 

 

 

 

 

]]>
https://blogs.perficient.com/2012/05/07/how-can-i-make-today-my-default-prompt-value-%ce%b9/feed/ 0 210520