Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3363

Reading data from XML table and Perform Post Operation

$
0
0

Dear All,

 

I got struck in one requirement where i am using the XML view with table and editable values. After updation of the table with new values i would like to perform the Post operation and create the document number.

 

I have written the below code and not able to read the values from XML table and perform the Post operation.  Please correct me if i am wrong here and let me know the right approach to do it.

 

I have also read the values based on the sap.ui.getCore() as well but still i did not get values.

 

Here is my code :

var PoItemNo = this.getView().byId("PoNumber")

  .getText();

  ;

  var DelNumber1 = this.getView().byId("DONN").getValue();

  var Vendor1 = this.getView().byId("VendorNumber")

  .getValue();

  var Material1 = this.getView().byId("Material")

  .getValue();                                                    //

  // var VendorName1 =

  // this.getView().byId("VendorASNNumber").getValue();

  var MatDesc1 = this.getView().byId("MaterialDesc")

  .getValue();

  var ItemNo1 = this.getView().byId("Item").getValue();

  var Quan1 = this.getView().byId("Quan").getValue();

  var Plant1 = this.getView().byId("Plant").getValue();

  var StorageLoc1 = this.getView().byId("SLoc")

  .getValue();

  var Batch1 = this.getView().byId("SBATCH").getValue();

  var DoM1 = this.getView().byId("DatePickerm")

  .getValue();

  var DoE1 = this.getView().byId("DatePickerm")

  .getValue();

  var UoM1 = this.getView().byId("UOM").getValue();

 

 

 

  var ponum = this.getView().byId("PoNumber").getValue();

  var ServiceURL = "http://d12.com:8024/sap/opu/odata/sap/ZMM_SUBCON_PO_GW_SRV/VendorValidSet('+ponum+')";

 

 

  OData

  .request(

  {

  requestUri : ServiceURL,

  method : "GET",

  headers : {

  "X-Requested-With" : "XMLHttpRequest",

  "Content-Type" : "application/atom+xml",

  "DataServiceVersion" : "2.0",

  "X-CSRF-Token" : "Fetch"

  }

  },

 

 

  // The next step is to read the

  // X-CSRF-Token value from READ response

  // and prepare the POST method.

  // syntax to read the token.

  function(data, response) {

  header_xcsrf_token = response.headers['X-CSRF-Token'];

  console.log(header_xcsrf_token);

 

 

  // Now we have the valid CSRF

  // protection token to call

  // modifiable operations. We can use

  // this token with Create, Update

  // and Delete Operations.

  OData

  .request(

  {

  requestUri : "http://d12.com:8024/sap/opu/odata/sap/ZMM_SUBCON_PO_GW_SRV/VendorValidSet",

  method : "POST",

  headers : {

  "X-Requested-With" : "XMLHttpRequest",

  "Content-Type" : "application/atom+xml",

  // "DataServiceVersion": "2.0",

  "Accept": "application/atom+xml, application/atomsvc+xml, application/xml",

  "X-CSRF-Token": header_xcsrf_token,

 

  },

 

  data : {

  // PoNumber

  // :

  // $('#PoNumber').val(),

  // //

  // ProcType

  // :

  // this.getView().byId("ProcType').val(),

  // ProcType

  // : 1,

  // DelNumber

  // :

  // $('#DONN').val(),

  // // Vendor

  // :

  // $('#vnumid11').val(),

  // Vendor :

  // 4260001605,

  // VendorName

  // :

  // $('#VN').val(),

  // Material

  // :

  // $('#Material').val(),

  // MatDesc :

  // $('#MaterialDesc').val(),

  // ItemNo :

  // $('#Item').val(),

  // Quan :

  // $('#SQUAN').val(),

  // Plant :

  // $('#Plant').val(),

  // StorageLoc

  // :

  // $('#SLoc').val(),

  // Batch :

  // $('#SBATCH').val(),

  // DoM :

  // $('#DatePickerm').val(),

  // DoE :

  // $('#DatePickerme').val(),

  // UoM :

  // $('#UOM').val()

  // PoNumber

  // :

  // $('#PoNumber').val(),

  // ProcType

  // :

  // this.getView().byId("ProcType').val(),

  PoNumber : PoItemNo1,

  ProcType : 1,

  DelNumber : DelNumber1,

  // Vendor :

  // $('#vnumid11').val(),

  Vendor : 4260001605,

  VendorName : VendorName1,

  Material : Material1,

  MatDesc : MatDesc1,

  ItemNo : ItemNo1,

  Quan : Quan1,

  Plant : Plant1,

  StorageLoc : StorageLoc1,

  Batch : Batch1

  DoM : DoM1,

  DoE : DoE1,

  UoM : UoM1

 

 

  }

  },

 

  function(data,

  response) {

  sap.ui

  .getCore()

  .byId(

  "Main")

  .getModel(

  "PurchaseOrderSet")

  .refresh(

  true);

  alert('Success');

  },

  function(err) {

  alert('Error !!');

  } // anon function

 

  );


Viewing all articles
Browse latest Browse all 3363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>