Skip to Content
0
Former Member
Apr 24, 2014 at 10:41 AM

Create Deep Entity in SAP UI5 - oData Model

964 Views

Hi,

I am doing a CRUD project and want to perform a deep entity creation. I've an entity Student and another is Enrollment. A Student can have multiple Enrollments. For this, I've created Association b/w these 2 entities.

Now from SAP UI5, i want to call create operation in which while creating Student record, i also want Enrollment records to be inserted into DB.

I am trying to use the following code to create the required Data object.

oNewEntry.StudentID = "000"; // Will be generated

oNewEntry.StudentName = "Xyz";

oNewEntry.Course = "ABC";

oNewEntry.Age = parseInt(25);

oEnrollment = {};

oEnrollment.StudentID = "000";

oEnrollment.CertificateID = "SAPUI5";

oEnrollment.EnrollDate = new Date(2014,03,30,00,01,00);

oEnrollment.CreateDate = new Date(2014,03,30,00,01,00);

oEnrollment.Status = "X";

oNewEntry.Enrollment = oEnrollment;

oModel.create("/StudentSet",

oNewEntry,

null,

function()

{

alert("Student record created successfully!");

},

function()

{

alert("Student record creation failed!");

}

);

I am trying the above code, but it always throw the following error.

The following error text was processed in system GW1 : Specified value is not a valid value for the type of an XML document The error occurred on the application server XXXXXX. The termination type was: RABAX_STATE.

Am i doing any mistake while creating oNewEntry object ? As I am able to create entity StudentSet & EnrollmentSet individually but not as Deep Entity in one go.

Please Help.