Skip to Content

OCI Return from SAPUI5 to Material Management

Hi there,

we have implementet a shopping cart in SAPUI5. Its working fine, if we call a REST-Service to create a purchase order in SAP.

But now, we want to use this shop in materials management ME21N OCI-integration.

Theoretically I know what and how to post to sap. A test in plain HTML works fine.

I have implementet two different ways in SAPUI5 to post data to sap but none ist returning something.

Both variants return to SAP, but no data is delivered...

why should we use sapui5 if SAP itself prevents its use?

Variant1 HTML-creation:

var myForm="";
$.each(cartData.items, function(i,item){
 myForm += '<input type="hidden" name="NEW_ITEM-LINE['+i+']" value="'+i+'" />';
 myForm += '<input type="hidden" name="NEW_ITEM-DESCRIPTION['+i+']" value="'+item.name+'" />';
 myForm += '<input type="hidden" name="NEW_ITEM-LONGTEXT_1['+i+']" value="" />';
 myForm += '<input type="hidden" name="NEW_ITEM-QUANTITY['+i+']" value="'+item.quantity+'" />';
 myForm += '<input type="hidden" name="NEW_ITEM-UNIT['+i+']" value="PCE" />';
 myForm += '<input type="hidden" name="NEW_ITEM-PRICE['+i+']" value="'+item.price+'" />';
 myForm += '<input type="hidden" name="NEW_ITEM-CURRENCY['+i+']" value="EUR" />';
 myForm += '<input type="hidden" name="NEW_ITEM-PRICEUNIT['+i+']" value="1" />';
 myForm += '<input type="hidden" name="NEW_ITEM-LEADTIME['+i+']" value="0" />';
 myForm += '<input type="hidden" name="NEW_ITEM-VENDOR['+i+']" value="" />';
 myForm += '<input type="hidden" name="NEW_ITEM-VENDORMAT['+i+']" value="'+item.id+'" />';
 myForm += '<input type="hidden" name="NEW_ITEM-MATGROUP['+i+']" value="" />';
});
//myForm += '</form>';
var myhtml = new sap.ui.core.HTML();
 myhtml.setContent(myForm);
myhtml.placeAt("sendForm");
		
$("#sendForm").action=ociData.hook;
$("#sendForm").target=ociData.returntarget;
$("#sendForm").innerHTML = myForm;
$("#sendForm").submit();

In this variant it seems, the inbuild internet explorer cant understand js...

Variant2 - JSON-POST

var itemList = [];
$.each(cartData.items, function(i,item){
 var item1 = {
  LINE:"00001",
  DESCRIPTION:item.name,
  LONGTEXT_1:"",
  QUANTITY:item.quantity,
  UNIT:"PCE",
  PRICE:item.price,
  CURRENCY:"EUR",
  PRICEUNIT:"1",
  LEADTIME:"21",
  VENDOR:"",
  VENDORMAT:item.id,
  MATGROUP:""
 };
itemList.push( item1);
});
var oData = {
 NEW_ITEM: itemList
};
	
var osendModel = new sap.ui.model.json.JSONModel();
osendModel.attachRequestCompleted(function(oData) {
 oRData = osendModel.getData();
 if(oRData.status == '1'){
  var data = {
   items: []
  };
 oCartModel = new sap.ui.model.json.JSONModel(data);
 sap.ui.getCore().byId("app").setModel(oCartModel,"cart");
 obj.setEnabled(true);
 $("#tid").html("<h3>Total: 0.00 €</h3>");
 var msg = "Bestellung "+oRData.number+" angelegt.";
 sap.m.MessageToast.show(msg);
 }else{
 obj.setEnabled(true);
 sap.m.MessageToast.show("Fehler bei der Datenübertragung!");
 }
});
osendModel.attachRequestFailed(function(oData){
 obj.setEnabled(true);
 sap.m.MessageToast.show("Fehler bei der Datenübertragung!");
});
osendModel.attachParseError(function(oData){
 obj.setEnabled(true);
 sap.m.MessageToast.show("Fehler bei der Datenübertragung!");
});
osendModel.loadData(ociData.hook, oData, true, 'POST');

kind regards - Sven

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers