cancel
Showing results for 
Search instead for 
Did you mean: 

What to choose as service: XSJS or XSOData?

former_member186148
Active Participant
0 Kudos

Hello SDN!


In our HANA SPS08 we have master table and some dependent tables with association 1...n in DB. Data for these tables should come from UI in the same request. During saving GUID should be generated for master record and then used in dependend records. Which way is preferred for this task - using XSJS service or using XSOData service? Service will be consumed by SAPUI5.

I know how to do it in XSJS but I'm not sure that build XSJS service is the easiest way.

And the second little question - what does navigation in XSOData means?

Regards,

Lev

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I would personally always try to start with XSODATA since it provides a standard service interface and no/low custom coding approach.  I would only use a custom XSJS service for unusual data sources which can't be wrapped by a view or when non-Odata interface is needed. From what you what you described I don't see why that couldn't be accomplished with XSODATA using a Batch operation with content-ids and XSJS or Stored Procedure exits during the update/insert operations.

Navigation in XSODATA - you mean the Navigates keyword part of the entity definition? This is the where you use an association to tell the OData how navigation is possible between one or more entities. This will result in generating HTTP URL links in the resulting service data to the endpoint of the navigation specified.

former_member186148
Active Participant
0 Kudos

Hello Thomas!

Thank you for answer.

I've read and watched your video about associations, events and Content-Ids but I want to clarify something. Lets say I have two tables: Master and Details with one-to-many relation. I define them in XSOData service like this:


service {

    "demo::MASTER_TBL" as "Master"

    create events(

        before "pathToXSJSExit" // here I generate ID for Master

    );

    "demo::DETAILS_TBL" as "Details";

    association "MasterToDetails" principal "Master"("ID") multiplicity "1"
dependent "Details"("MASTER.ID") multiplicity "*";

}

I suppose I should use userexit to set MASTER.ID field for Details table. But where I should use it? In create event for Details or for association?

About Navigation - yes, I meant navigation keyword. Thank you for describing it.

Regards,

Lev

former_member594414
Participant
0 Kudos

Hi thomas.jung ,

Can you please help with clarifications to the below questions

a) We create an oData service and pass to UI. Let's say I create a service to expose the entire table and send the service to UI. In UI, they consume the service based on some filter conditions in the URI. So in which layer does the filter happen? UI,Middleware or DB? Some of my colleagues here say filter happens at UI layer and that causes lag in loading application.

b) If we use oData service, we make a lot of views based on the requirement. Is it a good practice to create these many DB artifacts?

c) Is it okay to directly call the Procedure for CRUD operations using oData exit? Or should we invoke an xsjslib and then call the procedure? Which is the best practice?

Please help

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate

arunelangovan - first its not really correct to ask new, unrelated questions in existing, closed forum entries. Really you should have posted these questions in their own, new forum entry.

a. if the filter condition is passed to the OData service via URl then it will be applied within the DB. The filter conditions become part of the WHERE condition on the generated query.

b. If you requirements for the views, then I don't seem the problem in having them. I don't really understand the question.

c. Sure. You have the option to use either SQLScript or XSJS in your exits. If you want to use the SQLScript language then its fine to use it directly. You only need to use XSJSLIB when you want to write your exits in JavaScript instead of SQLScript. So its a decision of with language (and there are definitely differences between the two / pros and cons of each) you want to use to write your exits. Once you've made that decision there is no reason to mix in XSJS if you have chosen SQLScript.