cancel
Showing results for 
Search instead for 
Did you mean: 

error while sending data from SAPUI5 application to SQL procedure via odata producer

Former Member
2,254

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

philippefbertrand
Participant
0 Kudos

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)

Former Member
0 Kudos

We are using SQL Anywhere 17 17.0.0.1062. The Odata producer is exposing a procedure for POST operation. How can I view this in the metadata? InvoiceCreate is a procedure and create is the alias for this.