Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

SAP Screen Personas - Getting Started


 

Scripting


SAP Screen Personas- by Former Member , Regina Sheynblat

Purpose

The purpose of this document is to provide a brief overview of scripting done in SAP Screen Personas 3.0.

Overview

The following are a brief examples of how to do scripting in SAP Screen Personas 3.0.

Scripting 101 Documentation

The object of this documentation is to give you a brief overview of scripting.  It shows simples examples on how to :

  1. Create a Script
  2. Validate a Script
  3. Rename a Script
  4. Delete a Script
  5. Use Logging
  6. Script Inspector
  7. How to use variables
  8. How to get data from a different script
  9. How to Work with Dates

The whole document can be found here

How to Do: Radio Buttons

To see step by step instructions on how to script Radio Buttons click here.  SAP Screen Personas 3.0 Scripting - Radio Button . How to Do Radio Buttons Video: https://video.sap.com/media/t/0_mnzvu2g2

How to Do: Create an F4 Search Help Element

To see step by step instructions on how to script an F4 Search Help Element click here. SAP Screen Personas 3.0 Scripting - F4 Search Help

How to Do: Creating a List Report with the use of a template

To see step by step instruction on how to create list reports with templates click here.  SAP Screen Personas 3.0 Scripting - List Report Template

How to Do: If/Then statements

The following video and code shows you how to use JavaScript to do a simple If/Then statement.

  • To see the documentation that supports the video above just click here:  IfThenExample.pdf

 

If/Then Scenario
//copy the sales order into a variable
var salesorder=session.findById("wnd[0]/usr/txtPersonas_3").text;
  
//execute transaction va03
session.findById("wnd[0]/tbar[0]/okcd").text = "va03";
session.findById("wnd[0]").sendVKey(0);
  
//press enter
session.findById("wnd[0]/tbar[0]/btn[0]").press();
  
//paste the value into order
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").text=salesorder;
session.findById("wnd[0]").sendVKey(0);

How to Do: Nested If/Then and Incorporate Information Pop-ups

To see step by step instructions on how to do nested if/then statements and incorporate inforamtion pop-ups click here: SAP Screen Personas 3.0 Scripting - Information Pop-Ups

How to Do: Copy and Paste

The following video and code shows you how to use JavaScript to do Copy & Paste scenario.

 

Copy and Paste Script
//After entering the Sales Order Press the Display Button to go to the 2nd screen 
session.findById("wnd[0]/usr/btnDISPLAY").press();    
 
// Assign the Country to a Variable that is called country 
var country=session.findById("wnd[0]/usr/tabsEPM_SO_TAB/tabpEPM_SO_TAB_FC1/ssubEPM_SO_TAB_SCA:RS_EPM_SO_CLASSIC_DYNPRO:0301/txtSEPM_SO_HEADER_300-COUNTRY_NAME").text; 
 
//Assign the Net Amount to the variable called net_amount 
var net_amount=session.findById("wnd ]/usr/tabsEPM_SO_TAB/tabpEPM_SO_TAB_FC1/ssubEPM_SO_TAB_SCA:RS_EPM_SO_CLASSIC_DYNPRO:0301/txtSEPM_SO_HEADER_300-NET_AMOUNT").text;    
 
//Press the Back button to go back to 1st Screen 
session.findById("wnd[0]/tbar[0]/btn[3]").press();    
 
//Paste the Country into the text field Country that you created using Personas 
session.findById("wnd[0]/usr/txtPersonas_4").text=country;    
 
//Paste the Net Amount into the text field Net Amount that you created using Personas 
session.findById("wnd[0]/usr/txtPersonas_5").text=net_amount;

How to Do: Sales Order Lookup

The following video and code shows you how to use JavaScript to a Sales Order Lookup.

 

