on 05-02-2017 10:16 PM
Attempted to create the following JavaScript for UPC Check Digit Validation using SAP Screen Personas 2.0 and couldn't get it to work. It looks like the system didn't like the coding. I am hoping someone could take a look at this code and let me know what's wrong with this code. Any help provided would be greatly appreciate it. Thanks!
var evens=0;
var odds=0;
var remainder=0;
// walk through each character except the last in the var args.bottleupc
for (i=0,i<args.bottleupc.length-1;i++)
{
// add the odd and even numbers
if ((i % 2) == 1)
odds = odds + parseInt(args.bottleupc.substr(i,1));
else
evens = evens + parseInt(args.bottleupc.substr(i,1));
}
evens = evens * 3;
// get the remainder if not evenly divisible by 10
remainder=(evens+odds) % 10;
// compare the remainder to the last digit in args.bottleupc
if (remainder != parseInt(args.bottleupc.substr(args.bottleupc.length-1,1))
{
args.msg = "BAD CHECK DIGIT";
}
Hi Veronica,
Personas 2.0 does not support Javascript, so did you mean to say Personas 3.0 script? Also can you tell me what error you are getting?
Thanks
Chinthan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.