Skip to Content
0

How to call oModel.Create() for deep entity in sapui5?

Jul 06, 2017 at 05:49 AM

54

avatar image

I have to call oModel.Create() for creating data into 3 entity sets which are linked together.

Basically from front end once all attributes are filled then a sales order with all its attributes will be created in the backend. Hence i want to call oModel.Create() for that purpose. But its not working.

I am attaching my code here.

     	var ar = [];
        var RequestBody = {};
     	RequestBody.Vbeln = w,
        RequestBody.Ves_Name = sap.ui.getCore().byId("tbx_VesselName").getValue(),
        RequestBody.Ves_Arr_Date = sap.ui.getCore().byId("dp_vesselArrDate").getValue(),
       RequestBody.VVN = sap.ui.getCore().byId("tbx_VVN").getValue()
       var child = [];
     ar = tblContractLineDescription.getSelectedItems();
    for(var i=0;i<ar.length;i++){
   child.push({Zzlocation:sap.ui.getCore().byId("idLocation").getValue(),
      	         Comment:sap.ui.getCore().byId("tbx_comment").getValue(),
     	         //  Kwmeng:sap.ui.getCore().byId("tbx_cnt").getValue()
     	            });	}
   RequestBody.SO_Head_Item_Nav = child;
   oModel.create("/SO_Header_detailsSet",RequestBody,null,function(RequestBody,response)
   {sap.m.MessageBox.success("Sales Order  "  +  RequestBody.Vbeln +  "   has been created",{
     	     onClose:function(oAction){
     	   sap.ui.getCore().byId("tbx_VesselName").setValue()===""
     	   sap.ui.getCore().byId("dp_vesselArrDate").setValue()==="";
     	   sap.ui.getCore().byId("tbx_VVN").setValue()==="";
     	   sap.ui.getCore().byId("idLocation").setValue()==="";
     	    lsContractDetails.removeSelections();
     	                					}}		
     	                					
     	                					
     	                					)},
     	                			function(){alert("failed")}		
     	                			)
     	                			
					  			}
     	                			}]
			             })   	               
			            	               ]
			            })
			        ]
 		});


10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
avatar image
Former Member Jul 06, 2017 at 07:07 AM
0

Hello Anand,

RequestBody.SO_Head_Item_Nav = child;

It seems this code is correct. Kindly check the name "SO_Head_Item_Nav" under Navigation properties under your entity set(SO_Header_detailsSet)

if its available and Kindly let me know the error which is your getting

Regards

Vijay

Share
10 |10000 characters needed characters left characters exceeded