on 05-14-2015 12:52 PM
You can get more specific with status bar messages.
Use JS .contains for a string to look for certain error message you are looking for...etc etc..
Below example is for a flavor from transaction SMEN....
//Get the username entered by the user
var uName = session.findById("wnd[0]/usr/txtPersonas_2").text;
//Goto SU01
session.findById("wnd[0]/tbar[0]/okcd").text = "/nsu01";
session.findById("wnd[0]").sendVKey(0);
//Enter the username
session.findById("wnd[0]/usr/ctxtSUID_ST_BNAME-BNAME").text = uName;
//Press Display
session.findById("wnd[0]/tbar[1]/btn[7]").press();
//If there is an error in status bar, come back to main screen and display the result
if(session.findById("wnd[0]/sbar").text){
session.findById("wnd[0]/tbar[0]/btn[3]").press();
session.findById("wnd[0]/usr/txtPersonas_4").text = "User Does not Exist";
}
else{
//Capture the lastname
var lname = session.findById("wnd[0]/usr/tabsTABSTRIP1/tabpADDR/ssubMAINAREA:SAPLSUID_MAINTENANCE:1900/txtSUID_ST_NODE_PERSON_NAME-NAME_LAST").text;
//Go back to SMEN
session.findById("wnd[0]/tbar[0]/okcd").text = "/n";
session.findById("wnd[0]").sendVKey(0);
//Paste the last name
session.findById("wnd[0]/usr/txtPersonas_4").text = lname;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If I removed "IF SENTENCE" the program works fine, but I want to do the validation.
Thanks!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I assume in your original script you have { after else, which is missing here. Other than that put a debugger; statement in the first line of else. when you open chrome/safari debugger tools, the control will stop there and let you see the flow. Script errors very easy to catch, as a matter of fact.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.