Skip to Content
avatar image
Former Member

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

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

  • 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);
  • It seems OK to me at first glance, but you can comment and check if you still get errors

  • 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.

  • Get RSS Feed

1 Answer

  • Jan 19 at 04:23 PM

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