Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

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){"Invoice " + oData.ivnum + " has been created", {
      icon : sap.m.MessageBox.Icon.SUCCESS, // default
      title : "Success"});},
    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);, {
      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.

asked 02 May '17, 07:56

suberta's gravatar image

accept rate: 0%

edited 02 May '17, 08:02

Mark%20Culp's gravatar image

Mark Culp

Could you please try your service call with LogVerbosity=4 and add the results (just the part where it processes your service call request) to your question ?

(02 May '17, 09:38) PhilippeBert...

I can add that "data1" should be an object with the properties and values to be posted to the server. E.g.

let data1 = { name: "hello", dest: "Vlad" };

Because OData works with objects, not with plain values. You can use (as an option) RESTClient-like software to experiment with requests/responses.

Oh, I have forgot to add - you can call the GET service, and specify the object's key, e.g.

GET yourEntitySet(1)

it will return you the OData entity in JSON (hopefully), and if you take it from the response, clean from the garbage that OData has (such as useless URLs), you should be able to submit this entity with POST. Please remember, that key is usually generated on the server side.

(03 May '17, 03:30) Vlad


The results after call with

LogVerbosity=4 and data1 = { name: "hello", dest: "Vlad" };

are as follows:

R. 2017-05-03 17:52:29. [test:4] Request GET D. 2017-05-03 17:52:29. [test:4] DataServiceVersion 2.0 Response 2.0 R. 2017-05-03 17:52:29. [main] - - [03/May/2017:17:52:29 +0530] "POST /connectedpharmacy/test/create HTTP/1.1" - 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36" "-" R. 2017-05-03 17:52:29. [test:5] Request POST D. 2017-05-03 17:52:29. [test:5] DataServiceVersion 2.0 Response 2.0 D. 2017-05-03 17:52:29. [test:5] Executing SQL Statement: CALL "cpadmin"."InvoiceCreate"( "data1" = ? ); D. 2017-05-03 17:52:29. [test:5] database error: "[SAP][JDBC Driver][SQL Anywhere]Syntax error near ')' on line 1 ". E. 2017-05-03 17:52:29. [test:5] (HTTP 500 Internal Server Error - 30000) An unexpected error occurred in the producer and was written to file "C:\ProgramData\SQL Anywhere 17\diagnostics\ODP17_20170503_175229_592.txt"

The file ODP17_20170503_175229_592.txt has following contents: database error: "[SAP][JDBC Driver][SQL Anywhere]Syntax error near ')' on line 1 ". at com.sybase.odata.producer.database.sqlanywhere.SASQLExceptionInterpreter.interpret( at com.sybase.odata.producer.database.InvokeRequest.execute( at com.sybase.odata.producer.handler.AbstractHandler.handleInvokeRequest( at com.sybase.odata.producer.handler.PostHandler.handleRequestImpl( at com.sybase.odata.producer.handler.AbstractHandler.handleRequest( at com.sybase.odata.producer.servlets.ODataServlet.doPost( at javax.servlet.http.HttpServlet.service( at com.sybase.odata.producer.servlets.ODataServlet.service( at javax.servlet.http.HttpServlet.service( at org.eclipse.jetty.servlet.ServletHolder.handle( at org.eclipse.jetty.servlet.ServletHandler.doHandle( at org.eclipse.jetty.server.handler.ContextHandler.doHandle( at org.eclipse.jetty.servlet.ServletHandler.doScope( at org.eclipse.jetty.server.handler.ContextHandler.doScope( at org.eclipse.jetty.server.handler.ScopedHandler.handle( at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle( at org.eclipse.jetty.server.handler.HandlerCollection.handle( at org.eclipse.jetty.server.handler.HandlerWrapper.handle( at org.eclipse.jetty.server.Server.handle( at org.eclipse.jetty.server.HttpChannel.handle( at org.eclipse.jetty.server.HttpConnection.onFillable( at$ at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob( at org.eclipse.jetty.util.thread.QueuedThreadPool$ at

(03 May '17, 08:31) suberta
Replies hidden

Wait a second, are you using OData model, but your web service awaits for a single parameter?

Could you please show me $metadata that the web server produces? I'd like to look at your schema.

The error you got from me is because my example was artificial, I don't know what exactly you have designed. When you use ODataModel.create, it is assumed that you define the entity set, not a custom web service.

(03 May '17, 08:50) Vlad

This XML file does not appear to have any style information associated with it. The document tree is shown below. <edmx:edmx xmlns:edmx="" version="1.0"> <edmx:dataservices xmlns:m="" m:dataserviceversion="1.0"> <schema xmlns:d="" xmlns:m="" xmlns="" namespace="SAPSQLOData"> <entitytype name="ivtg01">...</entitytype> <entitytype name="nrange">...</entitytype> <entitytype name="ivti01">...</entitytype> <entitytype name="cumg01">...</entitytype> <entitytype name="itmg01">...</entitytype> <entitytype name="immg01">...</entitytype> <entitytype name="itmg02">...</entitytype> <entitytype name="HELLO">...</entitytype> <entitycontainer name="test_Container" m:isdefaultentitycontainer="true">...</entitycontainer> </schema> </edmx:dataservices> </edmx:edmx>

(03 May '17, 08:56) suberta
Replies hidden

In the $metadata output I see neither InvoiceCreate, nor InvoiceCreate/create. Does it exist?

(03 May '17, 09:35) Vlad
showing 4 of 6 show all flat view

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)

permanent link

answered 03 May '17, 09:51

PhilippeBertrand%20_SAP_'s gravatar image

accept rate: 22%

edited 03 May '17, 11:46

We are using SQL Anywhere 17 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.

(04 May '17, 03:18) suberta
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 02 May '17, 07:56

question was seen: 1,806 times

last updated: 04 May '17, 03:18