on 01-28-2015 12:30 PM
Hi,
I have a requirement where I need to get the EQUIPMENT Number from a long string found in SAP. Please view ATTACHMENT.
This is my Input string from Tcode IA02.
Input: Equipment 149054 KOMATSU-PC1250LC-8
I need the Equipment Number 149054 and the Description KOMATSU-PC1250LC-8 separately for my output.
I am not sure if Javascript with string functions will work, since the input has multiple spaces.
Any ideas on how to go about this in PERSONAS???
Thanks
Abraham
Hi Startlet,
As Steve suggested, you can use javascript for this.
Check the below example code and you can combine what you want:
1. Find out the first occurrences of numbers in a string:
var r = /\d+/;
var s = "149054 KOMOATEST";
alert (s.match(r));
2. You want all the numbers in your string
var r = /\d+/g;
var s = "635 this is personas 1012";
var m;
while ((m = r.exec(s)) != null) {
alert(m[0]);
}
3. Remove whitespace from string
var s = "this is my test personas";
alert(s.replace(/ /g,''));
if you want to learn more about regex in js, you might want to check:
Regards,
Sushant
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sushant,
I tried as you said in PERSONAS. Now the Javascript error has disappeared but my output is "System.Windows.Browser.ScriptObject"
Do you know what would be wrong here.
Thanks
Abraham
FYI: The javascript code#1 works perfectly to fetch the Equip# from the string. I tested it on one of the online test environments and it works perfectly.
You will need to use a JavaScript action for this. How you parse it in JS will depend on the structure, but you can certainly do it with JS string functions. You will probably want to use indexOf and lastIndexOf string methods to pick the string apart.
Steve.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.