COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: blakesmind on 19 Dec 2013 10:15:51 PM

Title: Comments in report expressions
Post by: blakesmind on 19 Dec 2013 10:15:51 PM
To help document reports I develop, I adopted a practice of adding comments inline to report expressions using the comment syntax :

#/* this is a comment */#
1 = 1


I expected this same syntax to work on a report expression for a conditional boolean variable which will later be used as a Render Variable. It seems the parser responsible for report expressions in Condition Explorer doesn't like this syntax.

When I try to validate a report expression with the comment syntax, it fails ...

RSV-VAL-0002 Invalid expression #/* this is a comment */# 1 = 1. CRX-YXX-4010 A parsing error was found at or near the position 0 in the expression '#/* this is a comment */# 1 = 1'.

If I remove the comment syntax, the report expression code validates just fine with no errors.

1 = 1

Is this just a bug, or is the comment syntax different for this type of report expression?

I'm using Cognos 10.2

Thank you!
Title: Re: Comments in report expressions
Post by: bdbits on 20 Dec 2013 03:33:35 PM
Hmm, well I just tried a few possibilities and could not find a way to embed comments in a conditional.

Over time, I have found what expressions are supported can vary with where you are entering the expression. So, it may not be a "bug" so much as "working as designed". You could contact support and see what they say, but actually I am not sure this is documented or supported in the first place.
Title: Re: Comments in report expressions
Post by: Lynn on 17 Feb 2014 10:35:08 AM
I suspect the difference occurs because variables are related to layout whereas query expressions are related to what the query engine sends to the database.

Macros are intended for query expressions as I read it in the FM user guide document:

QuoteMacros are fragments of code that you can insert anywhere in the Select statement that defines
a query subject.

All that is really happening when you include a macro containing a comment in your query expressions using

#/* this is a comment */#

is that the database ends up getting normal database comment syntax such as

/* this is a comment */

There isn't any comment syntax that I know of for Cognos locally processed elements, aka the non-database stuff.

Can't swear I'm 100% correct here, but this is what I think is happening so take it fwiw.