SAP Hana CRUD cloud platform issues

I'm trying to do a simple meek look at the Hana cloud platform, but I'm stuck on the building part. I have hdbdata defined like this.

`Type NameT {
        FIRST : SString;
        MIDDLE : SString;
        LAST : SString;
        INITIALS : BusinessKey;

Entity User {
        key UserID: BusinessKey;
        Name: NameT;
        Sex: String(1);
        Phone: SString;
        EmailAdress: SString;
        LoginName: String(12);
        AddressID: Association to Addresses null;
`

      

And I have a method in my controller like this

newUser: function() {
    var oModel = new sap.ui.model.odata.ODataModel("../services/user.xsodata/", true);
    var oEntry = {};
    var Name = {}
    oEntry.UserID = "0000000000";
    Name = {};
    Name.FIRST = sap.ui.getCore().byId("firstNameField").getValue();
    Name.MIDDLE = sap.ui.getCore().byId("middleNameField").getValue();
    Name.LAST = sap.ui.getCore().byId("lastNameField").getValue();
    oEntry.Name = Name;
    oEntry.LoginName = sap.ui.getCore().byId("userNameField").getValue();
    oEntry.Sex = sap.ui.getCore().byId("sexBox").getValue();
    oEntry.Phone = sap.ui.getCore().byId("phoneField").getValue();
    oEntry.EmailAdress = sap.ui.getCore().byId("emailField").getValue();
    //oEntry.AddressID = "1" //model.getProperty("AddressID", oTable.getContextByIndex(oTable.getSelectedIndex()));
    oModel.setHeaders({
        "content-type": "application/json;charset=utf-8"
    });
    oModel.create('/Users', oEntry, null, function() {
        alert("Create successful");
    }, function() {
        alert("Create failed");
    });

},

      

But no matter how I try to set the Name, I get the error

31 15:01:34 The following problem occurred: HTTP request failed400, Bad Request, {"error": { "code": "", "message": { "lang": "en-US", "value": "Request contains properties that do not exist in entity 'UsersType'."}}} - ...

Can anyone help me find out how to get the name for the create procedure?

+3


source to share





All Articles