Jump to content
We've recently updated our Privacy Statement, available here ×

Replacing a Field Value


prinsesajade

Recommended Posts

hi!it's me again..

do u have any idea how i can do this?

i have this report that will generate a payroll..one of the fields is taxCode (Integer)..

here is my question..

say for example the value of taxCode for this certain employee is 20 i have to replace this value with a constant that wil be coming from a java class (TaxCategoryConstant)..here is my class:

so if the employee's taxCode is 20, S should be displayed in the result..

have any idea on this?

thank you!

Code:
public class TaxCategoryConstants {	public static final int Z=0;	public static final int S=20;	public static final int HF=25;	public static final int ME=32;	public static final int HF1=33;	public static final int HF2=41;	public static final int HF3=49;	public static final int HF4=57;	public static final int ME1=40;	public static final int ME2=48;	public static final int ME3=56;	public static final int ME4=64;}
Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

You have 2 options:

1. Write an helper class to performe a decode:

MyHelperClass.decode( $F{taxCode} )

2. Use a big switch of if/else. The basic syntax is   (<condition>) ? <exp on true> : <exp on false>
That means that you would have something like:

($F{taxCode}.intValue() == 0) ? "Z" :
  (  ($F{taxCode}.intValue() == 20) ? "S" :
     (  ($F{taxCode}.intValue() == 25) ? "HF" :
            [.....]
            (  ($F{taxCode}.intValue() == 56) ? "ME3" : "ME4" )
         )
       )
      [....]
  )
)

it is long, it is not very much readable, but it works (you are in charge to fill the [...] sections and fix the parenthesis...)

Giulio

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...