Sales Order Lookup
//copy the sales order into a variable
var salesorder=session.findById("wnd[0]/usr/txtPersonas_3").text;
//execute transaction va03
session.findById("wnd[0]/tbar[0]/okcd").text= "va03";
session.findById("wnd[0]").sendVKey(0);
//press enter
session.findById("wnd[0]/tbar[0]/btn[0]").press();
//paste the value into order
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").text=salesorder;
session.findById("wnd[0]/tbar[1]/btn[5]").press();
The following video and code show you how to work with Short Links in transaction VA01.

 

Initiate Rush Order
//Define Objects 
var objHtmlView = session.findById("wnd[0]/usr/htmlViewerPersonas_8");
//Define ShortLink 
var server = location.protocol + '//' + location.host; var rushOrderURL = server + "/sap/bc/personas?sap-ie=edge&sap-client=001&sap-language=EN&&sap-personas-source=300_cor&sap-personas-flavor=005056BA7C3A1ED496D7EA8101447348&~transaction=VA01";
//Refresh HTML Viewer Control 
objHtmlView.url = rushOrderURL;
Initiate Standard Order
//Define Objects 
var objHtmlView = session.findById("wnd[0]/usr/htmlViewerPersonas_8");
//Define ShortLink 
var server = location.protocol + '//' + location.host; var standardOrderURL = server + "/sap/bc/personas?sap-ie=edge&sap-client=001&sap-language=EN&&sap-personas-source=300_cor&sap-personas-flavor=005056BA7C3A1ED496C8EC82C3D6F348&~transaction=VA01";
//Refresh HTML Viewer Control 
objHtmlView.url = standardOrderURL;
  •  To see documentation that supports the video above just click here: ShortLinks.pdf

 

How to Do: Flavor Switching

The following video and code show you how to switch flavors under a condition. 
 
How to Switch Flavors
//Read Order Type from UI field 
var orderType = session.findById("wnd[0]/usr/ctxtVBAK-AUART").text;
//Switch Flavor based on Order Type 
if (orderType != 'undefined' && orderType != null) {  //Standard Order  if (orderType == "OR") {
  session.utils.changeFlavor("005056BA7C3A1ED496C8EC82C3D6F348");  }   
//Rush Order  
else if (orderType == "SO") {      session.utils.changeFlavor("005056BA7C3A1ED496D7EA8101447348");     } }
//Execute Enter keystroke 
session.findById("wnd[0]").sendVKey(0);
 

 

How to Do: Error Handling

The following video and code show you how to catch errors that are thrown by SAP.

 

Error Handling in SAP Screen Personas 30
// Define object 
var orderNumber=session.findById("wnd[0]/usr/txtPersonas_11").text; 
// Validate entry 
if (orderNumber.length > 0) {  
// Launch order display transaction         
session.callTransaction("VA03");         
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").text = orderNumber;  
// Press enter        
 session.findById("wnd[0]").sendVKey(0);  
// Validate error message         
var message=session.findById("wnd[0]/sbar").text;         
if (message.length > 0) {          session.findById("wnd[0]/tbar[0]/btn[3]").press();                
 alert(message);         } } else {                 alert("Please enter order number!"); } 

How to Do: Overwrite Pre-Filled Fields

The following video and code show you how to overwrite Pre-Filled Fields in SAP.

How to Overwrite Pre-Filled Fields
// Read date 
var startDate=session.findById("wnd[0]/usr/txtPersonas_31").text; 
// Launch transaction 
session.callTransaction("VA05"); 
// Replace pre-filled start date with the entered date 
session.findById("wnd[0]/usr/ctxtVBCOM-AUDAT").text = startDate;

Related Content

Related Search Terms:

SAP Screen Personas, <PUT YOUR SEARCH TERMS HERE AS A COMMA SEPARATED LIST>

Related SAP Notes/KBAs

<PUT NOTE NUMBERS HERE, IDEALLY INCLUDING THEIR TITLE>

 

 

Please check back for more content in the future.

  • No labels