on 10-09-2015 2:29 PM
Hi Experts
We are facing one issue on screen personas while table parsing to capture data selected row from the table.
We are tried using given example on SCN
Link: http://wiki.scn.sap.com/wiki/display/Img/SAP+Screen+Personas+3.0+and+Tables
Used below code:
// Define Objects
var objAdditDataBtn = session.findById("wnd[0]/tbar[1]/btn[30]"),
objMainDataBtn = session.findById("wnd[0]/tbar[1]/btn[27]"),
objAdditTable = session.findById("wnd[0]/usr/tabsTABSPR1/tabpZU01/ssubTABFRA1:SAPLMGMM:2110/subSUB2:SAPLMGD1:8000/tblSAPLMGD1TC_KTXT"),
objInfo = session.findById("wnd[0]/usr/textEditPersonas_4");
// Define Functions
// Parse data from table object to an array function
parseTable(srcTable) {
var totalColNum = srcTable.columns.length,
totalRowNum = srcTable.rowCount,
resTable = new Array();
for (var curColNum=1; curColNum<=totalColNum; curColNum++) {
var curCol = srcTable.getColumnId(curColNum);
resTable[curColNum] = new Array();
resTable[curColNum][0] = curCol;
for (var curRowNum = 0; curRowNum<totalRowNum; curRowNum++) {
resTable[curColNum][curRowNum+1] = srcTable.getCellValue
(curRowNum, curCol); } } return resTable; }
// Table data formatting function
formatTableData(srcTable) {
var resArr = [];
for (var i = 1; i < srcTable.length; i++) {
for (var j = 1; j < srcTable[i].length; j++) {
var val = srcTable[i][j].replace(/\_/g,"");
if(val) {
resArr[j] = (resArr[j]) ? resArr[j] + " " + val : val;
}
}
}
return resArr.join("\n");
}
// Parse the table and display the results
var jsAdditTable = parseTable(objAdditTable),
copyData = formatTableData(jsAdditTable);
only modified screen ID’s
we are getting below error
Unexpected token {
I removed some code given only
parseTable(srcTable) {
}
For above code also I am getting same error
Please advise how to solve the issue.
I think part of the problem is that your function definitions are missing the "function" keyword. So rather than:
formatTableData(srcTable) {
var resArr = [];
for (var i = 1; i < srcTable.length; i++) {
for (var j = 1; j < srcTable[i].length; j++) {
var val = srcTable[i][j].replace(/\_/g,"");
if(val) {
resArr[j] = (resArr[j]) ? resArr[j] + " " + val : val;
}
}
}
return resArr.join("\n");
}
you should have:
function formatTableData(srcTable) {
var resArr = [];
for (var i = 1; i < srcTable.length; i++) {
for (var j = 1; j < srcTable[i].length; j++) {
var val = srcTable[i][j].replace(/\_/g,"");
if(val) {
resArr[j] = (resArr[j]) ? resArr[j] + " " + val : val;
}
}
}
return resArr.join("\n");
}
But also look at the code in this Wiki page to see how to copy data from a table: Copying Table data into a variable - SAP Imagineering - SCN Wiki. I'm not sure your parseTable function will work correctly.
Steve.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks steve for quick replay.
above problem was solved.
My exact requirement is I have a flat file I tried upload data and after some modification to data
I have displayed the same in the ALV, now user clicked on any row we have to select the particular row need to capture the row.
In this case when I use object picker to select the ALV it is showing as a shell not like table.
Please advise in this case.
That is correct. The object ID will say it is a "shell" but look at the type in the object inspector and it will be a TableView or GridView, like this:
You can use the "onSelect" event of a grid or table to trigger a script. That script will be passed a "source" parameter that references the table, from which you can get the selected row number and then call getCellValue, like this:
var row = parseInt(source.selectedRows);
var value = source.getCellValue(row, "CCOL");
(substitute the appropriate column name, obviously )
Does that make sense?
Steve.
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.