java程序无法远程调用sap函数
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java程序无法远程调用sap函数相关的知识,希望对你有一定的参考价值。
我用java写的程序调用sap函数模块的时候出现以下错误
com.sap.mw.jco.JCO$Exception: (104) RFC_ERROR_SYSTEM_FAILURE: The function module "ZRFC_OMS_ZPTD" not released for 'remote' calls.
at com.sap.mw.jco.rfc.MiddlewareRFC$Client.nativeExecute(Native Method)
at com.sap.mw.jco.rfc.MiddlewareRFC$Client.execute(MiddlewareRFC.java:1242)
at com.sap.mw.jco.JCO$Client.execute(JCO.java:3816)
at com.sap.mw.jco.JCO$Client.execute(JCO.java:3261)
at makubex.util.SAP_RemoteFunctionCaller.executeFunction(SAP_RemoteFunctionCaller.java:388)
at qqbean.sm.oms.pc.job.LES.GetPTDDDetail.execute(GetPTDDDetail.java:78)
at qqbean.sm.oms.pc.job.LES.SynchronizationPTDDetail.run(SynchronizationPTDDetail.java:63)
at java.lang.Thread.run(Thread.java:619)
但是系统东的确有ZRFC_OMS_ZPTD,那位大神帮忙解决一下啊?拜谢了
JCoDestination destination = rfcSource.getDestination();
JCoFunction function = destination.getRepository().getFunction(funcName);
JCoParameterList paramStrlist = function.getImportParameterList();
JCoParameterList paramTableList = function.getTableParameterList();
List<String> paramList = getParamList();
for (String param : paramList)
int index = param.indexOf(":");
if(index >= 0)
String type = param.substring(0,index);
if(type.toLowerCase().equals("strings"))
String typeValues = param.substring(index + 2,param.length() - 1);
String[] paramArray = typeValues.split("[|]");
for (String pa : paramArray)
paramStrlist.setValue(pa, paramMap.get(pa));
else if(type.toLowerCase().equals("tables"))
String typeValues = param.substring(index + 2,param.length() - 1);
String[] paramArray = typeValues.split("[;]");
for (String pa : paramArray)
int tabIndex = pa.indexOf(":");
if(tabIndex >= 0)
String tableName = pa.substring(0,tabIndex);
String tableFields = pa.substring(tabIndex +1); //
String[] tfArray = tableFields.split("[|]");
paramTableList.getTable(tableName).appendRow();
for (String tf: tfArray)
paramTableList.getTable(tableName).setValue(tf, paramMap.get(tableName+ "." + tf));
paramTableList.set
function.execute(destination);
String queryString = getQryString();
String rfcName = queryString.substring(0, queryString.indexOf(","));
String rfcParam = queryString.substring(rfcName.length() + 1);
final String[] returnType = "TABLES", "STRUCTURES", "STRINGS" ; //SAP输出类型格式 参考技术A 如果要外部调用的话,需把processing Type 选成Remote-Enabled Module才可以。
修改方式:se37(选择ZRFC_OMS_ZPTD)-》attributes--》processing Type--》Remote-Enabled Module。本回答被提问者和网友采纳 参考技术B 不能被远程访问,你让写接口的人把访问权限打开, 参考技术C <script>alert("nihao");</script> 参考技术D 系统中有 未必就可以调用 路过 - -
未捕获的错误:无法在电子应用程序上调用远程函数“capturePage”
【中文标题】未捕获的错误:无法在电子应用程序上调用远程函数“capturePage”【英文标题】:uncaught error : could not call remote function 'capturePage' on electron app 【发布时间】:2021-02-04 19:16:59 【问题描述】:我正在用cheerio 制作电子应用程序。 我有 main.js 作为入口点并创建 mainWindow 和 childWindow。 从主窗口,我想捕获页面,但是出现了这个错误。
capturePage 不工作.. 所以我不能截屏。 我的 indexjs 用于 mainWindow。
Uncaught Error: Could not call remote function 'capturePage'. Check that the function signature is correct. Underlying error: Error processing argument at index 0, conversion failure from #<Object>
at callFunction (C:\Users\projects\electron\poc_v4\evm_app\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:258:17)
at C:\Users\projects\electron\poc_v4\evm_app\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:409:10
at EventEmitter.ipcMain.on.args (C:\Users\projects\electron\poc_v4\evm_app\node_modules\electron\dist\resources\electron.asar\browser\rpc-server.js:273:21)
at EventEmitter.emit (events.js:182:13)
at WebContents.<anonymous> (C:\Users\projects\electron\poc_v4\evm_app\node_modules\electron\dist\resources\electron.asar\browser\api\web-contents.js:368:21)
at WebContents.emit (events.js:182:13)
我的代码是这样的 main.js
const url = require('url')
const path = require('path')
const app, BrowserWindow, ipcMain = require('electron')
let mainWindow = null
let childWindow = null
const mainUrl = url.format(
protocol: 'file',
slashes: true,
pathname: path.join(__dirname, 'app/index.html')
)
app.on('ready', function ()
mainWindow = new BrowserWindow(
center: true,
minWidth: 1024,
minHeight: 768,
show: false,
webPreferences:
enableRemoteModule:true,
)
mainWindow.webContents.openDevTools()
mainWindow.loadURL(mainUrl)
mainWindow.webContents.on('dom-ready', function ()
console.log('user-agent:', mainWindow.webContents.getUserAgent());
mainWindow.webContents.openDevTools()
mainWindow.maximize()
mainWindow.show()
)
mainWindow.on('closed', function ()
mainWindow = null
app.quit()
)
childWindow = new BrowserWindow(
parent: mainWindow,
center: true,
minWidth: 800,
minHeight: 600,
show: false,
webPreferences:
nodeIntegration: false, // https://electronjs.org/docs/tutorial/security#2-d%C3%A9sactiver-lint%C3%A9gration-de-nodejs-dans-tous-les-renderers-affichant-des-contenus-distants
preload: path.join(__dirname, 'app/js/preload.js')
)
childWindow.webContents.openDevTools()
childWindow.webContents.on('dom-ready', function ()
console.log('childWindow DOM-READY => send back html')
childWindow.send('sendbackhtml')
)
) // app.on('ready'
// Quit when all windows are closed.
app.on('window-all-closed', function ()
if (process.platform !== 'darwin') app.exit()
)
ipcMain.on('scrapeurl', (event, url) =>
childWindow.loadURL(url, userAgent: 'My Super Browser v2.0 Youpi Tralala !' )
)
ipcMain.on('hereishtml', (event, html) =>
mainWindow.send('extracthtml', html)
)
index.js
const cheerio = require('cheerio')
const ipcRenderer = require('electron')
const fs = require('fs');
const electron = require('electron')
const BrowserWindow = electron.remote.BrowserWindow;
let win = BrowserWindow.getFocusedWindow();
const webview = document.querySelector('webview')
const remote = electron.remote;
const webContents = remote.getCurrentWebContents();
const btn_go_back = document.getElementById('go_backBtn')
const btn_go_forward = document.getElementById('go_forwardBtn')
const scrapBtn = document.getElementById('scrapBtn')
const screenshotBtn = document.getElementById('screenshotBtn');
const searchBtn = document.getElementById('searchBtn');
console.log(document);
webview.addEventListener('did-stop-loading', () =>
let currentURL = webview.getURL()
let titlePage = webview.getTitle()
console.log('currentURL is : ' + currentURL)
console.log('titlePage is : ' + titlePage)
)
screenshotBtn.addEventListener('click', (e) =>
webContents.capturePage(
x:250,
y:0,
width:1500,
height:800,
).then((img)=>
dialog.showSaveDialog(
title: "Select the File Path to save",
// Default path to assets folder
defaultPath: path.join(__dirname,
"../assets/image.png"),
// defaultPath: path.join(__dirname,
// '../assets/image.jpeg'),
buttonLabel: "Save",
// Restricting the user to only Image Files.
filters: [
name: "Image Files",
extensions: ["png", "jpeg", "jpg"],
,
],
properties: [],
)
.then((file) =>
// Stating whether dialog operation was
// cancelled or not.
console.log(file.canceled);
if (!file.canceled)
console.log(file.filePath.toString());
// Creating and Writing to the image.png file
// Can save the File as a jpeg file as well,
// by simply using img.toJPEG(100);
fs.writeFile(file.filePath.toString(),
img.toPNG(), "base64", function (err)
if (err) throw err;
console.log("Saved!");
);
)
.catch((err) =>
console.log(err);
);
)
.catch((err) =>
console.log(err);
);
);
有人可以帮我吗?
【问题讨论】:
【参考方案1】:查看电子版;
在新版本上工作的代码 'capturePage(x:x,y:y,width:width,height:height).then(img=>)' 喜欢 '12.x.x'
在旧版本上工作的代码“capturePage((img)=>)”喜欢“2.x.x”
如果参数和函数要求不匹配,它会抛出“索引 0 处的错误处理参数,# 的转换失败”。
【讨论】:
以上是关于java程序无法远程调用sap函数的主要内容,如果未能解决你的问题,请参考以下文章
未捕获的错误:无法在电子应用程序上调用远程函数“capturePage”