cancel
Showing results for 
Search instead for 
Did you mean: 

Passing two entity types in XSODATA

thamizharasan
Advisor
Advisor
0 Kudos
273

Hi,

I am trying to do an update in a table with xsodata using procedure. With this documentation Custom Exits for OData Write Requests - SAP HANA Developer Guide for SAP HANA Studio - SAP Library I came to know for update we need to pass 2 input parameters as entity types. For create I passed one input parameter (entity type) as input it worked fine. I used Odata.create() method to create an entity and my entity type as two cols so i passed the input as {"Col1": "Value1", "Col2" : Value2}.

But for update i need to pass two input parameters for entity. One is the old value and the another one is the updated value. I am using Odata.update() method to achieve this but stuck with passing the input parameters. Can anyone suggest me how to pass multiple input parameter for entity types.

Regards,

ThamizharasaN.

Accepted Solutions (0)

Answers (1)

Answers (1)

pfefferf
Active Contributor
0 Kudos

Hello Thamizharasan,

the input parameters you describe ar the parameters which contains the entity values before and after the update? If yes, you just need to specify/use the parameters in your OData write exit. They are supplied automatically.

In an SQLScript exit you need two IN parameters ("new" and "old") typed to the entity. In an XSJS exit you have a parameter (e.g. param) which has the properties "beforeTableName" and "afterTableName". These two properties contain the name of temporary tables which contains the data before and after the update).

Best Regards,

Florian

thamizharasan
Advisor
Advisor
0 Kudos

Hi Florian,

Thanks for the reply. I tested the procedure in SQLScript it works fine. But when i make a call from XSODATA i'm unable to pass to input parameters in the request..

Regards,

ThamizharasaN.

pfefferf
Active Contributor
0 Kudos

What do you mean with "call from XSODATA" + "unable to pass to input parameters"? Can you share what you wanna do?

thamizharasan
Advisor
Advisor
0 Kudos

Hi,

Below is my service.


service {

"mySchema"."mySchema.table::TEAM" as "TEAM"

        create using "mySchema.service::CreateTeam"

        update using "mySchema.service::UpdateTeam";     

}

Below is my porcedure.


PROCEDURE "mySchema"."mySchema.service::UpdateTeam" (

  IN team_detail  "mySchema"."mySchema.table::TEAM",

  IN team_update_detail "mySchema"."mySchema.table::TEAM",

     OUT error "mySchema"."mySchema.service::error_type"  )

  LANGUAGE SQLSCRIPT

  SQL SECURITY INVOKER

  --DEFAULT SCHEMA <default_schema_name>

  --READS SQL DATA

  AS

BEGIN

/*****************************

  Write your procedure logic

*****************************


--My procedure logic is here it's working fine.

END

I have tested the procedure in sql script it's working fine. I need to know how to call this service using OData.update() method..

Regards,

ThamizharasaN.

pfefferf
Active Contributor
0 Kudos

It is called automatically, cause you defined it in the service that it should be called for an update. So it is enough that your ODataModel points to the right OData service. The exit logic is then handled by the OData framework on HANA itself. No additional coding on client side is necessary (beside the update call itself).

Best Regards,

Florian

thamizharasan
Advisor
Advisor
0 Kudos

Hi Florian,


I understood your point. My doubt is about the passing the data to that service. for example..



oModel.update("/TEAM", {we pass data here(in which format the data should be passed)}, {

     success: function(response){

     },

     error: function(error){

      console.log(error);

     }

});

As you see the update method I'm unable to pass the Input parameters (entity types) to it. In SQLScript we will pass the temporary table to execute the procedure. Whereas here how should we pass the input...?



Regards,

ThamizharasaN.

pfefferf
Active Contributor
0 Kudos

You just have to pass the "new" data in JSON format. The framework determines the values for the "old" and "new" parameter of your procedure automatically and calls it automatically.

Regards,

Florian

former_member226419
Contributor
0 Kudos

Hi Thamizharasan,

Can you please share your procedure logic?

Just wants to replicate the same on my HANA machine,

Br

Sumeet