Search

Custom Search

Sunday, June 7, 2009

@prompt:




Description:
Use this function to prompt user for a value will be used during report run. For example if you want to run a monthly report against a specific month, you have to prompt the user to enter the Month or even select it from the list of value displayed.

 

Before we start:
I assume that you are familiar with BO universe designer and BO web inelegance. If you need to go through universe or Webi rich client tutorial please use the following links:
Syntax:
@prompt ('prompt text (1)', 'type (2)', 'list of values(3)', 'mono/multi(4)', 'free/constrained(5)')

 

Parameters:
Param Description Mandatory Values
1 Text used to prompt the user when he trying to run/refresh the report Yes N/A
2 Type of the expected value entered by the user and also must be same type of the object that we will use the prompt return value to compare with Yes A: alphanumeric
C: string
D: Date
N: Number
U: Unicode
3 List of values that will displayed to the user if he click on the Values button when he prompted to enter a value No Object defined to retrieve list of values
4 Number of valued allowed No Mono: user can select one value only
Multi: user can select Multi Values
5 User can edit enter a value by himself or not. No Free: user can type his own value
Constrained: user must select from list of values.

 


 

Where to use this function:
You can use this function anywhere; this is some places that you can use this function
  • Filter: you can use this function to prompt the user for a value that will use in filtering the retrieved data. [Click here for more information about conditions & Pre-defined filters in BO]
  • Where clause: when you create an object you can use this function in the where clause.
  • Select clause: you can use this function even in the select clause see examples.
  • Derived table: you can use this function in your derived table query. [Click here for more information about how to use prompt with derived tables]

     

 

Tips and Tricks:
  • You can use the same prompt in more than one place; just make sure that the prompt text exactly the same when you use it with other universe objects.
  • You can use data conversion function to convert the prompt returned value before using it. For example if the prompt return "Jan09" and you want to compare it with a Date column in database you have to convert it before using it. In our case we will use to_date (@prompt(,,,,,),'MONYY').
  • If your prompt will return multi value use IN operation instead of equal (=)
  • Note that not all users having permission to view list of values while they trying to run or refresh the report by default. The administrator should grant this permission to this user.
  • If you will use the free mode (user can type what he want) you should give a hint in the prompt text message about the data format expected. For example if the user should enter month in format (MON YY) then the prompt message should be descriptive like "Please enter month like Jan 09".

 


 


 

Example # 1 (simple prompt):
We need to create a new condition that will prompt user to enter a valid date to display data related to this date in our report.
Create a new condition with the specification below [Insert --> Condition]
  • Name: As of Date prompt
  • Description: Prompt user to enter a specified as of date value
  • Where:

    @select(Dimensions/As of Date) = @prompt (
    'Enter As of Date:', 'D', ['Dimensions/As of Date'], mono, constrained)
Notes:
  • Red single quote places. It will give you error message "Parse failed: invalid definition UNV0023"

     

 

Example # 2 (Prompt returns multi values):
We need to create a new condition that will prompt user to select cities that he wants to display revenue data
Create a new condition with the specification below [Insert --> Condition]
  • Name: Cities prompt
  • Description: Prompt user to select one or multiple cities to filter data according to
  • Where:

    @select(Dimensions/City) IN @prompt (
    'Select one or more cities from the list:', 'C', ['Dimensions/City'], Multi, constrained)
Notes:
  • We used Multi key word instead of mono this time this to indicate that the prompt will return one or more values.
  • Note also we used the IN operator instead of equal. This is because the return value is a collection of values not one single value as the previous example.

 

Example # 3 (user type Free Prompt):
We need to create a new condition that will prompt user to type the city that he want to display report data for.
Create a new condition with the specification below [Insert --> Condition]
  • Name: City prompt
  • Description: Prompt user to select or type a city
  • Where:

    @select(Dimensions/City) = @prompt (
    'Type a City name:', 'C', ['Dimensions/City'], mono, free)
Notes:
  • Note that we have used free key word instead of constrained. This will give the user the flexibility to type the city name directly without need to select form list of values.
  • Note that if the user type Paris while the stored value in @select(Dimensions/City) is PARIS then the query will return no data. To solve this issue you can use the Upper or lower function that will return the given string in upper case format or lower case format.
    UPPER(@select(Dimensions/City)) = UPPER(@prompt (
    'Type a City name:', 'C', ['Dimensions/City'], mono, free))
  • If you want the user to type multiple cities use this form
    @select(Dimensions/City) IN @prompt (
    'Type Cities name:', 'C', ['Dimensions/City'], Multi,
    free)
    Please note that user will enter values comma separated without space Like: (Paris,London,Roma,Cairo)

     


     
