2014-12-30 82 views
1

我想在SAP BO“查询生成器”上运行脚本片段,它是使用SQL检索数据的简单工具。 (由于声誉,我无法上传图片,产品的界面可以在这里找到:http://scn.sap.com/docs/DOC-42952自动运行JavaScript脚本代码

由于我有一堆查询运行,我想用snippet自动运行它们。使用下面的代码:

//select the textarea to insert retrieved queries 
    document.querySelector("textarea").textContent = "SELECT * FROM CI_INFOOBJECTS"; 
    //click the submit button 
    document.getElementsByTagName('input')[0].click(); 

    //code to export the query result 

    //after click(), the page reloaded and it won't executed the following code. 
    document.addEventListener("DOMContentLoaded", function() { 
    //back to the previous page, run the previous code again 
     window.history.back(1); 
     }, false); 

有没有人有好的想法如何实现它?谢谢你的帮助。

回答

2

您可以使用Tampermonkey进行镶边,您可以从hibbard tampermonkey tutorial等网站了解如何使用它。 总体的sript应该是这样的:

// ==UserScript== 
 
// @name   Enter any name you like here 
 
// @namespace URL of website you own 
 
// @version  0.1 
 
// @description retrive data using sql 
 
// @author  Your name here 
 
// @match  relevant url 
 
// ==/UserScript== 
 
/* jshint -W097 */ 
 

 

 
// Your code here... 
 
//select the textarea to insert retrieved queries 
 
    document.querySelector("textarea").textContent = "SELECT * FROM CI_INFOOBJECTS"; 
 
    //click the submit button 
 
    document.getElementsByTagName('input')[0].click(); 
 

 
    //code to export the query result 
 

 
    //after click(), the page reloaded and it won't executed the following code. 
 
    document.addEventListener("DOMContentLoaded", function() { 
 
    //back to the previous page, run the previous code again 
 
     window.history.back(1); 
 
     }, false);
制作neccesay变化像@match。 请留言,如果您有任何疑问。希望它有帮助