In cognos, could we avoid an optional prompt asking a value when its parameter is used in a data item in a query?

前提是你 提交于 2019-12-05 07:21:17

问题


Actually, I'm working in Cognos 10.1 report studio. In my report, I have two prompts, one is optional and another prompt is required. I've used both the prompt parameters inside the data item for some condition. So, the optional prompt has also turned to required. What should we do to avoid this?


回答1:


We can use #prompt()# for this. Usually, #prompt()# is used to deliberately force the parameter to hold some value. Instead of using the parameter directly, we should use the #prompt()#.

For example,

Suppose, ?Parameter1? is used in a data item and it holds a integer value, replace it with a #prompt()# like this #prompt('Parameter1','integer')#.

Suppose, if the condition is like

if(?Parameter1? is not null)
{  
   statement; 
}

it should be,

if(#prompt('Parameter1','integer')# is not null) 
{
   statement; 
}

If we use #prompt()#, we can use the parameter inside the data item, without affecting the prompt's usage.




回答2:


Regular Prompt Used in Data items calculations/logic always become required regardless because the data item in query must be presented and is not optional as in presentation items so the calculation has to resolve. Like the other poster stated in comes prompt macros ## which truely serves in my opinion 2 real-world purposes and argueable some others that we won't talk about.

  1. A poor mans search/replace substitution in queries before they are submitted(handy in these situations).
  2. defaulting a parameter if missing which in 8.4 is freaking darn near impossible to do especially in a data item.
  3. In MDX queries prompt macros are awesome because of #1 Hard Search and Replace in queries without the native Cognos prompt issues that get in the way sometimes.


来源:https://stackoverflow.com/questions/14441522/in-cognos-could-we-avoid-an-optional-prompt-asking-a-value-when-its-parameter-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!