Four Stars

increment a Big Dec context variable in tMap

Hi

I am trying to conditionally increment a Big Dec context variable based on certain field values 

currently I can do this via tJavaRow component, but want to bring this into a tMap - so the logic is centralized

 

this code currently works in tJavaRow 

 

 

AccumulationExampletJavaRow.png

but when I try to code something similar in the Var Expression builder, I receive "Type mismatch: cannot convert from Number&Comparable<?> to BigDecimal"

AccumulationExampleTmap.png

 

I have tried to search online in several places to address this issue but have had zero luck

do you have any advice

 

thank you in advance

1 ACCEPTED SOLUTION

Accepted Solutions
Twelve Stars TRF
Twelve Stars

Re: increment a Big Dec context variable in tMap

Hi,

Not very clean in my opinion, but if I understand your request you should try this.

Create a BigDecimal variable in the tMap, enter the expression builder and type the code:

null; // This is here because you need to affect a value to the variable
if(!"A".equals("B")) // Replace this with your condition
	context.test = context.test.add(new BigDecimal(1)); // Replace with your context variable

As you can see, the expression builder can be used to enter a piece of Java code which is not used for the variable assignment.

The only rule is that the 1st line must reprsent the right part of the variable assignment, but of course, you are not forced to use this variable anywhere.

So, this is what you expect: the context variable is incremented by 1 for each input row under condition.

Hope this helps.


TRF
4 REPLIES
Seven Stars

Re: increment a Big Dec context variable in tMap

In your expression remove "context.LastName_NullCount ="
In line 3 as shown in picture
Twelve Stars TRF
Twelve Stars

Re: increment a Big Dec context variable in tMap

Hi,

Not very clean in my opinion, but if I understand your request you should try this.

Create a BigDecimal variable in the tMap, enter the expression builder and type the code:

null; // This is here because you need to affect a value to the variable
if(!"A".equals("B")) // Replace this with your condition
	context.test = context.test.add(new BigDecimal(1)); // Replace with your context variable

As you can see, the expression builder can be used to enter a piece of Java code which is not used for the variable assignment.

The only rule is that the 1st line must reprsent the right part of the variable assignment, but of course, you are not forced to use this variable anywhere.

So, this is what you expect: the context variable is incremented by 1 for each input row under condition.

Hope this helps.


TRF
Twelve Stars TRF
Twelve Stars

Re: increment a Big Dec context variable in tMap

Does this help?
If so, please mark the case as solved.
Kudos also accepted.

TRF
Four Stars

Re: increment a Big Dec context variable in tMap

TRF

thank you 

this works - sorry for not responding to you sooner

your efforts are much appreciated