cancel
Showing results for 
Search instead for 
Did you mean: 

OData CreateEntity method getting triggered instead of oData Deep Create

06-25-2019 12:14 AM
4322 views 10 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Hi,

Below is the payLoad I am passing from WEBIDE to back-end(ECC). I want to send this date to back-end OData invoking '/IWBEP/IF_MGW_APPL_SRV_RUNTIME/CREATE_DEEP_ENTITY' but it actually triggers

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_ENTITY. Navigation property in the back-end is Ydept_Id. I have redefined both above mentioned methods (currently no code written as I want to check which method is getting invoked). May I know what mistake I am doing, ...anything with the payload in the below code ?

crtEmpRecord:function(){			
			var depId = this.getView().byId("deptId").getValue();
			var depNam = this.getView().byId("deptname").getValue();
			var empId = this.getView().byId("empId").getValue();
			var empNam = this.getView().byId("empName").getValue();
			
			var empAray = [];
			var obj1 = {
				"YempId": empId,
				"YempName": empNam,
				"YdeptId": depId
			};
			
			empAray.push(obj1);
			
			var finData = {
				"YdeptId": depId,
				"YdeptNam": depNam,
				"Ydept_Id": empAray
			};			
			
this.getView().getModel("local").create("/Department_1Set", finData, null, function(oData, oResponse)
		{
			sap.m.MessageBox.show("Employee Record Successfully Created");
		}
	);					
		}
0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

Thank you all for your inputs. I am closing this thread as it looks like the reason is not the above SAPUI5 porgram but the back-end OData implementation.

Answers (6)

Answers (6)

himanshupensia
Participant

Hi Vekanta,

To access create deep entity you must have navigation to some other entity. If you already have then use below code.

var payload = {};
//Put value of the header entity here . In my case it is Matnr .
payload.Matnr = '12345';
var empAray = [];
var obj1 = {
"YempId": empId,
"YempName": empNam,
"YdeptId": depId
};
empAray.push(obj1);
//put your array in navigation entity.In my case name of my Navigation entity is NAVMARC
payload.NAVMARC= empAray ;
this.getView().getModel("local").create("/Department_1Set", payload , null, function(oData, oResponse)
		{
			sap.m.MessageBox.show("Employee Record Successfully Created");
		}
	);					
		} 
mvaibhav
Contributor

hi Venkata,

The syntax you are using for .create method seems to be incorrect.

I believe you are using oData model v2.

.create method should have 3 parameters whereas your request has 4.

create(sPath, oData, mParameters?) : object

https://ui5.sap.com/#/api/sap.ui.model.odata.v2.ODataModel

Please check.

Thanks,

Vaibhav Maheshwari

agrawalaadhar8
Participant

Hi,

Does your target Entity has Associations and Navigation to other entities?

Kindly check this link once.

Regards

Former Member
0 Likes

Thanks for the response. It does have navigation/associations implemented but looks to be some issue there. As this above SAPUI5 code works fine when I point it to a different OData service.

junwu
SAP Champion
SAP Champion

there are many steps to achieve deep insert.

have you done all ?

what steps/blog you are following?

Former Member
0 Likes

Thanks Vaibhav. Just want to let you know that it actually is working fine now when I changed the OData service. Which then means that there is some issue with my OData implementation. So doens't look to be an issue with SAPUI5 OData.create.

But since you have touched the point, ..SAP site tells that create method on OData may not insert deep structure. But it actually is inserting...like in my above case. Is not this confusing or I am not following.

-----------

create

Trigger a POST request to the OData service that was specified in the model constructor.

Please note that deep creates are not supported and may not work.

----------

Former Member
0 Likes

Hi,

I know how to create a deep insert, ...I mean, I have done it in the past. But this time when I doing it my request go to Create_entity and not create_deep_entity.

May I ask you one question ....

If both the below methods are redefined, then based on what request the method gets invoked. I mean, when does the first method gets invoked and when does second method gets invoked.

1) /IWBEP/IF_MGW_APPL_SRV_RUNTIME/CREATE_DEEP_ENTITY

2) /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_ENTITY