Skip to Content
0
Former Member
Jul 05, 2016 at 09:52 PM

XS OData POST with returning data

447 Views

Experts,

I wrote a rather complex stored procedure that inserts or updates a record in a z-table.

This procedure will be called as 'CREATE USING', linked to an XS OData service.

This service will be called from an app in the HCP (licenced version) but that 's not realy important here.

The problem I'm facing is that I need to receive the created ID as a return of the POST operation, which is handled by the stored procedure.

Like I read on SCN this is impossible with cette procedure and I would have to use an XSJS lib.

I found and saw some examples on how to use this but it is still unclear how I could achieve this, keeping the logic in the stored procedure.

Recap:

OData model -> service with create using (SP or XSJS lib ?)

Creation process should happen in the SP and I should be able to pass the errors as wel as the newly created ID back to the UI that called the service.

I know it should be XSJS but I'm searching for a good example that comes as close as possible to my situation.

I would think it's something like this:


XS OData model

service{

... as ...

CREATE USING 'reference to your xsjs lib:function name'

}

xsjs lib file

xsjs lib:function name

{

// read the imported data from the posted body


// call the procedure that returns an error or not


// no error, get the ID (or receive it in the previous step but will be hard in combination with error type I think ?)


// compose OData return with error message or success message and new ID (if it wasn't an update).

}

Thanks in advance and points will be awarded!