on 2017 May 02 8:56 AM
Dear Experts,
To create entries in a SQL Anywhere table from an SAPUI5 application, I have created an odata producer:
service namespace "test" { serviceop post "cpadmin"."InvoiceCreate" as "create" returns multiplicity "0"; serviceop get "cpadmin"."InvoiceCreate" returns multiplicity "0"; }
The procedure InvoiceCreate has an import (IN) parameter: ALTER PROCEDURE "cpadmin"."InvoiceCreate"(IN data1 long varchar)
From the SAPUI5 application the call is made to the odata producer with the parameter for data1:
data1 = "hello"; this.oDataModel.create('/create', data1, null, function(oData, response){ sap.m.MessageBox.show("Invoice " + oData.ivnum + " has been created", { icon : sap.m.MessageBox.Icon.SUCCESS, // default title : "Success"});}, function(oError){ var test_str = oError.response.body; var start_pos = test_str.indexOf('value') + 8; var end_pos = test_str.indexOf('innererror', start_pos) - 4; var text_to_get = test_str.substring(start_pos, end_pos); sap.m.MessageBox.show(text_to_get, { icon : sap.m.MessageBox.Icon.ERROR, // default title : "Error"}); })
When I am calling the SAPUI5 application, I get the error: "Wrong number of parameters for Service Operation"
If I do no pass any parameter from the SAPUI5 application, it works fine. How can I pass data from the SAPUI5 application to this procedure. Kindly suggest.
Request clarification before answering.
There seems to be an issue with the stored procedure you are trying to access.
Executing SQL Statement: CALL "cpadmin"."InvoiceCreate"( "data1" = ? ); database error: "[SAP][JDBC Driver][SQL Anywhere]Syntax error near ')' on line 1 ".
What version of SQL Anywhere are you using (including build number)? How is the OData service launched?
Is there something else in the background that could be altering or removing the stored procedure? The metadata you posted does not include any reference to InvoiceCreate - are you sure the database hasn't been altered?
First try to get the stored procedure to work using dbisql as cpadmin (in case there is something wrong with the procedure itself) then try a browser (like chrome) to access the metadata and try calling the service operation. Once all that is working, you can worry about SAPUI5.
Note: if you change the database schema (add, alter tables and procedures), the OData server has to be restarted to reflect the changes.
(I confess I am not knowledgeable in UI5 so I'm speaking from a pure OData perspective)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
68 | |
16 | |
12 | |
7 | |
7 | |
4 | |
4 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.