If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

How to Create a Function

Started by jeisma, 08 Dec 2017 01:05:53 PM

Previous topic - Next topic

jeisma

Hi,

How do you create a function that you can call inside the Query Explorer's Data Items.

For example, I want to create a function (never mind the syntax just yet)


function validDate (invoicedate)
  var validDateFr, validDateTo

  if (inRange(..))
    return true

  return false.
end function


So a Data Item's expression definition, I could have something like this:

  if (validDate(current_date)) then
    "OK"
  else "NOT OK"


Possible to do?


TIA!

CognosPaul

Most databases will allow you to create User Defined Functions (UDFs) that you can import into Cognos, and then use like any other function.

SQL Server:
https://docs.microsoft.com/en-us/sql/relational-databases/user-defined-functions/create-user-defined-functions-database-engine

Oracle:
https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions231.htm

Once you create the function, you can use the import wizard in Framework Manager to import it. There should be an expandable functions list.

jeisma


I see, so it's not as simple as I initially thought.  :(

Thank you for taking the time to respond. I'll explore this option.

dougp

#3
You may be able to do this with a Cognos macro, although the macro feature is pretty limited.

dougp

Are you sure you need a function?  How about just a data item?


if ([invoicedate] between ?validDateFr? and ?validDateTo?)
then ('OK')
else ('Not OK')