Groovy - Fetch value of substitution variable in Groovy in (E)PBCS

Hi,

We all have requirement to fetch the value of substitution variable in our calculations script and then based on the value have some calculation performed.

Groovy does has the substitution variable class but it isn't functioning yet. So how do we get the value of substitution variable.

The solution is simple. Have a calc manager variable for example "getcurrMonth" and have the default value as "&currMonth" substitution variable.

Then add this variable to our Groovy calculation script and check the ishidden property of this variable.

To fetch the value of this variable simply use the below code.
String sCurrPeriod = rtps.getcurrMonth

It will return the current month which is set in the substitution variable currMonth.

Another option is to use RptValue contructor as below

RtpValue rtp = new RtpValue('getcurrMonth', 6, 'Period', '&CurrMonth', '&CurrMonth', '', 'DBName', 'AppName')

String sCurrPeriod = rtp.member.toString()

sCurrPeriod will have your substitution variable value


Hope you find it useful.

Thanks.

Comments

  1. Superb Post! Thanks Abhijeet for helping us and guiding us.

    ReplyDelete
  2. Thanks Abhijeet. Great Post

    ReplyDelete

Post a Comment