Skip to Content
avatar image
Former Member

SAP Screen Personas 2.0 - Help with JavaScript

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)); 
   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";
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • May 03, 2017 at 04:39 AM

    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?



    Add comment
    10|10000 characters needed characters exceeded

    • 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.