Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Maybe some of you have experienced this problem and maybe not. Maybe you just knew the answer but I couldn't find it on here anywhere so when I figured it out, I figured I'd share.

In the current environment I'm working in, when a new account is entered into IDM, be it through IDM directly or via the HR system, the first 6 characters of the last name and a couple characters from the first name or nickname are then used to complete the MSKEYVALUE, which is in turn becomes the user's Windows and SAP login IDs. We call this the 6+2 unique ID. The problem that was occurring was that if the person had spaces in their last name, that space counted as a character. It would get squeezed out when the actual MSKEYVALUE was created but it would then leave the ID in a 5+2 state.

For example, a name of "Jodi Van Camp", "Van Camp" being the MX_LASTNAME, would turn out an MSKEYVALUE of "VanCaJo" when it should be "VanCamJo".

The bottom line was, we needed to eliminate those spaces in the last name for the purpose of creating the MSKEYVALUE.

I thought it would be a simple replace using a script. Maybe something like this:


function z_eliminateWhitespace(Par){
  var result = Par.replace(/\s+/g, "");
  return result;
}

Or maybe this:


function z_eliminateWhitespace(Par){
  var result = Par.replace(/\s/g, "");
  return result;
}

Or this:


function z_eliminateWhitespace(Par){
  var result = Par.replace(/ /g, "");
  return result;
}

Or lastly, this:


function z_eliminateWhitespace(Par){
  var result = Par.replace(" ", "");
  return result;
}

None of this seemed to work. I've had it happen way too many times where a SQL query or JavaScript won't work exactly the way it should in IDM as it does in other environments so this wasn't a total surprise but now what? Finally, I happen on the idea of splitting the string on the spaces and rejoining it without the spaces. This was the script I eventually came up with and it seems to work:


function z_eliminateWhitespace(Par){
  var result = Par.split(" ").join("");
  return result;
}

The final script had an IF line before the split / join checking Par to make sure it wasn't empty or a NULL value but you get the general idea. Hope this perhaps helps someone out there someday.

2 Comments
Labels in this area