公
告
:
读取商用配件数据
作者:confusion 日期:2010-06-18
//读取商用配件数据----------[传入in1 in2两参数 返回ret["PJDDH"] ret["PJDDH"] RFC中两个字段]
程序代码
sap_rfc_api.jsp 代码:
程序代码
拓展:
//---[传入in1 ano两参数 返回RFC中ret["TSAP"]表、ret["TSAP"][i]["KDAUF"]表中字段]
程序代码
程序代码function callServerlibo(in1){
if(in1 == ''){alert('请输入SAP订单号');return false;}
var in2 = document.all.fldpjddh.value;
var api = new SAP.RFC();
try{
api.setProxyURL("http://oa.china-chigo.com:8010/ajax/sap_rfc_api.jsp");
api.setPoolName("SAP889");
api.setRFCName("ZRFC_GET_ZHMX_PJ_SY");
api.addImportParameter("VBELNS",in1);
api.addImportParameter("PJT",in2);
api.addExportParameter("PJDDH");
api.addExportParameter("PJDDH2");
//api.addTableParameter("ZUKEY",SAP.RFC.EXPORT_FLAG);
api.callRFC(processResult);
}catch(ex){
alert(ex.description);
}
function processResult(ret){
if(ret[SAP.RFC.EXCEPTION]){ //发生异常
alert(ret[SAP.RFC.EXCEPTION]);
}else{ // 正常,处理结果
var a = ret["PJDDH"];
if(a.length>0){
document.all.fldkcpjsl.value=ret["PJDDH"];
document.all.fldpjddh.value=ret["PJDDH2"];
}
}
}
}
if(in1 == ''){alert('请输入SAP订单号');return false;}
var in2 = document.all.fldpjddh.value;
var api = new SAP.RFC();
try{
api.setProxyURL("http://oa.china-chigo.com:8010/ajax/sap_rfc_api.jsp");
api.setPoolName("SAP889");
api.setRFCName("ZRFC_GET_ZHMX_PJ_SY");
api.addImportParameter("VBELNS",in1);
api.addImportParameter("PJT",in2);
api.addExportParameter("PJDDH");
api.addExportParameter("PJDDH2");
//api.addTableParameter("ZUKEY",SAP.RFC.EXPORT_FLAG);
api.callRFC(processResult);
}catch(ex){
alert(ex.description);
}
function processResult(ret){
if(ret[SAP.RFC.EXCEPTION]){ //发生异常
alert(ret[SAP.RFC.EXCEPTION]);
}else{ // 正常,处理结果
var a = ret["PJDDH"];
if(a.length>0){
document.all.fldkcpjsl.value=ret["PJDDH"];
document.all.fldpjddh.value=ret["PJDDH2"];
}
}
}
}
sap_rfc_api.jsp 代码:
程序代码<%@ page language = "java" contentType = "text/html; charset=GBK" pageEncoding="GBK" %><%@ page import ="com.chigo.sap.*" %>
<?xml version="1.0" encoding="gbk" standalone="yes"?>
<%
boolean debug = true;
if(debug)
System.out.println("SAP代理开始执行!");
try{
request.setCharacterEncoding("UTF-8");
String xmlData = request.getParameter("data");
if(xmlData==null||xmlData.equals("")){
throw new Exception("未传输XML数据!");
}
if(debug){
System.out.println(xmlData);
}
out.print(new com.chigo.sap.SAP_RFC_API().runRFC(xmlData));
}catch(Exception ex){
ex.printStackTrace();
out.println("<return><exception>异常: "+ex.toString()+"</exception></return>");
}
if(debug)
System.out.println("SAP代理执行结束!");
%>
<?xml version="1.0" encoding="gbk" standalone="yes"?>
<%
boolean debug = true;
if(debug)
System.out.println("SAP代理开始执行!");
try{
request.setCharacterEncoding("UTF-8");
String xmlData = request.getParameter("data");
if(xmlData==null||xmlData.equals("")){
throw new Exception("未传输XML数据!");
}
if(debug){
System.out.println(xmlData);
}
out.print(new com.chigo.sap.SAP_RFC_API().runRFC(xmlData));
}catch(Exception ex){
ex.printStackTrace();
out.println("<return><exception>异常: "+ex.toString()+"</exception></return>");
}
if(debug)
System.out.println("SAP代理执行结束!");
%>
拓展:
//---[传入in1 ano两参数 返回RFC中ret["TSAP"]表、ret["TSAP"][i]["KDAUF"]表中字段]
程序代码function callServerlibo(in1){
alert(1);
var lengin1 = in1.split(splitStr);
var ano = document.all.fldano.value;
//alert("lengin1="+lengin1);
//alert("ano="+ano);
var api = new SAP.RFC();
try{
api.setProxyURL("http://oa.china-chigo.com:8010/ajax/sap_rfc_api.jsp");
api.setPoolName("SAP555");
api.setRFCName("ZRFC_GET_ZHMX");
api.addImportParameter("VBELNS",in1);
api.addImportParameter("ZNUMB",ano);
//api.addExportParameter("MESSAGE");
api.addTableParameter("TSAP",SAP.RFC.EXPORT_FLAG);
api.callRFC(processResult);
}catch(ex){
alert(ex.description);
}
function processResult(ret){
if(ret[SAP.RFC.EXCEPTION]){ //发生异常
alert(ret[SAP.RFC.EXCEPTION]);
}else{ // 正常,处理结果
//alert(ret["TSAP"].length);
if(ret["TSAP"].length>0){
for(var i=0;i<ret["TSAP"].length;i++){
document.getElementsByName("a14")[i].value = ret["TSAP"][i]["VDATU"];
}
}
}
}
}
alert(1);
var lengin1 = in1.split(splitStr);
var ano = document.all.fldano.value;
//alert("lengin1="+lengin1);
//alert("ano="+ano);
var api = new SAP.RFC();
try{
api.setProxyURL("http://oa.china-chigo.com:8010/ajax/sap_rfc_api.jsp");
api.setPoolName("SAP555");
api.setRFCName("ZRFC_GET_ZHMX");
api.addImportParameter("VBELNS",in1);
api.addImportParameter("ZNUMB",ano);
//api.addExportParameter("MESSAGE");
api.addTableParameter("TSAP",SAP.RFC.EXPORT_FLAG);
api.callRFC(processResult);
}catch(ex){
alert(ex.description);
}
function processResult(ret){
if(ret[SAP.RFC.EXCEPTION]){ //发生异常
alert(ret[SAP.RFC.EXCEPTION]);
}else{ // 正常,处理结果
//alert(ret["TSAP"].length);
if(ret["TSAP"].length>0){
for(var i=0;i<ret["TSAP"].length;i++){
document.getElementsByName("a14")[i].value = ret["TSAP"][i]["VDATU"];
}
}
}
}
}
评论: 0 | 引用: 0 | 查看次数: 105
发表评论
上一篇
下一篇


文章来自:
Tags: