cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Screen Personas 2.0 - Help with JavaScript

Former Member
0 Kudos

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";
}

Accepted Solutions (0)

Answers (1)

Answers (1)

chinthan_yajamaan
Active Contributor
0 Kudos

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

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

I think she means having the above script within a 'Calculate with JavaScript' script step 🙂

Theoretically this could work, but indeed, knowing the error message would probably help in identifying the problem.