我创建了一个简单的HTML网站来使用Odata服务。
基本上,系统A调用网站并从系统B加载数据。当用户单击按钮时,将数据提交回系统A。这是针对IW32中我的OCI目录功能的。
我不知道HOOK URL是什么,也不知道如何将数据发布回系统A。
我想念什么吗?
<!DOCTYPE html>
<html>
<head>
<link href="Style.css" rel="stylesheet" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="Component.js"></script>
<meta charset="ISO-8859-1">
<title>Data from BPS</title>
</head>
<body>
<p>Materials from BPS</p>
Material:<input type="text" name="iMat" id="iMat"><br><br>
Material Type:<input type="text" name="iMatType" id="iMatType"><br><br>
Material Description:<input type="text" name="iMatDesc" id="iMatDesc"><br><br>
<!-- <input type="button" id="btnSubmit" name="storeSAP" value="Transfer to SAP"/> -->
<form id="form" name="frmbasket" action="http://example.com?sap-client=800?&HOOK_URL=SAPEVENT:POST"
method="post" target="_top">
<input type="button" id="button" value="Submit">
<table id=table>
<thead>
<tr>
<th>Material</th>
<th>MaterialType</th>
<th>MaterialDesc</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="hidden" name="NEW_ITEM-DESCRIPTION[1]" id="iMatDesc">
<input type="hidden" name="NEW_ITEM-MATNR[1]" id="iMat">
<input type="hidden" name="NEW_ITEM-MATGROUP[1]" value = "">
<input type="hidden" name="NEW_ITEM-QUANTITY[1]" value = "1">
<input type="hidden" name="NEW_ITEM-UNIT[1]" value = "EA">
<input type="hidden" name="NEW_ITEM-PRICE[1]" value = "71.85">
<input type="hidden" name="NEW_ITEM-PRICEUNIT[1]" value = "5">
<input type="hidden" name="NEW_ITEM-CURRENCY[1]" value = "USD">
<input type="hidden" name="NEW_ITEM-LEADTIME[1]" value = "1">
<input type="hidden" name="NEW_ITEM-VENDOR[1]" value = "">
<input type="hidden" name="NEW_ITEM-VENDORMAT[1]" value = "">
<input type="hidden" name="NEW_ITEM-MANUFACTCODE[1]" value = "">
<input type="hidden" name="NEW_ITEM-MANUFACTMAT[1]" value = "">
<input type="hidden" name="NEW_ITEM-CONTRACT[1]" value = "">
<input type="hidden" name="NEW_ITEM-CONTRACT_ITEM[1]" value = "">
<input type="hidden" name="NEW_ITEM-SERVICE[1]" value = "">
<input type="hidden" name="NEW_ITEM-EXT_QUOTE_ID[1]" value = "">
<input type="hidden" name="NEW_ITEM-EXT_QUOTE_ITEM[1]" value = "">
<input type="hidden" name="NEW_ITEM-EXT_PRODUCT_ID[1]" value = "">
<input type="hidden" name="NEW_ITEM-LONGTEXT_1:132[1]" value = "longtext_1: Test Text">
<input type="hidden" name="NEW_ITEM-CUST_FIELD1[1]" value = "custf 1.1">
<input type="hidden" name="NEW_ITEM-CUST_FIELD2[1]" value = "custf 1.2">
<input type="hidden" name="NEW_ITEM-CUST_FIELD3[1]" value = "custf 1.3">
<input type="hidden" name="NEW_ITEM-CUST_FIELD4[1]" value = "custf 1.4">
<input type="hidden" name="NEW_ITEM-CUST_FIELD5[1]" value = "custf 1.5">
<input type="hidden" name="NEW_ITEM-SORTF[1]" id="iMat">
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
这是Component.js,我已经为其编写了脚本
$(document)
.ready(
function() {
var query = "example.com" // root
// uri
+ "?$format=json"; // give me json
// + "&$callback=callback"; //this is my callback
$.ajax({
type: "GET",
dataType : 'json',
url : query,
// jsonpCallback : 'callback',
username: sUsername,
password: sPassword,
contentType: "application/json",
success : callback,
error: function (xhr) { //Add these parameters to display the required response
alert(xhr.status);
alert(xhr.statusText);
},
});
function callback(result) {
var html = '';
// var shows = result.d;
// $('#dsListTemplate').tmpl(shows).appendTo('#ds_shows');
$.each(result.d.results, function(i, post) {
html += '<tr>';
html += '<td>' + post.Material + '</td>';
html += '<td>' + post.MaterialType + '</td>';
html += '<td>' + post.MaterialDesc + '</td>';
html += '</tr>';
$('table tbody').html(html);
});
}
});
$(document).ready(function() {
$("#table").on("click", "tr", function(event) {
event.preventDefault();
$('#table tr').removeClass('selected');
$(this).addClass('selected');
document.getElementById("iMat").value = this.cells[0].innerHTML;
document.getElementById("iMatType").value = this.cells[1].innerHTML;
document.getElementById("iMatDesc").value = this.cells[2].innerHTML;
/* event = event || window.event; //for IE8 backward compatibility
var target = event.target || event.srcElement; //for IE8 backward compatibility
while (target && target.nodeName != 'tr') {
target = target.parentElement;
}
//var cells = target.cells; //cells collection
var cells = target.getElementsByTagName('td'); //alternative
if (!cells.length || target.parentNode.nodeName == 'THEAD') { // if clicked row is within thead
return;
}
var f1 = document.getElementById('Material');
var f2 = document.getElementById('MaterialType');
var f3 = document.getElementById('MaterialDesc');
f1.value = cells[0].innerHTML;
f2.value = cells[1].innerHTML;
f3.value = cells[2].innerHTML; */
});
});
$(document).ready(function(){
$( "#button" ).click(function() {
$( "#form" ).submit();
});
});
/*$(document).ready(function() {
$("#btnSubmit").click(function() {
var a=$("#form").serialize();
$.ajax({
type: "POST",
url: "http://example.com:8000/sap/bc/ui5_ui5/sap/XXXXXX/index.html?sap-client=800?&HOOK_URL=SAPEVENT:POST",
data: a,
success: function (data) {
alert(data);
}
});
});
});
*/
因此,当单击“提交”按钮时,我应该将这些NEW-FIELDS通过IW32(“组件”选项卡)转移回SAP系统
有什么建议吗?
答案 0 :(得分:0)
此问题已解决。问题出在我编码隐藏输入以及操作参数的位置