Skip to Content
0
Jun 05, 2020 at 12:02 PM

How to do a Odata.create in Frontend and Backend?

231 Views

Hello,

I am trying to do call the Create_Entity-Method of my OData-Service but there always occurs an error and it is not even entering the method.

Here is my code:

Controller:

var selLgtyp = sap.ui.getCore().getModel("lagpModel").getProperty(sModelPath + "/Lgtyp");
var selLgpla = sap.ui.getCore().getModel("lagpModel").getProperty(sModelPath + "/Lgpla");
            var sServiceUrl = "/sap/opu/odata/sap/ZPP_ODATA_UMLAGERUNG_SRV/";
            var NewModel = new sap.ui.model.odata.v2.ODataModel(sServiceUrl, true);
            var oEntry = {};
            oEntry.LGNUM = "HMB";
            oEntry.LGTYP = selLgtyp;
            oEntry.LGPLA = selLgpla;
            NewModel.create("/LAGPSet", 
                    oEntry, {
                    success: function (oData, response) {
                        // create JSON model
                        var oODataJSONModel = new sap.ui.model.json.JSONModel();
                        // set the odata JSON as data of JSON model
                    
                    },
                    error: function (oError) {
                        sap.m.MessageBox.alert("Fehler beim lesen der Daten: " + oError.message);
                    }
                });


ZPP_ODATA_UMLAGERUNG_SRV/LAGPSet_Create_Entity Method:

 METHOD lagpset_create_entity.
*  RAISE EXCEPTION TYPE /iwbep/cx_mgw_not_impl_exc
*   EXPORTING
*     textid = /iwbep/cx_mgw_not_impl_exc=>method_not_implemented
*     method = 'LAGPSET_CREATE_ENTITY'.
    DATA: ls_data LIKE er_entity.
    io_data_provider->read_entry_data( IMPORTING es_data = ls_data ).
  ENDMETHOD.

ERROR:

The following problem occurred: HTTP request failed400,Bad Request,{"error":{"code":"/IWCOR/CX_DS_EP_PROPERTY_ERROR/005056A509B11ED1BF822D2D09171A04","message":{"lang":"de","value":"Eigenschaft 'LGNUM' ist ungültig"},"innererror":{"application":{"component_id":"PP","service_namespace":"/SAP/","service_id":"ZPP_ODATA_UMLAGERUNG_SRV","service_version":"0001"},"transactionid":"EE06BDD2E7140080E005ED93CE6F368B","timestamp":"20200605120112.1103590","Error_Resolution":{"SAP_Transaction":"Run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details","SAP_Note":"See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)"},"errordetails":[]}}} -

Hope you can help me

Thanks and best regards

Jay