cancel
Showing results for 
Search instead for 
Did you mean: 

APPLICATION_SCOPE vs TASK_SCOPE

Former Member
0 Kudos

Hi,

I've been doing some reading on using APPLICATION_SCOPE or TASK_SCOPE for model components.

What I understand is that by default APPLICATION_SCOPE is used and this is to optimise the number of connections to the backend (ABAP) by making sure that if several components use the same model, they will use the same connection.

Now, you can also set TASK_SCOPE which will not share the connection but will disconnect after each operation to the ABAP backend.

Could anyone enlighten me further on the advantages of using APPLICATION_SCOPE ? Does it have functionnal advantages such as allowing you to do multiple updates before commit ?

Also, if a user is running 2 applications which use the same connection pool and the same model object with APPLICATION_SCOPE, will he use 1 or 2 connections to the backend.

I'm trying to find reasons why using TASK_SCOPE would not be good but other than the impact of connecting and disconnecting to the system, it seems better since it would use less connections and thus eat up less memory on the ABAP side.

Thanks for your advice.

Accepted Solutions (0)

Answers (1)

Answers (1)

vmadhuvarshi_
Contributor
0 Kudos

Thierry,

You are correct that APPLICATION_SCOPE is the default scope used by model instances. This makes all the components in application share the same MODEL instance and thus reduces overhead of creating many model instances when one would suffice. Furthermore, with this SCOPE, you can make more than one model share the same JCO connection pool easily by using setConnectionProvider method of your model instance which is a good practice to avoid potential lock conflicts in ABAP side by avoiding allocation of multiple Roll areas for a single user.

In comparison, TASK_SCOPE lasts for only one round trip and thus adds the overhead of creating a MODEL instance every time a connection is required. For development, this overhead is not much but think about the production scenario where 100s of users are using the application and the overhead becomes significant.

Besides APPLICATION_SCOPE and TASK_SCOPE, there are COMPONENT_SCOPE (One instance of model will be shared by all controllers within a single component) and NO_SCOPE (Multiple applications can share the same model instance) also available.

Hope this helps.

Vishwas.

Former Member
0 Kudos

Hi,

where did you find information regarding all of the scopes ?

Thank you.

vmadhuvarshi_
Contributor
0 Kudos

Thierry,

I refer the book [Inside Web Dynpro for Java|http://sappress.com/product.cfm?account=vmadhuvarshi&session=02hh12umynrpl7mervwv&product=H983] by Chris Whealy. An excellent book for Web Dynpro Java programmers.

Regards,

Vishwas.