cancel
Showing results for 
Search instead for 
Did you mean: 

Create Fiori Application with multiple entitysets

suraj_pabbathi2
Participant
0 Kudos

Hi,

We are developing Custom Fiori Application to create quotation which has header and line item details.

We have two entity sets, QuoteHeader and QuoteItems. Right now we are facing three challenges.

1. From custom ui5 application, how to submit details related to both QuoteHeader and QuoteItems at the same time.

Is there way we can test it from Gateway client to submit the data to QuoteHeader and QuoteItems?

/sap/opu/odata/sap/zgw_create_quotation_srv/???

2. When we generated two entity sets in gateway, it has generated services to support CRUD operations.

But when we see Create service it only supports creation of single record as it is created after structure but not the table.

for eg: er_entity is declared of type zcl_zgw_create_quotati_mpc=>TS_QuoteItems.

How to make/enable Create service take multiple records and update to the database?

3.And also here, we would need single header record and multiple line items from input and save it to database.

So we need a method in the class that need to read both header and item records.

Thanks,
Suraj Pabbathi

Accepted Solutions (1)

Accepted Solutions (1)

junwu
Active Contributor
0 Kudos

Former Member
0 Kudos

Hi Jun,

The blog you have suggested was very helpful. Can you if possible also suggest if the same could be handled in a xml view.

Thanks,

Srinivasan

suraj_pabbathi2
Participant
0 Kudos

Hi Jun,

Thanks for sharing this blog. I have completed the coding and trying to test the application.

However in the debug mode, it is not calling the 'CREATE_DEEP_ENTITY' operation.

Please provide inputs on how to invoke method CREATE_DEEP_ENTITY?

Thanks,

Suraj

junwu
Active Contributor
0 Kudos

do you have deep structure when call the creation ?

suraj_pabbathi2
Participant
0 Kudos

Hi Jun,

After looking into other threads and the blog provided here carefully, I had to revisit my payload and I am set.

The catch is Navigational Property and Association should be correctly defined.

http://schemas.microsoft.com/ado/2007/08/dataservices/related/<Navigational Property>

title="ZPROJ_GR_MULTIDEEP_SRV.AssociationName">

Thanks for pointing me in correct direction,

Suraj Pabbathi

Answers (1)

Answers (1)

ugurkaya
Active Participant
0 Kudos

Hey Suraj,

You could do something similiar to invoke create deep entity method

var oModel = this.getView().getModel();

var oData  = this.getView().getModel("create").getData(this._sPath).Order;

  this.getModel("appView").setProperty("/busy", true);

// add as many items you want

  var aQuoteItems= [];

  aQuoteItems.push({

  "HeaderGuid": oData.Guid,

  "ItemId": oData.ItemId,

  "Quantity" : oData.Quantity

  });

  var mPayload = {

  "d":

  {

  "HeaderGuid"       : oData.Guid,

  "QuoteId"   : oData.QuoteId,

  "Partner" : oData.Partner,

"QuoteItemsSet" : aQuoteItems

  }

  };

  console.log("mPayload", mPayload);

// create deep entity

  oModel.create("/QuoteHeader ", mPayload, null, jQuery.proxy(function(oData, oResponse){

  this.getModel("appView").setProperty("/busy", false);

  sap.m.MessageToast.show("Success!");

  },this),

  jQuery.proxy(function(oError){

     sap.m.MessageBox.show( 

     "Error", 

         sap.m.MessageBox.Icon.ERROR, 

         "Hata!" 

     );

     this.getModel("appView").setProperty("/busy", false);

  },this));