Skip to Content
0

SAP Screen Personas 2.0 - Help with JavaScript

May 02, 2017 at 09:16 PM

44

avatar image
Former Member

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";
}
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Chinthan Yajamaan
May 03, 2017 at 04:39 AM
0

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

Show 1 Share
10 |10000 characters needed characters left 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.

0