cancel
Showing results for 
Search instead for 
Did you mean: 

Sap Screen Personas 3.0 Validate one field

Former Member
0 Kudos

Hello,

I want to find one user in SU01 using the field username.

If there is no existing user I want to put a message saying, "user doesn't exist"

********************************************************

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

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;
}

Answers (1)

Answers (1)

Former Member
0 Kudos

If I removed "IF SENTENCE" the program works fine, but I want to do the validation.

Thanks!!

former_member189842
Participant
0 Kudos

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.