on 07-24-2012 10:40 PM
Hello,
I have implemented copy paste functionality from "How To... Copy & Paste in BEx Web" (Link: http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/80220fed-0e6d-2b10-bbb9-f6af76dee...) to copy data from Excel to IP input screen. It is working fine with BW 7.0 webtemplates.
When we upgrade from BW 7.0 to BW 7.3 the webtemplate with copy paste Java script functionality is not work, and it is showing java script error.
and i have checked in the old BW 7.0 same webtemplate is working.
Can please advice what should be done to fix this java script error in BW 7.3? has anybody is using this copy paste java script in BW 7.3?
Thanks.
Actually we had problems with Internet Explorer browser, but the note: 1756779 explains the issue with Firefox browser.
I have communicated with SAP though a OSS message some time back and got the below information and it is working.
Follow below steps:
1. in BW7.3 webtemplate, for analysis item, which is represetning input enabled query should have below HTML code.
<bi:MODIFICATION type="CHOICE" value="MOD_SINGLE_MODULE" >
<bi:MOD_SINGLE_MODULE type="COMPOSITE" >
<bi:ACTIVE value="X" />
<bi:MOD_SELECT type="CHOICE" value="MOD_GENERIC_MODULE" >
<bi:MOD_GENERIC_MODULE type="COMPOSITE" >
<bi:MOD_REFERENCE value="com.sap.ip.bi.rig.CopyPaste" />
</bi:MOD_GENERIC_MODULE>
</bi:MOD_SELECT>
</bi:MOD_SINGLE_MODULE>
2. then execute IP web application.
3. select first cell in the input grid and hold the shift button and then select the last cell, that defines your selection criteria for paste.
4. now prepare the data in the excel file with required format, then copy(ctrl+C)
5. goto input grid, click paste(ctrl+V). it places the copied content.
Thanks,
pundari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Pundari,
we have the same problem. So I followed your steps. In step 5: 'it places the copied content.' ..but when I paste all the copied content is placed in one cell of the input grid. I tested different typs for the excel workbook, as csv, as webside, as webarchive....
what do you mean with 'prepare the data in the excel file with required format'?
Thanks and Regards
Hans John
Dear all,
use the way of Pundari with the MODIFICATION of the analysis item and leaf the scipt of the "How to ...copy and paste in BEx Web..." paper.
Read more about it in Analysis Web Item Parameter Modification from Andrey Uryukin.
Thanks and best regards
Hans John
Dear Andreas,
use the link to
Analysis Web Item Parameter Modification from Andrey Uryukin and download paper part 1.
In part 1 you find on page 51 all what you need: the modification you have to place in the analysis item and the html-code of the buttongroup (for 'Copy', 'Paste' and 'Clear Cells') you have to add. That s all. (I you have implemented the java script of the 'How to ..copy and paste...' paper in the web template delete it!)
Perform your Web Template and select first cell in the input grid and hold the shift button and then select the last cell, that defines your selection criteria for paste.
Take the same area of excel cells to the clipboard and paste it in your web template with the button 'Paste'.
Please, give me a feedback.
Best regards,
Hans John
Hi Hans,
thanks for your answer.
I tried everything you told me, but i still have the same problem.
Here is my button:
<bi:BUTTON index="1" type="COMPOSITE" >
<bi:CAPTION value="Paste" />
<bi:ACTION type="CHOICE" value="SCRIPT_FUNCTION" >
<bi:SCRIPT_FUNCTION value="sapbi_rig_cp_paste_clipboard" />
</bi:ACTION>
</bi:BUTTON>
And here my Ana-item:
<bi:ANALYSIS_ITEM name="HR_DATA" designheight="200" designwidth="400" >
<bi:DATA_PROVIDER_REF value="ACT" />
<bi:MODIFICATION type="CHOICE" value="MOD_SINGLE_MODULE" >
<bi:MOD_SINGLE_MODULE type="COMPOSITE" >
<bi:ACTIVE value="X" />
<bi:MOD_SELECT type="CHOICE" value="MOD_GENERIC_MODULE" >
<bi:MOD_GENERIC_MODULE type="COMPOSITE" >
<bi:MOD_REFERENCE value="com.sap.ip.bi.rig.CopyPaste" />
</bi:MOD_GENERIC_MODULE>
</bi:MOD_SELECT>
</bi:MOD_SINGLE_MODULE>
</bi:MODIFICATION>
<bi:NEW_LINES_COUNT value="0" />
</bi:ANALYSIS_ITEM>
It tried using the button, but every time i click the button, i get the message:
"Selection not defined properly"
If i tried with "strg+v" it pastes just the first value in the first row.
If I select for example 4 rows it just pastes 1 row...
Do i need a special format in excel?
Thanks for your help.
Best regards
Andreas
Dear Andreas,
Please use the following script for buttons , it was working nicely.
// ------------------------------------------------------------------------------
// Copy and Paste for SAP BI Analysis Item
// ------------------------------------------------------------------------------
// Functionality: selecting a recangle in Analysis Item
// - mouse click and shift click to define
// - paste: select single cell and paste
// - paste: select multi cell and paste will fill all with identical content
// - paste: select multi and paste multi - message!
// - paste ignores table fields which are not input enabled (no tagName 'INPUT')
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------
// Options (set to "true" to enable function or "false" to disable it)
// ------------------------------------------------------------------------------
// - sapbi_rig_plan_copy_paste_option = true / false
// -> enables or disables the copy & paste functionality
//
// - sapbi_rig_plan_paste_overwrite_option = true / false
// -> overwrite cell content during paste option if function is enabled
//
// - sapbi_rig_plan_select_on_click_option = true / false
// -> select all cell content on click if function is enabled
//
// - sapbi_rig_plan_next_cell_on_return_option = true / false
// -> press enter/return button to jump to the next row if function
// is enabled
//
// - sapbi_rig_plan_next_cell_row_first_option = true / false
// -> if "next cell on return" is enabled it will jump to the next column
// in the same row
// ------------------------------------------------------------------------------
var sapbi_rig_plan_copy_paste_option = true;
var sapbi_rig_plan_paste_overwrite_option = true;
var sapbi_rig_plan_select_on_click_option = true;
var sapbi_rig_plan_next_cell_on_return_option = true;
var sapbi_rig_plan_next_cell_row_first_option = true;
// List of global dependencies:
/*jslint browser: true */
/*global UR_SELECTION_STATE, sapUrMapi_SapTable_setCellSelection, sapUrMapi_Table_getClickedRowIndex,
sapUrMapi_Table_getClickedColIndex, ur_Table_create, sapUrMapi_SapTable_getClickedCellId */
var sapbi_rig_plan_inf = [];
sapbi_rig_plan_inf.top = -1;
sapbi_rig_plan_inf.left = -1;
sapbi_rig_plan_inf.bottom = -1;
sapbi_rig_plan_inf.right = -1;
sapbi_rig_plan_inf.activeSel = [];
sapbi_rig_plan_inf.activeTabId = '';
sapbi_rig_plan_inf.brwsType = '';
function sapbi_rig_cp_copy_clipboard() { sapbi_rig_plan_copy_clipboard(); }
function sapbi_rig_cp_paste_clipboard() { sapbi_rig_plan_paste_clipboard(); }
function sapbi_rig_cp_clear(content) { sapbi_rig_plan_clear(content); }
// Check if state is OK to perform copy or paste action
// ------------------------------------------------------------
function sapbi_rig_plan_isValidState(info){
if (info.top === -1 || info.bottom === -1 || info.left === -1 || info.right === -1){
return false;
}
if (info.activeTabID === '' || info.activeSel.length === 0){
return false;
}
}
function sapbi_rig_plan_getTableId(src){
var cellId;
if (sapbi_rig_plan_inf.brwsType === 'IE') {
cellId = sapUrMapi_SapTable_getClickedCellId(src);
} else {
cellId = sapUrMapi_Table_getClickedCellId('', src);
}
var cell = document.getElementById(cellId);
var parentTbl = cell;
while (parentTbl !== null && parentTbl.tagName !== 'TABLE') {
parentTbl = parentTbl.parentNode;
}
parentTbl = parentTbl.parentNode;
while (parentTbl !== null && parentTbl.tagName !== 'TABLE') {
parentTbl = parentTbl.parentNode;
}
if (parentTbl === null) {
return '';
} else {
return parentTbl.id;
}
}
// Set selection coordinates and activeItem based on src-element
// -------------------------------------------------------------
function sapbi_rig_plan_onclick(row, col,tabId, shiftKey, info){
if (shiftKey !== true || info.activeTabId !== tabId){
info.top = row;
info.left = col;
info.bottom = row;
info.right = col;
info.activeTabId = tabId;
} else {
if (info.top === -1 || info.left === -1){
info.top = row;
info.left = col;
} else {
// sort coordinates
if (info.top > row){
info.bottom = info.top;
info.top = row;
} else {
info.bottom = row;
}
if (info.left > col){
info.right = info.right;
info.left = col;
} else {
info.right = col;
}
}
}
}
// Store IDs of selected cells and perform highlighting
// ----------------------------------------------------------
function sapbi_rig_plan_highlight(on, info){
// clear previous selection
var TDInfo = [];
if (info.activeSel !== undefined){
var cntDelMax = info.activeSel.length;
for (var cntDel = 0; cntDel<cntDelMax; cntDel++){
TDInfo = info.activeSel.pop();
var refTD = document.getElementById(TDInfo[0]);
if (refTD !== null){
if (sapbi_rig_plan_inf.brwsType === 'IE') {
sapUrMapi_SapTable_setCellSelection(refTD, UR_SELECTION_STATE.NOT_SELECTED);
} else {
sapUrMapi_SapTableSelectCell(refTD, false, false, true);
}
}
}
}
if (on === false){return;}
// set new selection
var refTbl = ur_Table_create(info.activeTabId);
if (refTbl === null){alert('ur model not found'); return;}
for (var cntRow = info.top; cntRow <= info.bottom; cntRow++){
for(var cntCol = info.left; cntCol <= info.right; cntCol++){
refTD = refTbl.rows[cntRow].cells[cntCol].ref;
if (refTD !== null){
if (sapbi_rig_plan_inf.brwsType === 'IE') {
sapUrMapi_SapTable_setCellSelection(refTD, UR_SELECTION_STATE.SECONDARY);
} else {
sapUrMapi_SapTableSelectCell(refTD, false, true, true);
}
TDInfo = [];
TDInfo[0] = refTD.id;
TDInfo[1] = cntRow;
TDInfo[2] = cntCol;
info.activeSel.push(TDInfo);
}
}
}
}
// Handler for OnClick Event
// -------------------------------------------------------------
function sapbi_rig_plan_onclickHandler(e){
var src;
var sid;
if (sapbi_rig_plan_inf.brwsType === 'IE'){
e = window.event;
src = e.srcElement;
} else{
src = e.target;
}
var shiftKey = e.shiftKey;
if (src === null || src.tagName === 'BODY' || src.tagName === 'HTML'){
sapbi_rig_plan_highlight(false, sapbi_rig_plan_inf);
return;
}
var row;
var col;
if (sapbi_rig_plan_inf.brwsType === 'IE'){
row = sapUrMapi_SapTable_getClickedRowIndex(e);
col = sapUrMapi_SapTable_getClickedColIndex(e);
} else {
var cellRef = document.getElementById(sapUrMapi_Table_getClickedCellId('', e));
if (cellRef !== null) {
row = cellRef.getAttribute('rr');
col = cellRef.getAttribute('cc');
}
}
if (isNaN(row) || isNaN(col)){
return;
}
var tabId = sapbi_rig_plan_getTableId(e);
if (tabId.indexOf('_ia_pt_a') > 0) {
row--;
col--;
}
sapbi_rig_plan_onclick(row, col, tabId, shiftKey,sapbi_rig_plan_inf);
if (sapbi_rig_plan_select_on_click_option == true && shiftKey == false) {
sapbi_rig_plan_select_on_click(row, col, tabId);
}
if (sapbi_rig_plan_copy_paste_option == true) {
sapbi_rig_plan_highlight(true, sapbi_rig_plan_inf);
}
}
// Handler for OnKeyDown Event
// -------------------------------------------------------------
function sapbi_rig_plan_onkeydownHandler(e) {
var keynum;
var keyreturn = false;
if (window.event) // IE
{
keynum = e.keyCode;
if (keynum == 13)
keyreturn = true;
}
else if (e.which) // Netscape/Firefox/Opera
{
keynum = e.which;
if (keynum == 13)
keyreturn = true;
}
if (keyreturn == false) {
return true;
}
var src;
var sId;
if (sapbi_rig_plan_inf.brwsType === 'IE') {
e = window.event;
src = e.srcElement;
} else {
src = e.target;
}
if (src === null || src.tagName === 'BODY' || src.tagName === 'HTML') {
return;
}
var row;
var col;
if (sapbi_rig_plan_inf.brwsType === 'IE') {
row = sapUrMapi_SapTable_getClickedRowIndex(e);
col = sapUrMapi_SapTable_getClickedColIndex(e);
} else {
var cellRef = document.getElementById(sapUrMapi_Table_getClickedCellId('', e));
if (cellRef !== null) {
row = cellRef.getAttribute('rr');
col = cellRef.getAttribute('cc');
}
}
if (isNaN(row) || isNaN(col)) {
return;
}
var tabId = sapbi_rig_plan_getTableId(e);
if (tabId.indexOf('_ia_pt_a') > 0) {
row--;
col--;
}
if (sapbi_rig_plan_next_cell_on_return_option == true) {
sapbi_rig_plan_setFocusOnNextCell(row, col, tabId);
}
return false;
}
function sapbi_rig_plan_setFocusOnNextCell(row, col, tabId) {
var refTbl = ur_Table_create(tabId);
if (refTbl === null) { alert('ur model not found'); return; }
var maxRows = refTbl.rows.length;
var maxCols = refTbl.cols.length;
var colCnt;
var rowCnt;
var inputField;
if (sapbi_rig_plan_next_cell_row_first_option == false) {
// column first
row++; // next cell
for (colCnt = col; colCnt < maxCols; colCnt++) {
for (rowCnt = row; rowCnt < maxRows; rowCnt++) {
cellTD = refTbl.rows[rowCnt].cells[colCnt].ref;
if (cellTD != null) {
inputField = cellTD.getElementsByTagName('INPUT');
if (inputField != null && inputField.length > 0) { inputField[0].select(); return; }
}
}
row = 0;
}
} else {
// row first
col++; // next cell
for (rowCnt = row; rowCnt < maxRows; rowCnt++) {
for (colCnt = col; colCnt < maxCols; colCnt++) {
cellTD = refTbl.rows[rowCnt].cells[colCnt].ref;
if (cellTD != null) {
inputField = cellTD.getElementsByTagName('INPUT');
if (inputField != null && inputField.length > 0) { inputField[0].focus(); inputField[0].select(); return; }
}
}
col = 0;
}
}
}
// Global
// Register handler for events
// -------------------------------------------------------------
if (typeof (window.addEventListener) != 'undefined') {
sapbi_rig_plan_inf.brwsType = 'NN';
if (sapbi_rig_plan_select_on_click_option == true || sapbi_rig_plan_copy_paste_option == true) {
document.addEventListener('click',sapbi_rig_plan_onclickHandler,false);
}
if (sapbi_rig_plan_next_cell_on_return_option == true) {
document.addEventListener('onkeydown', sapbi_rig_plan_onkeydownHandler, false);
}
} else {
sapbi_rig_plan_inf.brwsType = 'IE';
if (sapbi_rig_plan_select_on_click_option == true || sapbi_rig_plan_copy_paste_option == true) {
document.body.attachEvent('onclick', sapbi_rig_plan_onclickHandler);
}
if (sapbi_rig_plan_next_cell_on_return_option == true) {
document.body.attachEvent('onkeydown', sapbi_rig_plan_onkeydownHandler);
}
}
// -------------------------------------------------------------
function sapbi_rig_plan_getContent(cell){
if (cell === null){return '';}
var inputField = cell.getElementsByTagName('INPUT');
if (inputField.length === 0){
if (sapbi_rig_plan_inf.brwsType === 'IE') {
return cell.innerText;
} else {
return cell.textContent;
}
} else {
return inputField[0].value;
}
}
function sapbi_rig_plan_setContent(cell, value){
if (cell === null){return;}
var inputField = cell.getElementsByTagName('INPUT');
if (inputField.length !== 0){
inputField[0].value = value;
if (sapbi_rig_plan_inf.brwsType === 'IE') {
inputField[0].fireEvent('onchange');
} else {
var evt = document.createEvent('HTMLEvents');
evt.initEvent('change', true, true);
inputField[0].dispatchEvent(evt);
}
}
}
function sapbi_rig_plan_select_on_click(row, col, tabId) {
var refTbl = ur_Table_create(tabId);
if (refTbl === null) { alert('ur model not found'); return; }
refTD = refTbl.rows[row].cells[col].ref;
if (refTD === null) { return; }
var inputField = refTD.getElementsByTagName('INPUT');
if (inputField != null && inputField.length > 0) { inputField[0].select(); }
}
// Copy data to clipboard (including input-field handling)
// -------------------------------------------------------
function sapbi_rig_plan_copy_clipboard(){
if (!window.clipboardData) {
alert('Access to clipboard not successful - potential reason: security does not allow access.');
return;
}
var info = sapbi_rig_plan_inf;
if (sapbi_rig_plan_isValidState(info) === false){
alert('Selection not defined properly.');
return;
}
var refTD;
var ClipBoardStr = '';
var refTbl = ur_Table_create(info.activeTabId);
if (refTbl === null){alert('ur model not found'); return;}
for (var cntRow = info.top; cntRow<=info.bottom; cntRow++){
for(var cntCol = info.left; cntCol<=info.right; cntCol++){
refTD = refTbl.rows[cntRow].cells[cntCol].ref;
ClipBoardStr = ClipBoardStr + sapbi_rig_plan_getContent(refTD);
if (cntCol < info.right){
ClipBoardStr = ClipBoardStr + '\t';
}
}
if (cntRow < info.bottom){
ClipBoardStr = ClipBoardStr + '\r\n';
}
}
if (ClipBoardStr.length > 0){
var retCode = window.clipboardData.setData('Text',ClipBoardStr);
if (retCode === false) {
alert('Access to clipboard not successful - potential reason: security does not allow access.');
}
}
}
function sapbi_rig_plan_paste_clipboard() {
var info = sapbi_rig_plan_inf;
if (sapbi_rig_plan_isValidState(info) === false) {
alert('Selection not defined properly.');
return;
}
if (!window.clipboardData) {
alert('Paste: Could not access clipboard.');
return;
}
var clipBoardData = window.clipboardData.getData('Text');
if (clipBoardData.length > 0 && clipBoardData.charAt(clipBoardData.length-1) == '\n') { // cut trailing return
clipBoardData = clipBoardData.substring(0, clipBoardData.length-1);
}
var selSingle = (info.activeSel.length === 1);
var clpHasRows = (clipBoardData.indexOf('\n') !== -1);
var clpHasCols = (clipBoardData.indexOf('\t') !== -1);
var clpSingle = (clpHasRows === false && clpHasCols === false);
var cell;
if (clpSingle === true) {
for (var cntSel = 0; cntSel < info.activeSel.length; cntSel++) {
cell = document.getElementById(info.activeSel[cntSel][0]);
sapbi_rig_plan_setContent(cell, clipBoardData);
}
return;
}
if (selSingle === false) {
var clipCol;
var cellTD;
var clipRow = clipBoardData.split('\n');
var refTbl = ur_Table_create(info.activeTabId);
var maxRows = info.bottom - info.top + 1;
if (maxRows > clipRow.length) {
maxRows = clipRow.length;
}
var maxCols;
for (var rowCnt = 0; rowCnt < maxRows; rowCnt++) {
clipCol = clipRow[rowCnt].split('\t');
maxCols = info.right - info.left + 1;
if (maxCols > clipCol.length) {
maxCols = clipCol.length;
}
for (var colCnt = 0; colCnt < maxCols; colCnt++) {
cellTD = refTbl.rows[rowCnt + info.top].cells[colCnt + info.left].ref;
sapbi_rig_plan_setContent(cellTD, clipCol[colCnt]);
}
}
return;
}
if (clpSingle === false && selSingle == true && sapbi_rig_plan_paste_overwrite_option == true) {
var clipCol;
var cellTD;
var clipRow = clipBoardData.split('\n');
var refTbl = ur_Table_create(info.activeTabId);
var maxRows = clipRow.length;
var maxCols;
for (var rowCnt = 0; rowCnt < maxRows; rowCnt++) {
clipCol = clipRow[rowCnt].split('\t');
maxCols = clipCol.length;
if (maxCols + info.left >= refTbl.rows[rowCnt + info.top].cells.length) {
maxCols = refTbl.rows[rowCnt + info.top].cells.length - info.left;
}
for (var colCnt = 0; colCnt < maxCols; colCnt++) {
cellTD = refTbl.rows[rowCnt + info.top].cells[colCnt + info.left].ref;
sapbi_rig_plan_setContent(cellTD, clipCol[colCnt]);
}
}
return;
}
alert('Ranges from selection and clipboard does not fit');
return;
}
function sapbi_rig_plan_clear(content){
if ('undefined' == typeof(content) ) content = '';
if (content == null) content = '';
var info = sapbi_rig_plan_inf;
if (sapbi_rig_plan_isValidState(info) === false){
alert('Selection not defined properly.');
return;
}
var cell;
for(var cntSel = 0; cntSel<info.activeSel.length; cntSel++){
cell = document.getElementById(info.activeSel[cntSel][0]);
sapbi_rig_plan_setContent(cell, content);
}
}
Dear Kiran,
thanks for ypur answer.
After trying a lot of different things, i get it to work.
The Problem was not about the JS Function, I just called the wrong function for the paste functionality,
it must be: sapbi_rig_plan_paste_clipboard and NOT sapbi_rig_cp_paste_clipboard.
But thanks a lot, i just saw it in your code that the name changed.
So for all the others, it works when you use the the modification in the analysis item, as describe above. Then assign the JS Function to a button.
Copy some cells from excel, mark the cell you want to paste in the values and push the button.
Thanks 🙂
Hello,
Just to simplify my question:
Has anyone created BW 7.3 webtemplate(for IP input report), with copy paste from excel Java script functionality? Is it working with BW 7.3 Bex web?
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.