Information about business rules
for SAP BW metadata appears in a different topic .
You can add business rules to the dimensions and query subjects in your model to refine the data retrieved and ensure that the correct information is available for your users.
Creating business rules and storing them in the model instead of in reports has many advantages. You save time because you and your users do not have to re-create the business rules every time they are needed. The business rules ensure consistency because your users all use the same definitions. For example, Low Margin means the same thing throughout the organization. They are easy to update because you maintain the business rules centrally so that all reports are updated automatically as the rules evolve. For example, if the definition for Low Margin changes, all reports that use the Low Margin calculation are updated automatically. The business rules enhance security. For example, you can use filters to limit the data that your users can see.
Information about calculations for
SAP BW metadata appears in a different topic .
You can create calculations to provide your users with calculated values that they regularly use. Calculations can use query items, parameters, variables, calculated members, expressions, and expression components, such as functions.
Punctuation characters, such as the question mark (?), must be in 7-bit ASCII character code. If you type a punctuation character from a multi-byte enabled keyboard, ensure that you type the 7-bit ASCII representation of the character. For example, type Alt+063 for the question mark.
Avoid using characters that are used for expression operators in the name of the calculation. Syntax errors may occur when the expression is evaluated. For example, a calculation named Margin * 10 causes errors when used in an expression such as [Margin * 10]< 20.
At query time, Framework Manager returns a null value for any calculation that contains a divisor whose value is zero. Framework Manager cannot detect zero-division errors in functions such as average and mod, because the division operator is not explicit.
Framework Manager supports stand-alone calculations and embedded calculations.
Use a stand-alone calculation when you want to reuse the expression.
You can apply a stand-alone calculation to one or more dimensions or query subjects to provide calculated data to a report, or include it in a package to make it available to your users. By moving a stand-alone calculation or a shortcut to it into a folder, you can better organize the model objects.
You cannot use stand-alone calculations in Analysis Studio. Instead, use an embedded calculation.
Use an embedded calculation when you want to use a calculation with only one dimension or query subject.
You can create an embedded calculation when modifying a relational data source query subject, model query subject, or dimension.
If you start with an embedded calculation, you can later convert it into a stand-alone expression that you can apply to other dimensions or query subjects. Tip: Right-click the calculation expression in the Calculations tab and click Convert to Stand-Alone Calculation.
When you embed a calculation, the data source query subject must have a relationship to any query subject referenced by the expression. This relationship is necessary even if the expression references a model query subject based on the same table as the data source query subject in which you are embedding the expression.
To create a calculation on an unrelated query subject, do one of the following:
Ensure that there is a join path between the new query subject and the one that contains the calculation.
Base the embedded calculation on a query item that is based on the data source query subject you want.
Convert the calculation to a stand-alone calculation, so that it is not part of the query subject.
Create a stand-alone calculation that references the embedded object.
Do one of the following:
If you want to create a stand-alone calculation, click the namespace or folder and, from the Actions menu, click Create, Calculation.
If you want to create an embedded calculation, double-click the dimension or query subject that will contain the calculation, click the Calculations tab, and then click Add.
In the Name box, type a name for the calculation.
Define the expression.
Goal | Action |
Add items | On the Model tab, click a query item, filter, or calculation and click the arrow. |
Add functions | On the Functions tab, choose a component and click the arrow. |
Add parameters | On the Parameters tab, click a parameter and click the arrow. |
Retrieve all data and show a specified number of rows | Click the options button, select the Restrict the maximum number of rows to be returned check box, and type the required number of rows to be returned. This setting does not improve performance for retrieving data when testing dimensions, query subjects, and query sets. |
Override session parameters | Click the options button, click Set, enter a value in the Override Value field, and click OK. |
Override prompt values | Click the options button, and then click Prompts. The Model Prompts Manager dialog box appears, which shows all prompts, and their values, that are in the model. |
To test the calculation, click the test button .
You can test only calculations that contain query items. If a calculation contains a function, for example _add_days, the test sample button is not available.
Click OK.
Modify the Data Type property to identify the type of data the calculation returns.
The Cognos 8 studio uses this information to format the data that the calculation returns.
You may be interested in the following related topics:
Information about filters for SAP
BW metadata appears in a different topic .
A filter is an expression that specifies the conditions that rows or instances must meet to be retrieved for the dimension, query subject, calculation, or report to which the filter is applied. A filter returns a boolean value so that you can limit the rows returned by a dimension or query subject.
For example, you can use the in_range function to create a filter that retrieves data for products introduced in a specific time frame. The syntax for this example looks like this:
[gosales_goretailers].[Products].[Introduction date] in_range {Feb 14, 1999 : July 14, 2007}
Note: When using a date or time function, you must use a 24-hour clock. Framework Manager does not support "a.m." or "p.m." in expressions. For example, use 20:00 to signify 8 p.m.
You can restrict the data represented by dimensions or query subjects in a project by creating a security filter. The security filter controls the data that your users can see when they set up their reports.
You can also apply governors to restrict the data that the queries in a package retrieve.
Framework Manager supports stand-alone filters and embedded filters.
Use a stand-alone filter when you want to reuse the expression.
You can add a stand-alone filter to one or more dimensions or query subjects to limit the data that the query retrieves when the filtered dimension or query subject is used in a report, or you can include it in a package to make it available to your users. By moving a stand-alone filter or a shortcut to it into a folder, you can better organize the model objects.
Use an embedded filter when you want to use a filter with only one dimension or query subject.
You can create an embedded filter when modifying a dimension, relational data source query subject, or model query subject.
If you start with an embedded filter, you can later convert it into a stand-alone expression that you can apply to other dimensions or query subjects. Tip: Right-click the filter expression in the Filters tab and click Convert to Stand-alone Filter.
When you embed a filter, the data source query subject must have a relationship to any query subject referenced by the expression. This relationship is necessary even if the expression references a model query subject based on the same table as the data source query subject in which you are embedding the expression.
To create a filter on an unrelated query subject, do one of the following:
Ensure that there is a join path between the new query subject and the one that contains the filter.
Base the embedded filter on a query item that is based on the data source query subject you want.
Convert the calculation to a stand-alone filter, so that it is not part of the query subject.
Create a stand-alone filter that references the embedded object.
Do one of the following:
If you want to create a stand-alone filter, click the namespace or folder and, from the Actions menu, click Create, Filter.
If you want to create an embedded filter, double-click the dimension or query subject that will contain the filter, click the Filters tab, and then click Add.
In the Name box, type a name for the filter.
Define the expression.
Goal | Action |
Add query items and filters | On the Model tab, drag the objects you want to the Expression Definition box. |
Add functions | On the Functions tab, drag the functions to the Expression Definition box. |
Add parameters | On the Parameters tab, drag the parameters to the Expression Definition box. |
Retrieve all data and show a specified number of rows | Click the options button, select the Restrict the maximum number of rows to be returned check box, and type the required number of rows to be returned. This setting does not improve performance for retrieving data when testing dimensions, query subjects, and query sets. |
Override session parameters | Click the options button, click Set, enter a value in the Override Value field, and click OK. |
Override prompt values | Click the options button, and then click Prompts. The Model Prompts Manager dialog box appears, which shows all prompts, and their values, that are in the model. |
To test the filter, click the test button .
Click OK.
You can also apply governors to restrict the data that
the queries in a package retrieve .
You may be interested in the following related topics:
Information about filters for SAP
BW metadata appears in a different topic .
To apply a filter, you must modify the dimension, data source query subject, or model query subject. The query subject must either contain the query items that the filter references, or have a relationship path to the query subjects that contain the query items.
You can embed a stand-alone filter in dimensions or query subjects, but if you want a different usage for each embedded filter, you must create different versions of the stand-alone filter. Otherwise, your users could be required to fill in a prompt that you thought was optional if there is any instance where the usage is set to mandatory.
For example, in query subject A, you embed a stand-alone filter and define it as optional. In query subject B, you define it as mandatory. When your users create a report that uses both query subjects, they are required to choose values in both filters, even the one defined as optional. All instances of the filter are considered to be mandatory when used in the same query. The solution is to create different versions of the filter, each with its own name.
Create a filter.
Select the filter and, from the Actions menu, click Edit Definition.
Click the Filters tab, and drag the filter you created to the Filters box.
Select a usage value for the filter.
Usage Value | Description |
Always | Use this usage value to ensure specified data is filtered out of all reports. For example, your company may have obsolete information that it stores but does not want to report on. Always is the default usage value. |
Design Mode Only | Retrieves a small subset of the data for the sample report. Use this usage value when you do not need to see all the data, for example when testing a query subject. Your users may need the design mode filter in Query Studio when they want to focus on designing the layout and format of a report and not retrieve all the data as they work. To access the design mode filter in Query Studio, run the report with limited data. |
Optional | Specifies that the filter is optional. The user is prompted to filter data and can leave the prompt blank. If the prompt is blank, Framework Manager ignores the filter and retrieves all data for the dimension or query subject. The ? ? syntax is required for optional prompts. Use this usage value if your users want to control when the filter is applied. For example, you want to see on one country sometimes and see the data for all countries at other times. An optional filter for country looks like this: ([GeoNamespace].[Countries].[CountryName] = ?WhichCountry?) |
If you want to view the SQL, click the Query Information tab.
Click OK.
You want to create a query that shows the currency name for a specific country. To do this, you create a filter that returns data for a specific country code, and apply the filter to a model query subject that retrieves the currency name for each country.
Note: The following example uses a relational data source.
Open the go_sales sample model. It is located in c8_location/webcontent/samples/Models/go_sales/go_sales.cpf
Create a filter to limit the retrieval of data to only those country codes in the conversion rate table whose value is 2:
Click the Filters folder and, from the Actions menu, click Create, Filter, and name the new filter ConversionRateCountryCode.
Click the Model tab.
In the Available Components box, open the Database view folder and then open the GoSales folder.
Add the Country Code query item from Conversion Rate query subject to the Expression definition box, and type ='2' at the end of the expression.
Click OK.
Create a model query subject named ISO Code.
In the Available Model Objects box, open the Database view folder.
Add Country query item and the ISO 3-letter code query item from the Country query subject to the Query Items and Calculations box.
Apply the ConversionRateCountryCode filter:
Click the Filters tab.
Open the Filters folder and drag ConversionRateCountryCode to the Filters box.
Click the Query Information tab.
The generated SQL contains the filter even though it does not affect the result set.
Change the usage of the ConversionRateCountryCode filter to Optional:
Click the Filters tab.
Click the ellipsis (...) button under Usage for the ConversionRateCountryCode filter, and click Optional.
If you want to view the SQL, click the Query Information tab.
Click OK.
Information about parameter maps
for SAP BW metadata appears in a different topic .
Use parameters to create conditional query subjects that allow for substitutions when the report is run. Parameter maps are objects that store key-value pairs. Parameter maps are similar to data source look-up tables. Each parameter map has two columns, one for the key and one for the value that the key represents. You can manually enter the keys and values, import them from a file, or base them on existing query items in the model.
All parameter map keys must be unique so that Framework Manager can consistently retrieve the correct value. Do not place quotation marks around a parameter value. You can use quotation marks in the expression in which you use the parameter.
The value of a parameter can be another parameter. However, you must enclose the entire value in number signs (#). The limit when nesting parameters as values is five levels.
When you use a parameter map as an argument to a function, you must use a percentage sign (%) instead of a dollar sign ($).
We recommend that you assign an alias to a query item that uses a parameter map as part of its name and to add the multilingual names to the object in the Language tab (Properties pane).
We recommend that you do not base a parameter map on a query item or table with a large result set, such as 50,000 rows. Each time you use the parameter map in an expression or in SQL, Framework Manager executes this large query. Performance is then slowed. Parameter maps are recommended for smaller lookup tables.
Click the Parameter Maps folder and, from the Actions menu, click Create, Parameter Map.
In the Name box, type a name for the new parameter map.
Click Manually enter the parameter keys, and/or import them from a file and click Next.
Do one of the following:
To manually enter values, click New Key, type a key, and press Tab to enter a value for that key.
To import keys and values, click Import File and identify the location of the appropriate .csv file. You can import from a .txt file only if the values are separated by tabs rather than commas.
Note: If you are going to use a parameter in a data source query subject, the value must use English-specific punctuation. This means that you must use a period (.) to represent a decimal and a comma (,) to separate lists of values.
Modify existing parameters as required.
Goal | Action |
Assign a default value | In the Default Value box, type a value. If the key is used in an expression that is not mapped, the default value is used. |
Remove a parameter | Select a row and click Delete. |
Modify a parameter | Select the row you want to modify, click the Edit button, and type a value. |
Clear all keys and values | Click Clear Map. |
Click Finish.
Click the Parameter Maps folder and, from the Actions menu, click Create, Parameter Map.
In the Name box, type a name for the new parameter map.
Click Base the parameter map on existing Query Items and click Next.
Click the query item to use as the key, and then click the query item to use as the value.
Both query items must be from the same query subject.
Click Next.
You can assign a default value. If the key used in an expression is not mapped, the default value is used.
Click Finish.
You may be interested in the following related topics:
An international company stores its product information in English and French. With the use of a parameter map and macros, employees can retrieve data that matches the information they require.
Create a Language_lookup parameter map that contains the following:
Key | Value |
en | EN |
fr | FR |
When you examine the SQL for the Product Line query subject, you see the following:
Select
PRODUCT_LINE.PRODUCT_LINE_CODE,
#'PRODUCT_LINE.PRODUCT_LINE_' + $Language_lookup{$runLocale}# as Product_Line
from
[gosales].PRODUCT_LINE PRODUCT_LINE
The runLocale macro returns a locale setting that is used by the Language_lookup macro to specify a language value.
Information about session parameters
for SAP BW metadata appears in a different topic .
A session parameter is a variable that Framework Manager associates with a session. For example, user ID and preferred language are both session parameters. Because session parameters are key and value pairs, you can think of each session parameter as an entry in a parameter map named Session Parameters. You use a session parameter in the same way that you use a parameter map entry, although the syntax for session parameters is slightly different.
There are two types of session parameters: environment and model.
Environment session parameters are predefined and stored in Content Manager. By default, the following session parameters appear in Framework Manager:
runLocale
account.defaultName
account.personalInfo.userName
If you log on anonymously, you will see only runLocale and account.defaultName(Anonymous).
If your authentication source supports other parameters and you entered information about them in the authentication source, you see other session parameters, such as account.personalInfo.email.
You can define additional parameters by using model session parameters. Model session parameters are stored in a parameter map named _env. They are set in the project and can be published with a package.
Model session parameters must have their values set within the scope of objects in the Framework Manager model. The scope can include the use of existing environment session parameters, as well as static values.
Each session parameter must have a name and a default value. You can define an override value to test the results that value returns. The override value is valid only when you have the model open, and is not saved when you save the model. If no override value exists, Framework Manager uses the default value when it executes a query that contains a session parameter.
The rules governing the use of parameters include the following:
All possible return values must have the same data type.
Only one value can be defined.
From the Project menu, click Session Parameters.
Click New Key and type a session parameter key and value.
Choose how to handle the override value.
To avoid having to set the override value every time you edit the project, set the session parameter as a value.
To avoid having to remove the project setting each time before you publish it, set the session parameter as a session override.
Modify existing parameters as required.
Goal | Action |
Change the parameter value | Click the row that contains the value you want to change, click Edit, and type a value. |
Assign a default value | In the Default Value box, type a value. Framework Manager uses the default value if a key has an invalid value. |
Remove a parameter | Click a row and click the Delete button. You cannot delete an environment session parameter. |
Clear an override value | Click a row and click Clear Override. |
Click Finish.
Model objects do not reflect changes to the data source objects on which they are based. Therefore, when you add a parameter to a data source query subject, consider whether you want to create a model object that references the parameter. If so, you must assign an alias to the parameterized object in the data source query subject. This ensures that model query subjects, filters, or calculations that reference the object return the correct results when the parameter value changes.
For example, the following SQL defines a data source query subject that contains a session parameter named runLocale. The runLocale parameter value specifies which column the query retrieves. The alias behaves like a shortcut so that when a model object references CountryNameAlias, Framework Manager retrieves the value to which the alias is assigned.
Select
#$ColumnMap{$runLocale}# as CountryNameAlias
From
[GoSales].Country
Macros are fragments of code that you can insert anywhere in the Select statement that defines a query subject. You can include references to session parameters, parameter maps, and parameter map entries. Parameter values are set when you run the query.
For example, you can use the language session parameter to show only the data that matches the language setting for the current user.
Macros can be used in these different ways:
They can be inserted in the SQL.
An example is Select * from Country where Country.Name = #$myMap{$runLocale}#
They can supply an argument to a stored procedure query subject.
If a value is not hard-coded for the argument, the stored procedure query subject can be used to return different data.
They can be inserted in expressions, such as calculations and filters.
An example is a filter [gosales].[Sales staff].[Staff name] = #$UserLookUpMap{$UserId}#
They can be used to dynamically complete the properties of a data source query subject.
This enables different users to supply different connection information and thus access different data sources. The properties that can contain macros are: Content Manager Datasource, Catalog, Cube, and Schema.
An example using the Content Manager Datasource property is #$DataSourceMap{$UserId}#
They can be used as a parameter wizard.
Parameters can reference other parameters. An example is Map1, Key = en-us, Value = #$myMap{$UserId}#
They can be used in the Session Parameter dialog box.
An example is MySessionParameter, value = #$myMap{$UserGroup}#
You can replace the following query subject elements with a parameter.
Element | Example |
Query items identified in the Select list | #'Product_name_'+ $languageCode# |
Tables identified in the From clause | Product_#$language# |
Where clause | Product_lang = #sq($languageCode)# |
Name of the data source, schema, or source property | #$data_source#.#$schema#.Products |
Use the following syntax to reference session parameter and parameter values.
Object | Syntax | Example |
Session key | $session_key | #$my_account# |
Parameter map key | $map{<key>} | #$map_one{'abc'}# |
Parameter map entry whose key is defined by a session parameter | $map{$session_key} | #$map_one{$my_account}# |
You can add the following elements to further define the macro expression.
Symbol | Purpose |
Single quotation marks ' | Delineates a literal string that has a single quotation mark as part of the string. If the single quotation mark appears in a string, such as a query item, the string must be enclosed in a single quotation mark on both sides of the string and the single quotation mark must be doubled. For example, ab'c is written as 'ab''c' If the single quotation mark appears in a macro, the string must be enclosed in square brackets. For example, ab'c is written as [ab'c] If the single quotation mark appears in a prompt, there is no need to enclose the string. To escape a single quotation mark in an expression, use ' |
Square brackets [ ] | Encloses model objects, such as a namespace or query subject and macro names that contain restricted characters, such as a number sign, hyphen, or space. |
Curly brackets, also known as braces { } | Calls a function that is unknown to the parser, such as dateadd in DB2, and whose first argument is a keyword. Example: dateadd ({month},2,<date expression>) |
+ operator | Concatenates two strings, such as 'abc' + 'xyz' |
Single quote function (sq) | Surrounds the result of a string expression with single quotation marks. Existing single quotation marks are double-escaped so that they do not interfere with the quotation structure. You can use this function to build clauses to test against literal parameter-driven values. Here is an example: #sq($my_sp)# If a session parameter (my_sp) has the value ab'cc, the result is 'ab"cc' |
Double quote function (dq) | Surrounds the result of a string expression with double quotation marks. You can use this function to refer to table and column names with non-identifier characters, such as a blank space or a percent sign (%). Here is an example: #dq ('Column' + $runLocale)# If runLocale=en-us, the result is "Column en-us" |
Square bracket function (sb) | Inserts a set of square brackets into the argument to build object references in a model query and model expressions, such as filters and calculations. Here is an example: #sb ('my item in ' + $runLocale)# If runLocale=en-us, the result is [my item in en-us] |
For information about functions, see Using the Expression Editor.
Macros are fragments of code that you can insert anywhere in the Select statement that defines a query subject. You can include references to session parameters, parameter maps, and parameter map entries. Parameter values are set when you run the query.
When you reference a parameter, you must do the following:
use a number sign (#) at the beginning and end of each set of one or more parameters.
Everything between the number signs is treated as a macro expression, which is processed at runtime. Framework Manager removes anything that is outside the number signs.
precede each parameter map entry with a dollar sign ($)
use a name that starts with an alpha character (a..z, A..Z)
Do not insert macros between existing quotation marks or square brackets because Framework Manager does not execute anything within these elements.
Select the data source query subject you want to modify.
From the Actions menu, click Edit Definition.
On the SQL tab, click Insert Macro to start the Macro Editor.
In the Available components box, click the parameter maps, session parameters, or functions you want to use, and drag them to the Macro definition box.
Ensure that you type the macro expression between the number signs. If you enter text before or after the number signs, when you click OK, Framework Manager deletes this text.
Insert single or double quotation mark functions.
Tip: Click the arrow next to these buttons for a menu
of choices for placing the quotation marks .
If you want to edit a parameter map or session parameter, click it in the Macro definition box.
The Parameter Map or Session Parameters dialog box appears. You can set override values for session parameters, add new items, or change values.
Check the macro in the Information box.
If a macro is incorrect, an error message appears.
Tip: To clear a macro, click the clear all button .
Click OK.
You can create mandatory and optional prompts in Framework Manager models by using query macros. You can use two prompt macro functions, prompt and promptmany, to create single value prompts and multiple value prompts. You can insert a prompt macro anywhere in the SQL statement that defines the query subject.
If you want to use a prompt macro in an expression such as a calculation, you must specify the data type when using an overloaded operator, such as a plus sign (+). You can use the plus sign to concatenate two items and to add two items.
If you want to define a filter on a dimension level and have the filter use the prompt or promptmany macro, you must provide the data type as memberuniquename and a default value. Here is an example:
members( [MS_gosales].[New Dimension].[PRODUCTLINE].[PRODUCTLINE] ) in ( set( #promptmany('what', 'memberuniquename', '[MS_gosales].[PROD1].[PRODUCTLINE].[PRODUCTLINE]->[all].[1]' )# ) )
Here is an example of a mandatory prompt:
select COUNTRY_MULTILINGUAL.COUNTRY_CODE as COUNTRY_CODE, COUNTRY_MULTILINGUAL.COUNTRY as COUNTRY, COUNTRY_MULTILINGUAL."LANGUAGE" as LANGUAGE1, COUNTRY_MULTILINGUAL.CURRENCY_NAME as CURRENCY_NAME from gosales.gosales.dbo.COUNTRY_MULTILINGUAL COUNTRY_MULTILINGUAL where COUNTRY_MULTILINGUAL.COUNTRY = #prompt('CountryName')#
The prompt and promptmany functions have the following parameters. All argument values must be specified as strings.
Parameter | Description | |
Name (mandatory) | Name of the prompt. Can also refer to the name of a parameter on a user-created prompt page, in which case the user-created prompt page appears when the report is run instead of the default prompt page that the macro would generate. | |
Datatype (optional) | Prompt value data type. The default value is string. Prompt values are validated. In the case of strings, the provided value is enclosed in single quotation marks and embedded single quotation marks are doubled. | |
Values include:
|
| |
DefaultText (optional) | Text to be used by default. If a value is specified, the prompt is optional. If you use a space and no values are provided in the Prompt Value dialog box, a Where clause is usually not generated. If you use text and no values are provided in the Prompt Value dialog box, a Where clause is usually generated using the default value. Ensure that the text you provide results in a valid SQL statement. | |
Text (optional) | Text that precedes any user-provided values, such as, 'and column1 = '. | |
QueryItem (optional) | The prompt engine can take advantage of the Prompt Info properties of the query item. Descriptive information can be shown although the prompt value is a code. | |
TextFollowing (optional) | The closing parenthesis which is used most often for the promptmany function. It is also useful when the prompt is optional and is followed by hardcoded filters in the SQL statement. |
When a report is run, you want your users to be prompted to choose the country for which they want to see data. The following code examples describe how you can use macros to create different prompts.
Note the following:
The Datatype argument is not specified. Therefore, it is a string, which is correct in this case.
The DefaultText argument is not specified. Therefore, it is a mandatory prompt.
select COUNTRY_MULTILINGUAL.COUNTRY_CODE as COUNTRY_CODE, COUNTRY_MULTILINGUAL.COUNTRY as COUNTRY, COUNTRY_MULTILINGUAL."LANGUAGE" as LANGUAGE1, COUNTRY_MULTILINGUAL.CURRENCY_NAME as CURRENCY_NAME from gosales.gosales.dbo.COUNTRY_MULTILINGUAL COUNTRY_MULTILINGUAL where COUNTRY_MULTILINGUAL.COUNTRY = #prompt('CountryName')#
Note the following:
This prompt requires a valid integer value as response.
The DefaultText argument is not specified. Therefore, it is a mandatory prompt.
select COUNTRY_MULTILINGUAL.COUNTRY_CODE as COUNTRY_CODE, COUNTRY_MULTILINGUAL.COUNTRY as COUNTRY, COUNTRY_MULTILINGUAL."LANGUAGE" as LANGUAGE1, COUNTRY_MULTILINGUAL.CURRENCY_NAME as CURRENCY_NAME from gosales.gosales.dbo.COUNTRY_MULTILINGUAL COUNTRY_MULTILINGUAL where COUNTRY_MULTILINGUAL.COUNTRY_CODE > #prompt('Starting CountryCode', 'integer', '', '', '[gosales].[COUNTRY_MULTILINGUAL].[COUNTRY_CODE]')#
Note the following:
This prompt allows the user to supply a valid integer response.
The DefaultText argument is specified. Therefore, the user may omit entering a value, in which case the value 10 is used. This makes it an optional prompt, but not an optional filter.
select COUNTRY_MULTILINGUAL.COUNTRY_CODE as COUNTRY_CODE, COUNTRY_MULTILINGUAL.COUNTRY as COUNTRY, COUNTRY_MULTILINGUAL."LANGUAGE" as LANGUAGE1, COUNTRY_MULTILINGUAL.CURRENCY_NAME as CURRENCY_NAME from gosales.gosales.dbo.COUNTRY_MULTILINGUAL COUNTRY_MULTILINGUAL where COUNTRY_MULTILINGUAL.COUNTRY_CODE > #prompt('Starting CountryCode', 'integer', '10' )#
Note the following:
The DefaultText argument is specified as a space character. In this case, the generated text is just the space character, which eliminates the Where clause from the query.
The Text argument is specified, which is written into the generated SQL before the user-provided prompt value.
select COUNTRY_MULTILINGUAL.COUNTRY_CODE as COUNTRY_CODE, COUNTRY_MULTILINGUAL.COUNTRY as COUNTRY, COUNTRY_MULTILINGUAL."LANGUAGE" as LANGUAGE1, COUNTRY_MULTILINGUAL.CURRENCY_NAME as CURRENCY_NAME from gosales.gosales.dbo.COUNTRY_MULTILINGUAL COUNTRY_MULTILINGUAL #prompt('Starting CountryCode', 'integer', ' ', // < = = this is a space 'where COUNTRY_MULTILINGUAL.COUNTRY_CODE >' )#
Note the following:
The Datatype argument is set to token, which means that the user-provided value is entered into the SQL without any checking on the provided value.
Token should be used only if there is a list of pick-values for the user.
The DefaultText argument is specified. Therefore, this is an optional prompt and group by COUNTRY is used in the generated SQL.
Select COUNTRY_MULTILINGUAL.COUNTRY_CODE as COUNTRY_CODE, COUNTRY_MULTILINGUAL.COUNTRY as COUNTRY, COUNTRY_MULTILINGUAL."LANGUAGE" as LANGUAGE1, COUNTRY_MULTILINGUAL.CURRENCY_NAME as CURRENCY_NAME from gosales.gosales.dbo.COUNTRY_MULTILINGUAL COUNTRY_MULTILINGUAL #prompt('Sort column', 'token', 'group by COUNTRY', 'group by ' )#
When a report is run, you want your users to select a language for the data in the report. The following examples describe several ways you can do this.
Note the following:
The name of the prompt is specified using a lookup in the parameter map named PromptLabels. The key value is the session variable $language.
The Where clause is using a parameterized column.
select ORDER_METHOD.ORDER_METHOD_CODE as ORDER_METHOD_CODE, ORDER_METHOD.ORDER_METHOD_#$language# as ORDER_METHOD_EN from gosales.gosales.dbo.ORDER_METHOD ORDER_METHOD #prompt($PromptLabels{$language}, '', ' ', 'where ORDER_METHOD.ORDER_METHOD_' + $language + ' >' )#
Note the following:
In the model, there is a parameter map DynPromptLabels with #$PromptLabels{$language}#
Part of the prompt information is run from a parameter map instead of being coded directly inside the SQL.
The whole macro containing the prompt can be a value in a parameter map.
select ORDER_METHOD.ORDER_METHOD_CODE as ORDER_METHOD_CODE, ORDER_METHOD.ORDER_METHOD_#$language# as ORDER_METHOD_EN from gosales.gosales.dbo.ORDER_METHOD ORDER_METHOD #prompt($DynPromptLabels{'ex9'}, '', ' ', 'where ORDER_METHOD.ORDER_METHOD_' + $language + ' >' )#
When a report is run, you want your users to select one or more values. The following examples describe several ways you can do this.
Note the following:
The user must enter at least a single value.
This resembles the first example on prompting for a country .
select COUNTRY_MULTILINGUAL.COUNTRY_CODE as COUNTRY_CODE, COUNTRY_MULTILINGUAL.COUNTRY as COUNTRY, COUNTRY_MULTILINGUAL."LANGUAGE" as LANGUAGE1, COUNTRY_MULTILINGUAL.CURRENCY_NAME as CURRENCY_NAME from gosales.gosales.dbo.COUNTRY_MULTILINGUAL COUNTRY_MULTILINGUAL where COUNTRY_MULTILINGUAL.COUNTRY IN (#promptmany('CountryName')#)
Note the following:
select COUNTRY_MULTILINGUAL.COUNTRY_CODE as COUNTRY_CODE, COUNTRY_MULTILINGUAL.COUNTRY as COUNTRY, COUNTRY_MULTILINGUAL."LANGUAGE" as LANGUAGE1, COUNTRY_MULTILINGUAL.CURRENCY_NAME as CURRENCY_NAME from gosales.gosales.dbo.COUNTRY_MULTILINGUAL COUNTRY_MULTILINGUAL where COUNTRY_MULTILINGUAL.COUNTRY_CODE IN ( #promptmany('Selected CountryCodes', 'integer', '', '', '[gosales].[COUNTRY_MULTILINGUAL].[COUNTRY_CODE]')# )
Note the following:
The In clause and both parentheses are part of the SQL statement.
select COUNTRY_MULTILINGUAL.COUNTRY_CODE as COUNTRY_CODE, COUNTRY_MULTILINGUAL.COUNTRY as COUNTRY, COUNTRY_MULTILINGUAL."LANGUAGE" as LANGUAGE1, COUNTRY_MULTILINGUAL.CURRENCY_NAME as CURRENCY_NAME from gosales.gosales.dbo.COUNTRY_MULTILINGUAL COUNTRY_MULTILINGUAL where COUNTRY_MULTILINGUAL.COUNTRY_CODE IN ( #promptmany('Selected CountryCodes', 'integer', '10' )# )
Note the following:
This example uses the TextFollowing argument.
select COUNTRY_MULTILINGUAL.COUNTRY_CODE as COUNTRY_CODE, COUNTRY_MULTILINGUAL.COUNTRY as COUNTRY, COUNTRY_MULTILINGUAL."LANGUAGE" as LANGUAGE1, COUNTRY_MULTILINGUAL.CURRENCY_NAME as CURRENCY_NAME from gosales.gosales.dbo.COUNTRY_MULTILINGUAL COUNTRY_MULTILINGUAL #promptmany('Selected CountryCodes', 'integer', ' ', // < = = this is a space 'where COUNTRY_MULTILINGUAL.COUNTRY_CODE IN ( ', '', ')' )#
Select COUNTRY_MULTILINGUAL.COUNTRY_CODE as COUNTRY_CODE, COUNTRY_MULTILINGUAL.COUNTRY as COUNTRY, COUNTRY_MULTILINGUAL."LANGUAGE" as LANGUAGE1, COUNTRY_MULTILINGUAL.CURRENCY_NAME as CURRENCY_NAME from gosales.gosales.dbo.COUNTRY_MULTILINGUAL COUNTRY_MULTILINGUAL, gosales.gosales.dbo.COUNTRY XX where COUNTRY_MULTILINGUAL.COUNTRY_CODE = XX.COUNTRY_CODE #promptmany('Selected CountryCodes', 'integer', ' ', ' and COUNTRY_MULTILINGUAL.COUNTRY_CODE IN (', '', ')' )#