Macro-passing Date Values To Prompts

  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Macro-passing Date Values To Prompts as PDF for free.

More details

  • Words: 320
  • Pages: 2
problem description impromptu prompts require dates to be entered in the format "yyyy-mm-dd". in some situations, one may wish to automate the running of a report which contains a date prompt and pass a date value calculated based on the current system date or values collected via custom dialogs or 3rd party automation tools such as microsoft visual basic. the following examples demonstrate how to use the cognosscript format() function to achieve this. it assumes a report with a single prompt, which requires a date value. for more information see the on-line help for the openreport method, the date() function, the format() function, and the inputbox() function. note that a space followed by an underscore is the cognosscript line continuation character, which allows a logical single line of code to be split over multiple lines of the source file for readability. solution description example 1: this example uses the cognosscript date() function to calculate the date of the day one week (7 days) earlier than the current system date and pass it to the report's prompt. sub dim dim dim dim

main() application as object report as object datestring as string promptstring as string

datestring=date-7 promptstring=format(datestring,"yyyy-mm-dd") set application=createobject("impromptu.application") application.opencatalog "c:\cognos\catalogs\catalog.cat", _ "accounting", "boring", _ "joe", "blow", _ 1 set report=application.openreport _ ("c:\cognos\reports\prompt.imr", promptstring) set report=nothing set application=nothing end sub example 2: this example uses the cognosscript inputbox() function to collect a date in a format familiar to the user and pass it to the report's prompt. the inputbox() function could be replaced with more complicated custom dialogs or a 3rd party application development tool could be used. sub dim dim dim dim

main() application as object report as object datestring as string promptstring as string

inputprompt$="enter start date for report (dd/mm/yy)"

inputtitle$="date" inputdefault$=format(date,"dd/mm/yy") datestring=inputbox(inputprompt$, inputtitle$, inputdefault$) promptstring=format(datestring,"yyyy-mm-dd") set application=createobject("impromptu.application") application.opencatalog "c:\cognos\catalogs\catalog.cat", _ "accounting", "boring", _ "joe", "blow", _ 1 set report=application.openreport _ ("c:\cognos\reports\prompt.imr", promptstring) set report=nothing set application=nothing end sub

Related Documents

1997 Prompts
June 2020 11
Writing Prompts
June 2020 19
Values
May 2020 29
Values
May 2020 31