The input variables are:
- TRDT and VLDT are strings and contain the date in format YYYYMMDD
- OWOVHE_R contains a string read from a file
- oOWOVHE contains the output value
- iOWOVHE contains the input value
The below JAVA code is called for every record read of a file and the purpose is to determine which value to take from the table (the valid date VLDT needs to be smaller or equal to the transaction date TRDT).
Code:
Expand|Select|Wrap|Line Numbers
- Integer nTRDT = Integer.parseInt(TRDT.trim());
- Integer nVLDT = Integer.parseInt(VLDT.trim());
- if (nTRDT >= nVLDT)
- {oOWOVHE = OWOVHE_R;}
- else
- {oOWOVHE = iOWOVHE;}
gives this result:
TRDT=20130307; VLDT=20120101; OWOVHE_R=7.500000; OWOVHE=7.500000
TRDT=20130307; VLDT=20130101; OWOVHE_R=6.000000; OWOVHE=6.000000
TRDT=20130307; VLDT=20131201; OWOVHE_R=9.000000; OWOVHE=9.000000
For the last OWEVHE the value should remain 6 as TRDT is smaller then VLDT.
What is wrong in the comparison? Should I not make then Integers? But how can I compare strings in a larger then?