Skip to Content
0

Scripting issue after upgrade. Can someone help troubleshoot my Screen Personas script?

Jan 09 at 09:38 PM

185

avatar image
Former Member

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;
}
10 |10000 characters needed characters left characters exceeded

Including the errors you get might help a lot with figuring out the problem. It is hard to debug "errors out" :-)

Steve,

1
Former Member
Steve Rumsby

Right. Thanks. See error message below:

sap.personas.scripting : Error during script execution: assignment to undeclared variable ianonymous@[AppID:ME53N]>[Flavor:Display_PR]>[Script:wnd[0]/scrptPersonas_005056A957741ED7BDC16A82F4D70134-test]:17:6

0

You can use the F12 Developer Tools on your browser

Then on Console etc on various tabs, you might be able to see some errors listed

You can share those screenshots with us

0
Former Member
ERALPER YILMAZ

Right. Thanks. See error message below:

sap.personas.scripting : Error during script execution: assignment to undeclared variable ianonymous@[AppID:ME53N]>[Flavor:Display_PR]>[Script:wnd[0]/scrptPersonas_005056A957741ED7BDC16A82F4D70134-test]:17:6

0

In Script Editor on your Screen Personas flavor, you will see a script named "

scrptPersonas_005056A957741ED7BDC16A82F4D70134-test" which you have created

It seems that you are assigning a value to a variable which has not beed declared before that line.

Could you please check if that is the reason?

0
Former Member
ERALPER YILMAZ

I'm pretty sure that it has something to do with variable aMaterialDescr? As that is the information that is being left out in the result.

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);
0

It seems OK to me at first glance, but you can comment and check if you still get errors

0
Former Member
ERALPER YILMAZ

Thanks, but still get the same error. Like I said, it worked in SP04 but after upgrade to SP05 it does not. I think that applying note 2467868 where there is a symptom listed that an “upgrade” is needed for older scripts might help.

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Cristin Charbonneau Jan 19 at 04:23 PM
0

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;
}
Show 5 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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.

0

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

me53n.jpg (187.0 kB)
1
Former Member
Cristin Charbonneau

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();
0

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();

1
Former Member
Cristin Charbonneau

Thanks Cristin you're awesome! That worked for me.

0