on 01-09-2018 9:38 PM
Hello,
I created a script in Screen Personas that worked in SP4, but after the upgrade to SP5, the script errors out. Can someone help troubleshoot the script? It is similar to the scripting examples from Screen Personas for Advanced Scenarios week 2 unit 4 (link below).
https://open.sap.com/files/6b04c6e9-d7a5-45b6-ad67-540f2567b18f
See my script below. This is used in a ME53N flavor. Thanks much.
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:*/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3212/cntlGRIDCONTROL/shellcont/shell").selectAll();
var oTableControl = session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:*/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3212/cntlGRIDCONTROL/shellcont/shell");
var aRows = parseSelectedRowsAbsolute(oTableControl.selectedRowsAbsolute);
var aMaterialDescr = "";
for (i=0; i<aRows.length;i++){
aMaterialDescr += oTableControl.getCellValue(aRows[i], "BNFPO") + ")" + " " + oTableControl.getCellValue(aRows[i], "TXZ01") + " " + "-" + " " + oTableControl.getCellValue(aRows[i], "MENGE") + " " + oTableControl.getCellValue(aRows[i], "MEINS") + "\n" ;
}
alert("Purchase Requisition Items:" + " " + aMaterialDescr);
function parseSelectedRowsAbsolute(sRows) {
var i, j, aRows = [], aTokens, aRange;
if (sRows === null || sRows === "") return aRows;
if(sRows.charAt(0)==";") {
sRows = sRows.substring(1); // trim leading semicolon
}
if(sRows.charAt(sRows.length-1)==";") {
sRows = sRows.substring(0, sRows.length-1); // trim trailing semicolon
}
aTokens = sRows.split(";");
for (i=0; i<aTokens.length; i++){
if (aTokens[i].indexOf("-")>0) {
aRange = aTokens[i].split("-");
for(j=Number(aRange[0]); j<=Number(aRange[1]); j++){
aRows.push(j);
}
}
else {
aRows.push(Number(aTokens[i]));
}
}
return aRows;
}
Hi Benjamin.
I'm not sure what your script is trying to display but is it possible you are having a control overwrite issues?
We recently moved from SP3 to SP6 and have some scripts that are no longer running for this reason.
If you are trying to display some like this, the attached code works for me in SP6.
"Purchase Requisition Items:
30) Air Handling Unit - 20 EA
50) Pipette - 100 EA"
I hope this helps,
Cristin
var oTableControl = session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:*/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211");
var aRows = parseSelectedRowsAbsolute(oTableControl.selectedRowsAbsolute);
var aMaterialDescr = "";
for (var i=0; i<aRows.length;i++){
aMaterialDescr += "\n" + oTableControl.getCellValue(aRows[i], "MEPO1211-EBELP") + ")" + " " + oTableControl.getCellValue(aRows[i], "MEPO1211-TXZ01") + " " + "-" + " " + oTableControl.getCellValue(aRows[i], "MEPO1211-MENGE") + " " + oTableControl.getCellValue(aRows[i], "MEPO1211-MEINS");
}
alert("Purchase Requisition Items:" + " " + aMaterialDescr);
function parseSelectedRowsAbsolute(sRows) {
var i, j, aRows = [], aTokens, aRange;
if (sRows === null || sRows === "") return aRows;
if(sRows.charAt(0)==";") {
sRows = sRows.substring(1); // trim leading semicolon
}
if(sRows.charAt(sRows.length-1)==";") {
sRows = sRows.substring(0, sRows.length-1); // trim trailing semicolon
}
aTokens = sRows.split(";");
for (i=0; i<aTokens.length; i++){
if (aTokens[i].indexOf("-")>0) {
aRange = aTokens[i].split("-");
for(j=Number(aRange[0]); j<=Number(aRange[1]); j++){
aRows.push(j);
}
}
else {
aRows.push(Number(aTokens[i]));
}
}
return aRows;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Cristin,
Thanks for helping out! Yes, I'm trying to get a pop-up message with the PR item information. However, I do not get the same result as you using your code in my ME53N flavor. Can you expand on the control overwrite issues you mention above? Any troubleshoot ideas for that? Thanks much.
Hi again, Benjamin.
Firstly, and this is on me, I was playing with ME23N and not ME53N - whoops. I'm not very familiar with these transactions...
I started again with ME53N and copied your code directly. The only thing I needed to do to make it work in SP6 was add a "var i = 0" to the for loop. The log was showing an error that i was undefined.
Could that be the problem?
Cristin
Hi Cristin,
Yes that worked for me in the ME53N Flavor. Thanks! However, now I am trying to get that alert message to my SMEN Dashboard Flavor. It does not seem to work when the script starts at the SMEN flavor. I'm trying to achieve the following steps:
1) Execute script on SMEN Flavor
2) Goes to ME53N
3) Retrieve item info on table
4) Return to SMEN Flavor
5) Alert message.
I have included my script below. Do you notice anything wrong with the script, perhaps another variable that needs to be defined? I have troubleshooted and debugged and can't seem to find the issue still. Thanks much.
var PR = session.findById("wnd[0]/usr/boxPersonas_148847518571534/ctxtPersonas_149004562956335").text;
if (!(PR)){
session.findById("wnd[0]/usr/boxPersonas_148847518571534/ctxtPersonas_149004562956335").setProperty("backgroundColor", "#FFC9C9");
session.findById("wnd[0]/usr/boxPersonas_148847518571534/ctxtPersonas_149004562956335").setProperty("borderColor", "#FF0000");
session.findById("wnd[0]/usr/txtPersonas_150645980996116").text = "";
session.findById("wnd[0]/usr/txtPersonas_148847545810988").text = "";
session.findById("wnd[0]/usr/boxPersonas_148847518571534/txtPersonas_148848130155264").text = "";
session.findById("wnd[0]/usr/txtPersonas_148847546339198").text = "";
session.findById("wnd[0]/usr/txtPersonas_148855780542963").text = "";
session.findById("wnd[0]/usr/boxPersonas_148847518571534/txtPersonas_150698115034275").text = "";
return;
} else {
session.findById("wnd[0]/usr/boxPersonas_148847518571534/ctxtPersonas_149004562956335").setProperty("backgroundColor", "");
session.findById("wnd[0]/usr/boxPersonas_148847518571534/ctxtPersonas_149004562956335").setProperty("borderColor", "");
}
session.startTransaction("ME53N");
session.findById("wnd[0]/tbar[1]/btn[17]").press();
session.findById("wnd[1]/usr/subSUB0:SAPLMEGUI:0003/ctxtMEPO_SELECT-BANFN").text = PR;
session.findById("wnd[1]/tbar[0]/btn[0]").press();
if (session.findById("wnd[0]/sbar").messageId === "06"){
session.findById("wnd[0]/tbar[0]/btn[12]").press();
session.findById("wnd[0]/usr/boxPersonas_148847518571534/ctxtPersonas_149004562956335").setProperty("backgroundColor", "#FFC9C9");
session.findById("wnd[0]/usr/boxPersonas_148847518571534/ctxtPersonas_149004562956335").setProperty("borderColor", "#FF0000");
session.findById("wnd[0]/usr/txtPersonas_150645980996116").text = "";
session.findById("wnd[0]/usr/txtPersonas_148847545810988").text = "";
session.findById("wnd[0]/usr/boxPersonas_148847518571534/txtPersonas_148848130155264").text = "";
session.findById("wnd[0]/usr/txtPersonas_148847546339198").text = "";
session.findById("wnd[0]/usr/txtPersonas_148855780542963").text = "";
session.findById("wnd[0]/usr/boxPersonas_148847518571534/txtPersonas_150698115034275").text = "";
}else {
if (session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:*/subSUB2:SAPLMEVIEWS:1100/subSUB1:SAPLMEVIEWS:4001/btnDYN_4000-BUTTON").iconId === "DAAREX"){
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:*/subSUB2:SAPLMEVIEWS:1100/subSUB1:SAPLMEVIEWS:4001/btnDYN_4000-BUTTON").press();
}
if (session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:*/subSUB3:SAPLMEVIEWS:1100/subSUB1:SAPLMEVIEWS:4002/btnDYN_4000-BUTTON").iconId === "DAAREX"){
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:*/subSUB3:SAPLMEVIEWS:1100/subSUB1:SAPLMEVIEWS:4002/btnDYN_4000-BUTTON").press();
}
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:*/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3212/cntlGRIDCONTROL/shellcont/shell").selectAll();
}
var oTableControl = session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:*/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:3212/cntlGRIDCONTROL/shellcont/shell");
var aRows = parseSelectedRowsAbsolute(oTableControl.selectedRowsAbsolute);
var aMaterialDescr = "";
for (var i=0; i<aRows.length;i++){
aMaterialDescr += oTableControl.getCellValue(aRows[i], "BNFPO") + ")" + " " + oTableControl.getCellValue(aRows[i], "TXZ01") + " " + "-" + " " + oTableControl.getCellValue(aRows[i], "MENGE") + " " + oTableControl.getCellValue(aRows[i], "MEINS") + "\n" ;
}
alert("Purchase Requisition Number:" + " " + PR + "\n" + "\n" + aMaterialDescr);
function parseSelectedRowsAbsolute(sRows) {
var i, j, aRows = [], aTokens, aRange;
if (sRows === null || sRows === "") return aRows;
if (sRows.charAt(0)==";") {
sRows = sRows.substring(1); // trim leading semicolon
}
if (sRows.charAt(sRows.length-1)==";") {
sRows = sRows.substring(0, sRows.length-1); // trim trailing semicolon
}
aTokens = sRows.split(";");
for (i=0; i<aTokens.length; i++){
if (aTokens[i].indexOf("-")>0) {
aRange = aTokens[i].split("-");
for(j=Number(aRange[0]); j<=Number(aRange[1]); j++){
aRows.push(j);
}
}
else {
aRows.push(Number(aTokens[i]));
}
}
return aRows;
}
session.findById("wnd[0]/tbar[0]/btn[15]").press();
Hi Benjamin.
I played with it some more and for me I was having issues with the selectedRowsAbsolute property. The "selectAll" doesn't seem to be really selecting them.
What I tried this time is using the rowCount property of oTableControl to count how many rows there are rather than how many were selected.
I also had to change the getCellValue to only "i" instead of aRows[i]. I commented out the function.
This seems to work for me...
Kind Regards,
Cristin
//var aRows = parseSelectedRowsAbsolute(oTableControl.selectedRowsAbsolute);
var numRows = oTableControl.rowCount;
var aMaterialDescr = "";
for (var i=0; i<numRows;i++){
aMaterialDescr += oTableControl.getCellValue(i, "BNFPO") + ")" + " " + oTableControl.getCellValue(i, "TXZ01") + " " + "-" + " " + oTableControl.getCellValue(i, "MENGE") + " " + oTableControl.getCellValue(i, "MEINS") + "\n" ;
}
session.utils.alert("Purchase Requisition Number:" + " " + PR + "\n" + "\n" + aMaterialDescr);
/*
function parseSelectedRowsAbsolute(sRows) {
var i, j, aRows = [], aTokens, aRange;
if (sRows === null || sRows === "") return aRows;
if (sRows.charAt(0)==";") {
sRows = sRows.substring(1); // trim leading semicolon
}
if (sRows.charAt(sRows.length-1)==";") {
sRows = sRows.substring(0, sRows.length-1); // trim trailing semicolon
}
aTokens = sRows.split(";");
for (i=0; i<aTokens.length; i++){
if (aTokens[i].indexOf("-")>0) {
aRange = aTokens[i].split("-");
for(j=Number(aRange[0]); j<=Number(aRange[1]); j++){
aRows.push(j);
}
}
else {
aRows.push(Number(aTokens[i]));
}
}
return aRows;
}
*/
session.findById("wnd[0]/tbar[0]/btn[15]").press();
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.