cancel
Showing results for 
Search instead for 
Did you mean: 

Create Deep Entity is not working when use sapui5

former_member231869
Participant
0 Kudos

i have create Create Deep Entity in which create entity logic is present and its working fine in gateway client

But i dont know how to consume it in SAP WEB IDE

In sap web IDE i choose CRUD template for this.

but not able to create the entry plz help me regarding this.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You have to create an instance of odata model & perform create operation on Model.

var oModel = new sap.ui.model.odata.ODataModel(gatewayServiceUrl,true);

Create a JSON type of data

var  globalJSON;

var Items = []; // Item level Record

for(var i = 0 ;i <itemreocrd.length;i++)

{

// sample code

     var objItems = new Object();

     objItems.key1_Item = 'value1';

     objItems.key2_Item = 'value2';

     Items.push(objItems);

}

var oEntry= {};

oEntry.Key1_Header = 'Value1'.

oEntry.Key2_Header = 'Value2'.

oEntry.Items = Items; // contains array of objects.

try now  oModel.create('/collectionName', oEntry, null, function(success){},function(oerror){});

former_member231869
Participant
0 Kudos

Hi ,

     Prafulla Chandra

                   my sapui5 code is right but do u knw how to hit the create deep entity,i mean my create deep entity set is not going to be hit.

when i click on save button my HeaderEntity hits   

Former Member
0 Kudos

Hi,

Could be please ensure that your oEntry.Items Name , i.e. Name of the Key which has array of objects , and the Navigation Name in developed model Gateway Service is same (Case sensitive).

Also could you please ensure that your navigation properties name in gateway model & the field name inside the Deep Structure which accepts Table Type is same.

former_member231869
Participant
0 Kudos

Prafulla

this is the way i have created the service in odata gateway client m able to create PR that is working fine but when same service i consume from sapui5 my create deep entity is not hitting

Former Member
0 Kudos

Can you please let me know the snapshot of your UI5 Code as well. It looks fine form gateway end .. Just wanted to cross check how you have done from UI Level.

Former Member
0 Kudos

What I am thinking , Instead of Using

/PRHeadreCollection() , Try using PRHeaderColletion  ( i.e remove Brackets from the end)

and in the link , /PRItemCollection(PRNumber=''...) try using only /PRItemCollection.

Hope this could also hit you deep entity and also share UI5 code snapshot for better understanding.

former_member231869
Participant
0 Kudos

Hi Prafulla,

                   Thanks for your valuable suggestions.now i am sharing screenshots of sapui5 code.

plz check if you could find something.

Screenshot1 : code of view.js.

Screenshot2:  how it looks initial screen .

i have Display DocumentType and PRnumber on the initial page.

Screenshot3:- show controller code in which model is bind.

                             

Former Member
0 Kudos

Hi ,

Sorry for the delay in Repose,I just analyzed your code.

Can you please replace the below line

requestORderHeader.PRHeaderCollection = itemData;

with

requestORderHeader.PRItemCollection = itemData;

I hope it will work. Let me know if any queries,

Thanks,

Prafulla

former_member231869
Participant
0 Kudos

I replace as you said but still not any progress...actually giving error .....giving PRitem is invalid....i mean it gives error which is item data.....i try to remove PRitem then it gave PurGroup

PurGroup is invalid...