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-03 21:48:47

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.

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