Example # 4 (From To prompt):
We need to create a new condition that will prompt user to enter "From Date" and "To Date" to display data related to this period in our report.
Create a new condition with the specification below [Insert --> Condition]
  • Name: From To prompt
  • Description: Prompt user to enter a specified period
  • Where:

    @select(Dimensions/As of Date) Between @prompt (
    'From Date:', 'D', ['Dimensions/As of Date'], mono, constrained) AND @prompt ('To Date:', 'D', ['Dimensions/As of Date'], mono, constrained)

 

Example # 5 (Use prompt with dimensions):
We need to create a new dimension that will display customer segment description based on what language user will select.
Prerequisites:
  • Language dimension Created.
  • Segment English Description created.
  • Segment France Description created.
  • Segment Dutch Description created.
  • Segment Arabic Description created.
Create a new Dimension with the specification below [Insert --> Dimension]
  • Name: Customer Segment Description
  • Description: Customer Segment Description based on the user selected language.
  • Select:
    Decode(@prompt (
    'Select Language:', 'C', ['Dimensions/Language'], mono, constrained),
    'EN', @select(Dimensions/Segment English Description),
    'FR', @select(Dimensions/Segment France Description),
    'DE', @select(Dimensions/Segment Dutch Description),
    'AR', @select(Dimensions/Segment Arabic Description), @select(Dimensions/Segment English Description))
Other information about Prompt:
Similar functions & Useful Links:

 

If you liked this post, then support me and buy my book:

9 comments:

  1. awesome !!!!! explanation...............thank u very much for this info.............

    ReplyDelete
  2. This is a great post!! you have helped me in my job!! thank you very much!!!

    ReplyDelete
  3. Can you use with the @PROMPT-command an asterisk(* or %) to select a multi entry (e.g. give me all suppliers where the customer name is starting with an 'C')?
    If yes: how? If not, is there another solution in BO?

    ReplyDelete
    Replies
    1. Maybe a good solution to this is to do something like that:
      substr(TABLE.TFIELD,1,2) = @prompt ('2 first words of name:', 'A', ['Dimensions/Name'], mono, free)

      or
      TABLE.TFIELD like @prompt ('2 first words of name:', 'A', , mono, free) || '%'

      TABLE.TFIELD can be changed to @select(DIMENSION)

      I hope this help

      Delete
  4. Hi. I must create a prompt to allow to user to select the dimension on which do the analysis. For example he can choose whether to display a measure based on the size of the x or y dimension. Is possible? Can you help me?

    ReplyDelete
  5. Thanks a lot for the great support.

    ReplyDelete
  6. Hi,

    Thanks for this post,

    When I try to execute à report, I have this message error: une erreur de base de données s'est produite: [Microsoft][SQL Server Native Client 10.0][SQL Server] La conversion d'un type de données varchar en type de données datetime a crée une valeur hors limites..(WIS 10901)


    I have searched for de prompt function and i find that:

    #fld1 <= @prompt('#txt1','D','#obj1',Mono,Free,Persistent,,)

    When executing report; I enter date at format: 01/01/2010

    I look a that column en datebase; is a datetime type


    can you help me.

    thanks.

    ReplyDelete
  7. I've a webi report in Business Objects version 4 with a prompting requirement as explained:
    There are 3 prompts that need to be related:
    Select Daily or Monthly
    Select Start Month, End Month
    Select Start Date, End Date

    User Interaction needs to be as follows:
    If Daily is selected, user can enter any Start Date, default End Date to Start Date + 30 Days. User should be able to change the End Date to any value that falls in the range [FROM: Start Date TO: Start Date + 30 Days].The Start Month, End Month prompt should be disabled.
    If Monthly is selected, user can select Start Month and End Month values with the expected constraint that the End Month is later than the Start Month. The Start Date and End Date prompts need to be disabled.
    How do I make this work? Please let me know if further information is needed to suggest a solution. Need this urgently! THANK YOU!

    ReplyDelete