Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
How to write a block of statement in tmap expression editor. I don't want to use extra component just because of some 2 extra statement.
e,g , I am having 10 input records(record_no, id, name) and after each two record add some value to column and reset the record count, so for next two it will start will 1.
Input
id|name
1|abc
2|pqr
3|xyz
4|ccc
output
id|name|rec_num
1|abc|1
2|pqr|2
3|xyz|1
4|ccc|2
rec_number = if(Numeric.sequence("s1",1,1) % 2 !=0) { Numeric.sequence("s1",1,1) }
else {
2 --> Assign 2 to 2nd row ;
Numeric.resetSequence("s1",1)--> Reset the sequence to 1
}
For other assignment I am already using tmap but I have implement above logic too. How I can implement only using tmap.
I can achieve by using tjavarow, but one component I have to add which I don't want to add.
Hi,
A somewhat unusual way of doing things in tMap but you can write a block of code like that:
Var.var1 is used to get the next value for sequence "s1".
Var.var2 value is forced to 1 (or any other value) for syntax. Be careful to the semicolumn after the 1 (usually there is no).
The 2nd line of code is here to reset the sequence "s1" to 0 if the curent value is even.
And the result is what you expect (I've added 2 lines just for testing):
Hope this helps.
Hi,
A somewhat unusual way of doing things in tMap but you can write a block of code like that:
Var.var1 is used to get the next value for sequence "s1".
Var.var2 value is forced to 1 (or any other value) for syntax. Be careful to the semicolumn after the 1 (usually there is no).
The 2nd line of code is here to reset the sequence "s1" to 0 if the curent value is even.
And the result is what you expect (I've added 2 lines just for testing):
Hope this helps.